It occurs to me that we _know_ which node pages in general belong to. At least at a very gross level in node_{start,end}_pfn[]. Use those to target the allocations of pages. Signed-off-by: Andy Whitcroft Signed-off-by: Dave Hansen --- memhotplug-dave/arch/i386/mm/discontig.c | 12 ++++++++++++ memhotplug-dave/arch/ppc64/mm/numa.c | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff -puN arch/i386/mm/discontig.c~B-sparse-130-add-early_pfn_to_nid arch/i386/mm/discontig.c --- memhotplug/arch/i386/mm/discontig.c~B-sparse-130-add-early_pfn_to_nid 2005-02-17 15:25:35.000000000 -0800 +++ memhotplug-dave/arch/i386/mm/discontig.c 2005-02-17 15:25:35.000000000 -0800 @@ -122,6 +122,18 @@ static void __init find_max_pfn_node(int BUG(); } +/* Find the owning node for a pfn. */ +int early_pfn_to_nid(unsigned long pfn) +{ + int nid; + + for (nid = 0; nid < MAX_NUMNODES && node_end_pfn[nid] != 0; nid++) + if (node_start_pfn[nid] <= pfn && node_end_pfn[nid] >= pfn) + return nid; + + return 0; +} + /* * Allocate memory for the pg_data_t for this node via a crude pre-bootmem * method. For node zero take this from the bottom of memory, for diff -puN arch/ppc64/mm/numa.c~B-sparse-130-add-early_pfn_to_nid arch/ppc64/mm/numa.c --- memhotplug/arch/ppc64/mm/numa.c~B-sparse-130-add-early_pfn_to_nid 2005-02-17 15:25:35.000000000 -0800 +++ memhotplug-dave/arch/ppc64/mm/numa.c 2005-02-17 15:25:35.000000000 -0800 @@ -662,3 +662,20 @@ static int __init early_numa(char *p) return 0; } early_param("numa", early_numa); + +/* Find the owning node for a pfn. */ +int early_pfn_to_nid(unsigned long pfn) +{ + int nid; + + for (nid = 0; nid < MAX_NUMNODES && + init_node_data[nid].node_spanned_pages; nid++) { + unsigned long start = init_node_data[nid].node_start_pfn; + unsigned long end = start + + init_node_data[nid].node_spanned_pages; + if (start <= pfn && pfn <= end) + return nid; + } + + return 0; +} _