Skip to content

Commit c6830c2

Browse files
hkamezawatorvalds
authored andcommitted
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>
1 parent af4087e commit c6830c2

10 files changed

Lines changed: 8 additions & 53 deletions

File tree

‎arch/alpha/include/asm/mmzone.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)
5656
* Given a kernel address, find the home node of the underlying memory.
5757
*/
5858
#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
59-
#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
6059

6160
/*
6261
* Given a kaddr, LOCAL_BASE_ADDR finds the owning node of the memory

‎arch/m32r/include/asm/mmzone.h‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ extern struct pglist_data *node_data[];
1414
#define NODE_DATA(nid) (node_data[nid])
1515

1616
#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-
})
2317

2418
#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
2519
/*
@@ -44,7 +38,7 @@ static __inline__ int pfn_to_nid(unsigned long pfn)
4438
int node;
4539

4640
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))
4842
break;
4943

5044
return node;

‎arch/parisc/include/asm/mmzone.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ extern struct node_map_data node_data[];
1414

1515
#define NODE_DATA(nid) (&node_data[nid].pg_data)
1616

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-
2417
/* We have these possible memory map layouts:
2518
* Astro: 0-3.75, 67.75-68, 4-64
2619
* zx1: 0-1, 257-260, 4-256

‎arch/powerpc/include/asm/mmzone.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ u64 memory_hotplug_max(void);
3838
#define memory_hotplug_max() memblock_end_of_DRAM()
3939
#endif
4040

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-
4841
#else
4942
#define memory_hotplug_max() memblock_end_of_DRAM()
5043
#endif /* CONFIG_NEED_MULTIPLE_NODES */

‎arch/sh/include/asm/mmzone.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
extern struct pglist_data *node_data[];
1010
#define NODE_DATA(nid) (node_data[nid])
1111

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-
1612
static inline int pfn_to_nid(unsigned long pfn)
1713
{
1814
int nid;

‎arch/sparc/include/asm/mmzone.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
extern struct pglist_data *node_data[];
99

1010
#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)
1311

1412
extern int numa_cpu_lookup_table[];
1513
extern cpumask_t numa_cpumask_lookup_table[];

‎arch/tile/include/asm/mmzone.h‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,6 @@ static inline int pfn_to_nid(unsigned long pfn)
4040
return highbits_to_node[__pfn_to_highbits(pfn)];
4141
}
4242

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-
5443
#define kern_addr_valid(kaddr) virt_addr_valid((void *)kaddr)
5544

5645
static inline int pfn_valid(int pfn)

‎arch/x86/include/asm/mmzone_32.h‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,6 @@ static inline int pfn_to_nid(unsigned long pfn)
4848
#endif
4949
}
5050

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-
6251
static inline int pfn_valid(int pfn)
6352
{
6453
int nid = pfn_to_nid(pfn);

‎arch/x86/include/asm/mmzone_64.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,5 @@ extern struct pglist_data *node_data[];
1313

1414
#define NODE_DATA(nid) (node_data[nid])
1515

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)
1916
#endif
2017
#endif /* _ASM_X86_MMZONE_64_H */

‎include/linux/mmzone.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,13 @@ typedef struct pglist_data {
647647
#endif
648648
#define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr))
649649

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+
650657
#include <linux/memory_hotplug.h>
651658

652659
extern struct mutex zonelists_mutex;

0 commit comments

Comments
 (0)