History

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.

KAMEZAWA Hiroyuki committed 15 years ago

Commit c6830c21 parent af4087e10 files · +8 −53Browse files

Unified · Split

10 files
  1. arch/alpha/include/asm/mmzone.h +0 −1
  2. arch/m32r/include/asm/mmzone.h +1 −7
  3. arch/parisc/include/asm/mmzone.h +0 −7
  4. arch/powerpc/include/asm/mmzone.h +0 −7
  5. arch/sh/include/asm/mmzone.h +0 −4
  6. arch/sparc/include/asm/mmzone.h +0 −2
  7. arch/tile/include/asm/mmzone.h +0 −11
  8. arch/x86/include/asm/mmzone_32.h +0 −11
  9. arch/x86/include/asm/mmzone_64.h +0 −3
  10. include/linux/mmzone.h +7 −0
arch/alpha/include/asm/mmzone.h+0−1
@@ -56,7 +56,6 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n) · 55 unmodified lines
56 * Given a kernel address, find the home node of the underlying memory.56 * Given a kernel address, find the home node of the underlying memory.
57 */57 */
58#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))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 * Given a kaddr, LOCAL_BASE_ADDR finds the owning node of the memory61 * Given a kaddr, LOCAL_BASE_ADDR finds the owning node of the memory
arch/m32r/include/asm/mmzone.h+1−7
@@ -14,12 +14,6 @@ extern struct pglist_data *node_data[]; · 13 unmodified lines
14#define NODE_DATA(nid) (node_data[nid])14#define NODE_DATA(nid) (node_data[nid])
15 15
16#define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)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#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))18#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
25/*19/*
@@ -44,7 +38,7 @@ static __inline__ int pfn_to_nid(unsigned long pfn) · 18 unmodified lines
44 int node;38 int node;
45 39
46 for (node = 0 ; node < MAX_NUMNODES ; node++)40 for (node = 0 ; node < MAX_NUMNODES ; node++)
47 if (pfn >= node_start_pfn(node) && pfn <= node_end_pfn(node))41 if (pfn >= node_start_pfn(node) && pfn < node_end_pfn(node))
48 break;42 break;
49 43
50 return node;44 return node;
arch/parisc/include/asm/mmzone.h+0−7
@@ -14,13 +14,6 @@ extern struct node_map_data node_data[]; · 13 unmodified lines
14 14
15#define NODE_DATA(nid) (&node_data[nid].pg_data)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/* We have these possible memory map layouts:17/* We have these possible memory map layouts:
25 * Astro: 0-3.75, 67.75-68, 4-6418 * Astro: 0-3.75, 67.75-68, 4-64
26 * zx1: 0-1, 257-260, 4-25619 * zx1: 0-1, 257-260, 4-256
arch/powerpc/include/asm/mmzone.h+0−7
@@ -38,13 +38,6 @@ u64 memory_hotplug_max(void); · 37 unmodified lines
38#define memory_hotplug_max() memblock_end_of_DRAM()38#define memory_hotplug_max() memblock_end_of_DRAM()
39#endif39#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#else41#else
49#define memory_hotplug_max() memblock_end_of_DRAM()42#define memory_hotplug_max() memblock_end_of_DRAM()
50#endif /* CONFIG_NEED_MULTIPLE_NODES */43#endif /* CONFIG_NEED_MULTIPLE_NODES */
arch/sh/include/asm/mmzone.h+0−4
@@ -9,10 +9,6 @@ · 8 unmodified lines
9extern struct pglist_data *node_data[];9extern struct pglist_data *node_data[];
10#define NODE_DATA(nid) (node_data[nid])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
16static inline int pfn_to_nid(unsigned long pfn)12static inline int pfn_to_nid(unsigned long pfn)
17{13{
18 int nid;14 int nid;
arch/sparc/include/asm/mmzone.h+0−2
@@ -8,8 +8,6 @@ · 7 unmodified lines
8extern struct pglist_data *node_data[];8extern struct pglist_data *node_data[];
9 9
10#define NODE_DATA(nid) (node_data[nid])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
14extern int numa_cpu_lookup_table[];12extern int numa_cpu_lookup_table[];
15extern cpumask_t numa_cpumask_lookup_table[];13extern cpumask_t numa_cpumask_lookup_table[];
arch/tile/include/asm/mmzone.h+0−11
@@ -40,17 +40,6 @@ static inline int pfn_to_nid(unsigned long pfn) · 39 unmodified lines
40 return highbits_to_node[__pfn_to_highbits(pfn)];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#define kern_addr_valid(kaddr) virt_addr_valid((void *)kaddr)43#define kern_addr_valid(kaddr) virt_addr_valid((void *)kaddr)
55 44
56static inline int pfn_valid(int pfn)45static inline int pfn_valid(int pfn)
arch/x86/include/asm/mmzone_32.h+0−11
@@ -48,17 +48,6 @@ static inline int pfn_to_nid(unsigned long pfn) · 47 unmodified lines
48#endif48#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
62static inline int pfn_valid(int pfn)51static inline int pfn_valid(int pfn)
63{52{
64 int nid = pfn_to_nid(pfn);53 int nid = pfn_to_nid(pfn);
arch/x86/include/asm/mmzone_64.h+0−3
@@ -13,8 +13,5 @@ extern struct pglist_data *node_data[]; · 12 unmodified lines
13 13
14#define NODE_DATA(nid) (node_data[nid])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#endif16#endif
20#endif /* _ASM_X86_MMZONE_64_H */17#endif /* _ASM_X86_MMZONE_64_H */
include/linux/mmzone.h+7−0
@@ -647,6 +647,13 @@ typedef struct pglist_data { · 646 unmodified lines
647#endif647#endif
648#define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr))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#include <linux/memory_hotplug.h>657#include <linux/memory_hotplug.h>
651 658
652extern struct mutex zonelists_mutex;659extern struct mutex zonelists_mutex;