aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Hansen <haveblue@us.ibm.com>2005-10-29 21:16:51 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 00:40:44 -0400
commit4ca644d970bf2542623228a4624af356d20ca267 (patch)
tree1040782e8799d5531a5ee1d5f1143e26e8781e9d
parented8ece2ec8d3c2031b1a1a0737568bb0d49454e0 (diff)
[PATCH] memory hotplug prep: __section_nr helper
A little helper that we use in the hotplug code. Signed-off-by: Dave Hansen <haveblue@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--include/linux/mmzone.h1
-rw-r--r--mm/sparse.c25
2 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 7519eb4191e7..4674145bb63d 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -509,6 +509,7 @@ static inline struct mem_section *__nr_to_section(unsigned long nr)
509 return NULL; 509 return NULL;
510 return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; 510 return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK];
511} 511}
512extern int __section_nr(struct mem_section* ms);
512 513
513/* 514/*
514 * We use the lower bits of the mem_map pointer to store 515 * We use the lower bits of the mem_map pointer to store
diff --git a/mm/sparse.c b/mm/sparse.c
index 347249a4917a..0d3bd4bf3aaa 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -72,6 +72,31 @@ static inline int sparse_index_init(unsigned long section_nr, int nid)
72} 72}
73#endif 73#endif
74 74
75/*
76 * Although written for the SPARSEMEM_EXTREME case, this happens
77 * to also work for the flat array case becase
78 * NR_SECTION_ROOTS==NR_MEM_SECTIONS.
79 */
80int __section_nr(struct mem_section* ms)
81{
82 unsigned long root_nr;
83 struct mem_section* root;
84
85 for (root_nr = 0;
86 root_nr < NR_MEM_SECTIONS;
87 root_nr += SECTIONS_PER_ROOT) {
88 root = __nr_to_section(root_nr);
89
90 if (!root)
91 continue;
92
93 if ((ms >= root) && (ms < (root + SECTIONS_PER_ROOT)))
94 break;
95 }
96
97 return (root_nr * SECTIONS_PER_ROOT) + (ms - root);
98}
99
75/* Record a memory area against a node. */ 100/* Record a memory area against a node. */
76void memory_present(int nid, unsigned long start, unsigned long end) 101void memory_present(int nid, unsigned long start, unsigned long end)
77{ 102{