Skip to content

Commit 9796547

Browse files
Christoph Lametertorvalds
authored andcommitted
mm: Get rid of __ZONE_COUNT
It was used to compensate because MAX_NR_ZONES was not available to the #ifdefs. Export MAX_NR_ZONES via the new mechanism and get rid of __ZONE_COUNT. Signed-off-by: Christoph Lameter <clameter@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ec7cade commit 9796547

2 files changed

Lines changed: 13 additions & 17 deletions

File tree

‎include/linux/mmzone.h‎

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#ifdef __KERNEL__
55
#ifndef __ASSEMBLY__
6+
#ifndef __GENERATING_BOUNDS_H
67

78
#include <linux/spinlock.h>
89
#include <linux/list.h>
@@ -15,6 +16,7 @@
1516
#include <linux/seqlock.h>
1617
#include <linux/nodemask.h>
1718
#include <linux/pageblock-flags.h>
19+
#include <linux/bounds.h>
1820
#include <asm/atomic.h>
1921
#include <asm/page.h>
2022

@@ -129,6 +131,8 @@ struct per_cpu_pageset {
129131
#define zone_pcp(__z, __cpu) (&(__z)->pageset[(__cpu)])
130132
#endif
131133

134+
#endif /* !__GENERATING_BOUNDS.H */
135+
132136
enum zone_type {
133137
#ifdef CONFIG_ZONE_DMA
134138
/*
@@ -177,9 +181,11 @@ enum zone_type {
177181
ZONE_HIGHMEM,
178182
#endif
179183
ZONE_MOVABLE,
180-
MAX_NR_ZONES
184+
__MAX_NR_ZONES
181185
};
182186

187+
#ifndef __GENERATING_BOUNDS_H
188+
183189
/*
184190
* When a memory allocation must conform to specific limitations (such
185191
* as being suitable for DMA) the caller will pass in hints to the
@@ -188,28 +194,15 @@ enum zone_type {
188194
* match the requested limits. See gfp_zone() in include/linux/gfp.h
189195
*/
190196

191-
/*
192-
* Count the active zones. Note that the use of defined(X) outside
193-
* #if and family is not necessarily defined so ensure we cannot use
194-
* it later. Use __ZONE_COUNT to work out how many shift bits we need.
195-
*/
196-
#define __ZONE_COUNT ( \
197-
defined(CONFIG_ZONE_DMA) \
198-
+ defined(CONFIG_ZONE_DMA32) \
199-
+ 1 \
200-
+ defined(CONFIG_HIGHMEM) \
201-
+ 1 \
202-
)
203-
#if __ZONE_COUNT < 2
197+
#if MAX_NR_ZONES < 2
204198
#define ZONES_SHIFT 0
205-
#elif __ZONE_COUNT <= 2
199+
#elif MAX_NR_ZONES <= 2
206200
#define ZONES_SHIFT 1
207-
#elif __ZONE_COUNT <= 4
201+
#elif MAX_NR_ZONES <= 4
208202
#define ZONES_SHIFT 2
209203
#else
210204
#error ZONES_SHIFT -- too many zones configured adjust calculation
211205
#endif
212-
#undef __ZONE_COUNT
213206

214207
struct zone {
215208
/* Fields commonly accessed by the page allocator */
@@ -1008,6 +1001,7 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
10081001
#define pfn_valid_within(pfn) (1)
10091002
#endif
10101003

1004+
#endif /* !__GENERATING_BOUNDS.H */
10111005
#endif /* !__ASSEMBLY__ */
10121006
#endif /* __KERNEL__ */
10131007
#endif /* _LINUX_MMZONE_H */

‎kernel/bounds.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define __GENERATING_BOUNDS_H
88
/* Include headers that define the enum constants of interest */
99
#include <linux/page-flags.h>
10+
#include <linux/mmzone.h>
1011

1112
#define DEFINE(sym, val) \
1213
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
@@ -17,5 +18,6 @@ void foo(void)
1718
{
1819
/* The enum constants to put into include/linux/bounds.h */
1920
DEFINE(NR_PAGEFLAGS, __NR_PAGEFLAGS);
21+
DEFINE(MAX_NR_ZONES, __MAX_NR_ZONES);
2022
/* End of constants */
2123
}

0 commit comments

Comments
 (0)