From 0f0acd565561b48bb1df5ce38712b314d0d147de Mon Sep 17 00:00:00 2001 From: Dave Hansen Date: Sat, 29 Oct 2005 18:16:51 -0700 Subject: [PATCH] --- yaml --- r: 11387 b: refs/heads/master c: 4ca644d970bf2542623228a4624af356d20ca267 h: refs/heads/master i: 11385: 76849428bde23f35efb1562420c6f08402c295bc 11383: c2d45457e6334ddbb4ba7a818cb827906e9136a4 v: v3 --- [refs] | 2 +- trunk/include/linux/mmzone.h | 1 + trunk/mm/sparse.c | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index fc43fef07162..26f3cdf583c7 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ed8ece2ec8d3c2031b1a1a0737568bb0d49454e0 +refs/heads/master: 4ca644d970bf2542623228a4624af356d20ca267 diff --git a/trunk/include/linux/mmzone.h b/trunk/include/linux/mmzone.h index 7519eb4191e7..4674145bb63d 100644 --- a/trunk/include/linux/mmzone.h +++ b/trunk/include/linux/mmzone.h @@ -509,6 +509,7 @@ static inline struct mem_section *__nr_to_section(unsigned long nr) return NULL; return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; } +extern int __section_nr(struct mem_section* ms); /* * We use the lower bits of the mem_map pointer to store diff --git a/trunk/mm/sparse.c b/trunk/mm/sparse.c index 347249a4917a..0d3bd4bf3aaa 100644 --- a/trunk/mm/sparse.c +++ b/trunk/mm/sparse.c @@ -72,6 +72,31 @@ static inline int sparse_index_init(unsigned long section_nr, int nid) } #endif +/* + * Although written for the SPARSEMEM_EXTREME case, this happens + * to also work for the flat array case becase + * NR_SECTION_ROOTS==NR_MEM_SECTIONS. + */ +int __section_nr(struct mem_section* ms) +{ + unsigned long root_nr; + struct mem_section* root; + + for (root_nr = 0; + root_nr < NR_MEM_SECTIONS; + root_nr += SECTIONS_PER_ROOT) { + root = __nr_to_section(root_nr); + + if (!root) + continue; + + if ((ms >= root) && (ms < (root + SECTIONS_PER_ROOT))) + break; + } + + return (root_nr * SECTIONS_PER_ROOT) + (ms - root); +} + /* Record a memory area against a node. */ void memory_present(int nid, unsigned long start, unsigned long end) {