diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-07-03 10:25:08 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-07-03 10:25:08 -0400 |
commit | 0a1340c185734a57fbf4775927966ad4a1347b02 (patch) | |
tree | d9ed8f0dd809a7c542a3356601125ea5b5aaa804 /mm/sparse.c | |
parent | af18ddb8864b096e3ed4732e2d4b21c956dcfe3a (diff) | |
parent | 29454dde27d8e340bb1987bad9aa504af7081eba (diff) |
Merge rsync://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts:
include/linux/kernel.h
Diffstat (limited to 'mm/sparse.c')
-rw-r--r-- | mm/sparse.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/mm/sparse.c b/mm/sparse.c index 100040c0dfb6..86c52ab80878 100644 --- a/mm/sparse.c +++ b/mm/sparse.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * sparse memory mappings. | 2 | * sparse memory mappings. |
3 | */ | 3 | */ |
4 | #include <linux/config.h> | ||
5 | #include <linux/mm.h> | 4 | #include <linux/mm.h> |
6 | #include <linux/mmzone.h> | 5 | #include <linux/mmzone.h> |
7 | #include <linux/bootmem.h> | 6 | #include <linux/bootmem.h> |
@@ -45,7 +44,7 @@ static struct mem_section *sparse_index_alloc(int nid) | |||
45 | 44 | ||
46 | static int sparse_index_init(unsigned long section_nr, int nid) | 45 | static int sparse_index_init(unsigned long section_nr, int nid) |
47 | { | 46 | { |
48 | static spinlock_t index_init_lock = SPIN_LOCK_UNLOCKED; | 47 | static DEFINE_SPINLOCK(index_init_lock); |
49 | unsigned long root = SECTION_NR_TO_ROOT(section_nr); | 48 | unsigned long root = SECTION_NR_TO_ROOT(section_nr); |
50 | struct mem_section *section; | 49 | struct mem_section *section; |
51 | int ret = 0; | 50 | int ret = 0; |
@@ -99,6 +98,22 @@ int __section_nr(struct mem_section* ms) | |||
99 | return (root_nr * SECTIONS_PER_ROOT) + (ms - root); | 98 | return (root_nr * SECTIONS_PER_ROOT) + (ms - root); |
100 | } | 99 | } |
101 | 100 | ||
101 | /* | ||
102 | * During early boot, before section_mem_map is used for an actual | ||
103 | * mem_map, we use section_mem_map to store the section's NUMA | ||
104 | * node. This keeps us from having to use another data structure. The | ||
105 | * node information is cleared just before we store the real mem_map. | ||
106 | */ | ||
107 | static inline unsigned long sparse_encode_early_nid(int nid) | ||
108 | { | ||
109 | return (nid << SECTION_NID_SHIFT); | ||
110 | } | ||
111 | |||
112 | static inline int sparse_early_nid(struct mem_section *section) | ||
113 | { | ||
114 | return (section->section_mem_map >> SECTION_NID_SHIFT); | ||
115 | } | ||
116 | |||
102 | /* Record a memory area against a node. */ | 117 | /* Record a memory area against a node. */ |
103 | void memory_present(int nid, unsigned long start, unsigned long end) | 118 | void memory_present(int nid, unsigned long start, unsigned long end) |
104 | { | 119 | { |
@@ -113,7 +128,8 @@ void memory_present(int nid, unsigned long start, unsigned long end) | |||
113 | 128 | ||
114 | ms = __nr_to_section(section); | 129 | ms = __nr_to_section(section); |
115 | if (!ms->section_mem_map) | 130 | if (!ms->section_mem_map) |
116 | ms->section_mem_map = SECTION_MARKED_PRESENT; | 131 | ms->section_mem_map = sparse_encode_early_nid(nid) | |
132 | SECTION_MARKED_PRESENT; | ||
117 | } | 133 | } |
118 | } | 134 | } |
119 | 135 | ||
@@ -164,6 +180,7 @@ static int sparse_init_one_section(struct mem_section *ms, | |||
164 | if (!valid_section(ms)) | 180 | if (!valid_section(ms)) |
165 | return -EINVAL; | 181 | return -EINVAL; |
166 | 182 | ||
183 | ms->section_mem_map &= ~SECTION_MAP_MASK; | ||
167 | ms->section_mem_map |= sparse_encode_mem_map(mem_map, pnum); | 184 | ms->section_mem_map |= sparse_encode_mem_map(mem_map, pnum); |
168 | 185 | ||
169 | return 1; | 186 | return 1; |
@@ -172,8 +189,8 @@ static int sparse_init_one_section(struct mem_section *ms, | |||
172 | static struct page *sparse_early_mem_map_alloc(unsigned long pnum) | 189 | static struct page *sparse_early_mem_map_alloc(unsigned long pnum) |
173 | { | 190 | { |
174 | struct page *map; | 191 | struct page *map; |
175 | int nid = early_pfn_to_nid(section_nr_to_pfn(pnum)); | ||
176 | struct mem_section *ms = __nr_to_section(pnum); | 192 | struct mem_section *ms = __nr_to_section(pnum); |
193 | int nid = sparse_early_nid(ms); | ||
177 | 194 | ||
178 | map = alloc_remap(nid, sizeof(struct page) * PAGES_PER_SECTION); | 195 | map = alloc_remap(nid, sizeof(struct page) * PAGES_PER_SECTION); |
179 | if (map) | 196 | if (map) |