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.
Unified · Split
| @@ -56,7 +56,6 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n) · 55 unmodified lines | ||
| 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 |
| @@ -14,12 +14,6 @@ extern struct pglist_data *node_data[]; · 13 unmodified lines | ||
| 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 | /* |
| @@ -44,7 +38,7 @@ static __inline__ int pfn_to_nid(unsigned long pfn) · 18 unmodified lines | ||
| 44 | 38 | int node; |
| 45 | 39 | |
| 46 | 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 | 42 | break; |
| 49 | 43 | |
| 50 | 44 | return node; |
| @@ -14,13 +14,6 @@ extern struct node_map_data node_data[]; · 13 unmodified lines | ||
| 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 |
| @@ -38,13 +38,6 @@ u64 memory_hotplug_max(void); · 37 unmodified lines | ||
| 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 */ |
| @@ -9,10 +9,6 @@ · 8 unmodified lines | ||
| 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; |
| @@ -8,8 +8,6 @@ · 7 unmodified lines | ||
| 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[]; |
| @@ -40,17 +40,6 @@ static inline int pfn_to_nid(unsigned long pfn) · 39 unmodified lines | ||
| 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) |
| @@ -48,17 +48,6 @@ static inline int pfn_to_nid(unsigned long pfn) · 47 unmodified lines | ||
| 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); |
| @@ -13,8 +13,5 @@ extern struct pglist_data *node_data[]; · 12 unmodified lines | ||
| 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 */ |
| @@ -647,6 +647,13 @@ typedef struct pglist_data { · 646 unmodified lines | ||
| 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; |