[PATCH] remove non-DISCONTIG use of pgdat->node_mem_map
This patch effectively eliminates direct use of pgdat->node_mem_map outside of the DISCONTIG code. On a flat memory system, these fields aren't currently used, neither are they on a sparsemem system. There was also a node_mem_map(nid) macro on many architectures. Its use along with the use of ->node_mem_map itself was not consistent. It has been removed in favor of two new, more explicit, arch-independent macros: pgdat_page_nr(pgdat, pagenr) nid_page_nr(nid, pagenr) I called them "pgdat" and "nid" because we overload the term "node" to mean "NUMA node", "DISCONTIG node" or "pg_data_t" in very confusing ways. I believe the newer names are much clearer. These macros can be overridden in the sparsemem case with a theoretically slower operation using node_start_pfn and pfn_to_page(), instead. We could make this the only behavior if people want, but I don't want to change too much at once. One thing at a time. This patch removes more code than it adds. Compile tested on alpha, alpha discontig, arm, arm-discontig, i386, i386 generic, NUMAQ, Summit, ppc64, ppc64 discontig, and x86_64. Full list here: http://sr71.net/patches/2.6.12/2.6.12-rc1-mhp2/configs/ Boot tested on NUMAQ, x86 SMP and ppc64 power4/5 LPARs. Signed-off-by: Dave Hansen <haveblue@us.ibm.com> Signed-off-by: Martin J. Bligh <mbligh@aracnet.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
29c31a3bf2
commit
408fde81c1
14 changed files with 28 additions and 36 deletions
|
@ -327,8 +327,6 @@ void __init mem_init(void)
|
|||
extern char _text, _etext, _data, _edata;
|
||||
extern char __init_begin, __init_end;
|
||||
unsigned long nid, i;
|
||||
struct page * lmem_map;
|
||||
|
||||
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
|
||||
|
||||
reservedpages = 0;
|
||||
|
@ -338,10 +336,10 @@ void __init mem_init(void)
|
|||
*/
|
||||
totalram_pages += free_all_bootmem_node(NODE_DATA(nid));
|
||||
|
||||
lmem_map = node_mem_map(nid);
|
||||
pfn = NODE_DATA(nid)->node_start_pfn;
|
||||
for (i = 0; i < node_spanned_pages(nid); i++, pfn++)
|
||||
if (page_is_ram(pfn) && PageReserved(lmem_map+i))
|
||||
if (page_is_ram(pfn) &&
|
||||
PageReserved(nid_page_nr(nid, i)))
|
||||
reservedpages++;
|
||||
}
|
||||
|
||||
|
@ -373,18 +371,18 @@ show_mem(void)
|
|||
show_free_areas();
|
||||
printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
|
||||
for_each_online_node(nid) {
|
||||
struct page * lmem_map = node_mem_map(nid);
|
||||
i = node_spanned_pages(nid);
|
||||
while (i-- > 0) {
|
||||
struct page *page = nid_page_nr(nid, i);
|
||||
total++;
|
||||
if (PageReserved(lmem_map+i))
|
||||
if (PageReserved(page))
|
||||
reserved++;
|
||||
else if (PageSwapCache(lmem_map+i))
|
||||
else if (PageSwapCache(page))
|
||||
cached++;
|
||||
else if (!page_count(lmem_map+i))
|
||||
else if (!page_count(page))
|
||||
free++;
|
||||
else
|
||||
shared += page_count(lmem_map + i) - 1;
|
||||
shared += page_count(page) - 1;
|
||||
}
|
||||
}
|
||||
printk("%ld pages of RAM\n",total);
|
||||
|
|
|
@ -36,7 +36,7 @@ void show_mem(void)
|
|||
printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
|
||||
for_each_pgdat(pgdat) {
|
||||
for (i = 0; i < pgdat->node_spanned_pages; ++i) {
|
||||
page = pgdat->node_mem_map + i;
|
||||
page = pgdat_page_nr(pgdat, i);
|
||||
total++;
|
||||
if (PageHighMem(page))
|
||||
highmem++;
|
||||
|
|
|
@ -560,14 +560,15 @@ void show_mem(void)
|
|||
int shared = 0, cached = 0, reserved = 0;
|
||||
printk("Node ID: %d\n", pgdat->node_id);
|
||||
for(i = 0; i < pgdat->node_spanned_pages; i++) {
|
||||
struct page *page = pgdat_page_nr(pgdat, i);
|
||||
if (!ia64_pfn_valid(pgdat->node_start_pfn+i))
|
||||
continue;
|
||||
if (PageReserved(pgdat->node_mem_map+i))
|
||||
if (PageReserved(page))
|
||||
reserved++;
|
||||
else if (PageSwapCache(pgdat->node_mem_map+i))
|
||||
else if (PageSwapCache(page))
|
||||
cached++;
|
||||
else if (page_count(pgdat->node_mem_map+i))
|
||||
shared += page_count(pgdat->node_mem_map+i)-1;
|
||||
else if (page_count(page))
|
||||
shared += page_count(page)-1;
|
||||
}
|
||||
total_present += present;
|
||||
total_reserved += reserved;
|
||||
|
|
|
@ -49,7 +49,7 @@ void show_mem(void)
|
|||
printk("Free swap: %6ldkB\n",nr_swap_pages<<(PAGE_SHIFT-10));
|
||||
for_each_pgdat(pgdat) {
|
||||
for (i = 0; i < pgdat->node_spanned_pages; ++i) {
|
||||
page = pgdat->node_mem_map + i;
|
||||
page = pgdat_page_nr(pgdat, i);
|
||||
total++;
|
||||
if (PageHighMem(page))
|
||||
highmem++;
|
||||
|
@ -152,7 +152,7 @@ int __init reservedpages_count(void)
|
|||
reservedpages = 0;
|
||||
for_each_online_node(nid)
|
||||
for (i = 0 ; i < MAX_LOW_PFN(nid) - START_PFN(nid) ; i++)
|
||||
if (PageReserved(NODE_DATA(nid)->node_mem_map + i))
|
||||
if (PageReserved(nid_page_nr(nid, i)))
|
||||
reservedpages++;
|
||||
|
||||
return reservedpages;
|
||||
|
|
|
@ -549,9 +549,8 @@ void __init mem_init(void)
|
|||
*/
|
||||
numslots = node_getlastslot(node);
|
||||
for (slot = 1; slot <= numslots; slot++) {
|
||||
p = NODE_DATA(node)->node_mem_map +
|
||||
(slot_getbasepfn(node, slot) -
|
||||
slot_getbasepfn(node, 0));
|
||||
p = nid_page_nr(node, slot_getbasepfn(node, slot) -
|
||||
slot_getbasepfn(node, 0));
|
||||
|
||||
/*
|
||||
* Free valid memory in current slot.
|
||||
|
|
|
@ -506,7 +506,7 @@ void show_mem(void)
|
|||
for (j = node_start_pfn(i); j < node_end_pfn(i); j++) {
|
||||
struct page *p;
|
||||
|
||||
p = node_mem_map(i) + j - node_start_pfn(i);
|
||||
p = nid_page_nr(i, j) - node_start_pfn(i);
|
||||
|
||||
total++;
|
||||
if (PageReserved(p))
|
||||
|
|
|
@ -98,7 +98,7 @@ void show_mem(void)
|
|||
printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
|
||||
for_each_pgdat(pgdat) {
|
||||
for (i = 0; i < pgdat->node_spanned_pages; i++) {
|
||||
page = pgdat->node_mem_map + i;
|
||||
page = pgdat_page_nr(pgdat, i);
|
||||
total++;
|
||||
if (PageReserved(page))
|
||||
reserved++;
|
||||
|
@ -654,7 +654,7 @@ void __init mem_init(void)
|
|||
|
||||
for_each_pgdat(pgdat) {
|
||||
for (i = 0; i < pgdat->node_spanned_pages; i++) {
|
||||
page = pgdat->node_mem_map + i;
|
||||
page = pgdat_page_nr(pgdat, i);
|
||||
if (PageReserved(page))
|
||||
reservedpages++;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)
|
|||
* Given a kernel address, find the home node of the underlying memory.
|
||||
*/
|
||||
#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
|
||||
#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
|
||||
#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
|
||||
|
||||
#define local_mapnr(kvaddr) \
|
||||
|
@ -108,7 +107,7 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)
|
|||
#define pfn_to_page(pfn) \
|
||||
({ \
|
||||
unsigned long kaddr = (unsigned long)__va((pfn) << PAGE_SHIFT); \
|
||||
(node_mem_map(kvaddr_to_nid(kaddr)) + local_mapnr(kaddr)); \
|
||||
(NODE_DATA(kvaddr_to_nid(kaddr))->node_mem_map + local_mapnr(kaddr)); \
|
||||
})
|
||||
|
||||
#define page_to_pfn(page) \
|
||||
|
|
|
@ -79,7 +79,6 @@ static inline int pfn_to_nid(unsigned long pfn)
|
|||
*/
|
||||
#define kvaddr_to_nid(kaddr) pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT)
|
||||
|
||||
#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
|
||||
#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
|
||||
#define node_end_pfn(nid) \
|
||||
({ \
|
||||
|
@ -100,7 +99,7 @@ static inline int pfn_to_nid(unsigned long pfn)
|
|||
({ \
|
||||
unsigned long __pfn = pfn; \
|
||||
int __node = pfn_to_nid(__pfn); \
|
||||
&node_mem_map(__node)[node_localnr(__pfn,__node)]; \
|
||||
&NODE_DATA(__node)->node_mem_map[node_localnr(__pfn,__node)]; \
|
||||
})
|
||||
|
||||
#define page_to_pfn(pg) \
|
||||
|
|
|
@ -14,7 +14,6 @@ extern struct pglist_data *node_data[];
|
|||
#define NODE_DATA(nid) (node_data[nid])
|
||||
|
||||
#define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
|
||||
#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
|
||||
#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
|
||||
#define node_end_pfn(nid) \
|
||||
({ \
|
||||
|
@ -32,7 +31,7 @@ extern struct pglist_data *node_data[];
|
|||
({ \
|
||||
unsigned long __pfn = pfn; \
|
||||
int __node = pfn_to_nid(__pfn); \
|
||||
&node_mem_map(__node)[node_localnr(__pfn,__node)]; \
|
||||
&NODE_DATA(__node)->node_mem_map[node_localnr(__pfn,__node)]; \
|
||||
})
|
||||
|
||||
#define page_to_pfn(pg) \
|
||||
|
|
|
@ -19,7 +19,6 @@ extern struct node_map_data node_data[];
|
|||
*/
|
||||
#define kvaddr_to_nid(kaddr) pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT)
|
||||
|
||||
#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
|
||||
#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
|
||||
#define node_end_pfn(nid) \
|
||||
({ \
|
||||
|
@ -38,7 +37,7 @@ extern struct node_map_data node_data[];
|
|||
({ \
|
||||
unsigned long __pfn = (pfn); \
|
||||
int __node = pfn_to_nid(__pfn); \
|
||||
&node_mem_map(__node)[node_localnr(__pfn,__node)]; \
|
||||
&NODE_DATA(__node)->node_mem_map[node_localnr(__pfn,__node)]; \
|
||||
})
|
||||
|
||||
#define page_to_pfn(pg) \
|
||||
|
|
|
@ -65,7 +65,6 @@ static inline int pa_to_nid(unsigned long pa)
|
|||
*/
|
||||
#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
|
||||
|
||||
#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
|
||||
#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
|
||||
#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
|
||||
|
||||
|
@ -76,7 +75,7 @@ static inline int pa_to_nid(unsigned long pa)
|
|||
#define discontigmem_pfn_to_page(pfn) \
|
||||
({ \
|
||||
unsigned long __tmp = pfn; \
|
||||
(node_mem_map(pfn_to_nid(__tmp)) + \
|
||||
(NODE_DATA(pfn_to_nid(__tmp))->node_mem_map + \
|
||||
node_localnr(__tmp, pfn_to_nid(__tmp))); \
|
||||
})
|
||||
|
||||
|
|
|
@ -35,9 +35,6 @@ static inline __attribute__((pure)) int phys_to_nid(unsigned long addr)
|
|||
#define kvaddr_to_nid(kaddr) phys_to_nid(__pa(kaddr))
|
||||
#define NODE_DATA(nid) (node_data[nid])
|
||||
|
||||
#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
|
||||
|
||||
#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
|
||||
#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
|
||||
#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
|
||||
NODE_DATA(nid)->node_spanned_pages)
|
||||
|
@ -50,7 +47,7 @@ static inline __attribute__((pure)) int phys_to_nid(unsigned long addr)
|
|||
(2.4 used to). */
|
||||
#define pfn_to_page(pfn) ({ \
|
||||
int nid = phys_to_nid(((unsigned long)(pfn)) << PAGE_SHIFT); \
|
||||
((pfn) - node_start_pfn(nid)) + node_mem_map(nid); \
|
||||
((pfn) - node_start_pfn(nid)) + NODE_DATA(nid)->node_mem_map; \
|
||||
})
|
||||
|
||||
#define page_to_pfn(page) \
|
||||
|
|
|
@ -284,6 +284,8 @@ typedef struct pglist_data {
|
|||
|
||||
#define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages)
|
||||
#define node_spanned_pages(nid) (NODE_DATA(nid)->node_spanned_pages)
|
||||
#define pgdat_page_nr(pgdat, pagenr) ((pgdat)->node_mem_map + (pagenr))
|
||||
#define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr))
|
||||
|
||||
extern struct pglist_data *pgdat_list;
|
||||
|
||||
|
|
Loading…
Reference in a new issue