Commit c2ebaa42 authored by Dave Hansen's avatar Dave Hansen Committed by Linus Torvalds

[PATCH] sparsemem base: early_pfn_to_nid() (works before sparse is initialized)

The following four patches provide the last needed changes before the
introduction of sparsemem.  For a more complete description of what this
will do, please see this patch:

or previous posts on the subject:

Three of these are i386-only, but one of them reorganizes the macros
used to manage the space in page->flags, and will affect all platforms.
There are analogous patches to the i386 ones for ppc64, ia64, and
x86_64, but those will be submitted by the normal arch maintainers.

The combination of the four patches has been test-booted on a variety of
i386 hardware, and compiled for ppc64, i386, and x86-64 with about 17
different .configs.  It's also been runtime-tested on ia64 configs (with
more patches on top).

This patch:

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
Signed-off-by: default avatarAndy Whitcroft <>
Signed-off-by: default avatarDave Hansen <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 408fde81
......@@ -146,6 +146,21 @@ static void __init find_max_pfn_node(int nid)
/* Find the owning node for a pfn. */
int early_pfn_to_nid(unsigned long pfn)
int nid;
for_each_node(nid) {
if (node_end_pfn[nid] == 0)
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment