Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Fix node_start/end_pfn() definition for mm/page_cgroup.c

commit 21a3c96 uses node_start/end_pfn(nid) for detection start/end
of nodes. But, it's not defined in linux/mmzone.h but defined in
/arch/???/include/mmzone.h which is included only under
CONFIG_NEED_MULTIPLE_NODES=y.

Then, we see
mm/page_cgroup.c: In function 'page_cgroup_init':
mm/page_cgroup.c:308: error: implicit declaration of function 'node_start_pfn'
mm/page_cgroup.c:309: error: implicit declaration of function 'node_end_pfn'

So, fixiing page_cgroup.c is an idea...

But node_start_pfn()/node_end_pfn() is a very generic macro and
should be implemented in the same manner for all archs.
(m32r has different implementation...)

This patch removes definitions of node_start/end_pfn() in each archs
and defines a unified one in linux/mmzone.h. It's not under
CONFIG_NEED_MULTIPLE_NODES, now.

A result of macro expansion is here (mm/page_cgroup.c)

for !NUMA
start_pfn = ((&contig_page_data)->node_start_pfn);
end_pfn = ({ pg_data_t *__pgdat = (&contig_page_data); __pgdat->node_start_pfn + __pgdat->node_spanned_pages;});

for NUMA (x86-64)
start_pfn = ((node_data[nid])->node_start_pfn);
end_pfn = ({ pg_data_t *__pgdat = (node_data[nid]); __pgdat->node_start_pfn + __pgdat->node_spanned_pages;});

Changelog:
- fixed to avoid using "nid" twice in node_end_pfn() macro.

Reported-and-acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Reported-and-tested-by: Ingo Molnar <mingo@elte.hu>
Acked-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

KAMEZAWA Hiroyuki and committed by
Linus Torvalds
c6830c22 af4087e0

+8 -53
-1
arch/alpha/include/asm/mmzone.h
··· 56 56 * Given a kernel address, find the home node of the underlying memory. 57 57 */ 58 58 #define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr)) 59 - #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 60 59 61 60 /* 62 61 * Given a kaddr, LOCAL_BASE_ADDR finds the owning node of the memory
+1 -7
arch/m32r/include/asm/mmzone.h
··· 14 14 #define NODE_DATA(nid) (node_data[nid]) 15 15 16 16 #define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn) 17 - #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 18 - #define node_end_pfn(nid) \ 19 - ({ \ 20 - pg_data_t *__pgdat = NODE_DATA(nid); \ 21 - __pgdat->node_start_pfn + __pgdat->node_spanned_pages - 1; \ 22 - }) 23 17 24 18 #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) 25 19 /* ··· 38 44 int node; 39 45 40 46 for (node = 0 ; node < MAX_NUMNODES ; node++) 41 - if (pfn >= node_start_pfn(node) && pfn <= node_end_pfn(node)) 47 + if (pfn >= node_start_pfn(node) && pfn < node_end_pfn(node)) 42 48 break; 43 49 44 50 return node;
-7
arch/parisc/include/asm/mmzone.h
··· 14 14 15 15 #define NODE_DATA(nid) (&node_data[nid].pg_data) 16 16 17 - #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 18 - #define node_end_pfn(nid) \ 19 - ({ \ 20 - pg_data_t *__pgdat = NODE_DATA(nid); \ 21 - __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \ 22 - }) 23 - 24 17 /* We have these possible memory map layouts: 25 18 * Astro: 0-3.75, 67.75-68, 4-64 26 19 * zx1: 0-1, 257-260, 4-256
-7
arch/powerpc/include/asm/mmzone.h
··· 38 38 #define memory_hotplug_max() memblock_end_of_DRAM() 39 39 #endif 40 40 41 - /* 42 - * Following are macros that each numa implmentation must define. 43 - */ 44 - 45 - #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 46 - #define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn) 47 - 48 41 #else 49 42 #define memory_hotplug_max() memblock_end_of_DRAM() 50 43 #endif /* CONFIG_NEED_MULTIPLE_NODES */
-4
arch/sh/include/asm/mmzone.h
··· 9 9 extern struct pglist_data *node_data[]; 10 10 #define NODE_DATA(nid) (node_data[nid]) 11 11 12 - #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 13 - #define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \ 14 - NODE_DATA(nid)->node_spanned_pages) 15 - 16 12 static inline int pfn_to_nid(unsigned long pfn) 17 13 { 18 14 int nid;
-2
arch/sparc/include/asm/mmzone.h
··· 8 8 extern struct pglist_data *node_data[]; 9 9 10 10 #define NODE_DATA(nid) (node_data[nid]) 11 - #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 12 - #define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn) 13 11 14 12 extern int numa_cpu_lookup_table[]; 15 13 extern cpumask_t numa_cpumask_lookup_table[];
-11
arch/tile/include/asm/mmzone.h
··· 40 40 return highbits_to_node[__pfn_to_highbits(pfn)]; 41 41 } 42 42 43 - /* 44 - * Following are macros that each numa implmentation must define. 45 - */ 46 - 47 - #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 48 - #define node_end_pfn(nid) \ 49 - ({ \ 50 - pg_data_t *__pgdat = NODE_DATA(nid); \ 51 - __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \ 52 - }) 53 - 54 43 #define kern_addr_valid(kaddr) virt_addr_valid((void *)kaddr) 55 44 56 45 static inline int pfn_valid(int pfn)
-11
arch/x86/include/asm/mmzone_32.h
··· 48 48 #endif 49 49 } 50 50 51 - /* 52 - * Following are macros that each numa implmentation must define. 53 - */ 54 - 55 - #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 56 - #define node_end_pfn(nid) \ 57 - ({ \ 58 - pg_data_t *__pgdat = NODE_DATA(nid); \ 59 - __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \ 60 - }) 61 - 62 51 static inline int pfn_valid(int pfn) 63 52 { 64 53 int nid = pfn_to_nid(pfn);
-3
arch/x86/include/asm/mmzone_64.h
··· 13 13 14 14 #define NODE_DATA(nid) (node_data[nid]) 15 15 16 - #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 17 - #define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \ 18 - NODE_DATA(nid)->node_spanned_pages) 19 16 #endif 20 17 #endif /* _ASM_X86_MMZONE_64_H */
+7
include/linux/mmzone.h
··· 647 647 #endif 648 648 #define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr)) 649 649 650 + #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 651 + 652 + #define node_end_pfn(nid) ({\ 653 + pg_data_t *__pgdat = NODE_DATA(nid);\ 654 + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\ 655 + }) 656 + 650 657 #include <linux/memory_hotplug.h> 651 658 652 659 extern struct mutex zonelists_mutex;