[PATCH 1/2] x86, numa, emu: move size calculation into if block

From: Yinghai Lu
Date: Wed Mar 02 2011 - 20:25:53 EST




don't need to assign them that early.

Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>
---
arch/x86/mm/numa_64.c | 11 +++++------
arch/x86/mm/numa_emulation.c | 3 ++-
2 files changed, 7 insertions(+), 7 deletions(-)

Index: linux-2.6/arch/x86/mm/numa_64.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_64.c
+++ linux-2.6/arch/x86/mm/numa_64.c
@@ -390,13 +390,12 @@ static void __init numa_nodemask_from_me
*/
void __init numa_reset_distance(void)
{
- size_t size = numa_distance_cnt * numa_distance_cnt * sizeof(numa_distance[0]);
-
/* numa_distance could be 1LU marking allocation failure, test cnt */
- if (numa_distance_cnt)
- memblock_x86_free_range(__pa(numa_distance),
- __pa(numa_distance) + size);
- numa_distance_cnt = 0;
+ if (numa_distance_cnt) {
+ size_t size = numa_distance_cnt * numa_distance_cnt * sizeof(numa_distance[0]);
+ memblock_x86_free_range(__pa(numa_distance), __pa(numa_distance) + size);
+ numa_distance_cnt = 0;
+ }
numa_distance = NULL; /* enable table creation */
}

Index: linux-2.6/arch/x86/mm/numa_emulation.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_emulation.c
+++ linux-2.6/arch/x86/mm/numa_emulation.c
@@ -300,7 +300,7 @@ void __init numa_emulation(struct numa_m
static struct numa_meminfo pi __initdata;
const u64 max_addr = max_pfn << PAGE_SHIFT;
u8 *phys_dist = NULL;
- size_t phys_size = numa_dist_cnt * numa_dist_cnt * sizeof(phys_dist[0]);
+ size_t phys_size = 0;
int i, j, ret;

if (!emu_cmdline)
@@ -341,6 +341,7 @@ void __init numa_emulation(struct numa_m
if (numa_dist_cnt) {
u64 phys;

+ phys_size = numa_dist_cnt * numa_dist_cnt * sizeof(phys_dist[0]);
phys = memblock_find_in_range(0,
(u64)max_pfn_mapped << PAGE_SHIFT,
phys_size, PAGE_SIZE);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/