diff options
author | Christoph Lameter <clameter@sgi.com> | 2006-09-26 02:31:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-26 11:48:46 -0400 |
commit | e53ef38d05dd59ed281a35590e4a5b64d8ff4c52 (patch) | |
tree | 42e525df84454e89abd6cab8d7983a6a0188b6bb | |
parent | fb0e7942bdcbbd2f90e61cb4cfa4fa892a873f8a (diff) |
[PATCH] reduce MAX_NR_ZONES: make ZONE_HIGHMEM optional
Make ZONE_HIGHMEM optional
- ifdef out code and definitions related to CONFIG_HIGHMEM
- __GFP_HIGHMEM falls back to normal allocations if there is no
ZONE_HIGHMEM
- GFP_ZONEMASK becomes 0x01 if there is no DMA32 and no HIGHMEM
zone.
[jdike@addtoit.com: build fix]
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Christoph Lameter <clameter@engr.sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/um/kernel/mem.c | 2 | ||||
-rw-r--r-- | include/linux/gfp.h | 18 | ||||
-rw-r--r-- | include/linux/mmzone.h | 36 | ||||
-rw-r--r-- | mm/page_alloc.c | 6 |
4 files changed, 51 insertions, 11 deletions
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index b39e624c3291..b1cd5c6e468b 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c | |||
@@ -226,7 +226,9 @@ void paging_init(void) | |||
226 | for(i=0;i<sizeof(zones_size)/sizeof(zones_size[0]);i++) | 226 | for(i=0;i<sizeof(zones_size)/sizeof(zones_size[0]);i++) |
227 | zones_size[i] = 0; | 227 | zones_size[i] = 0; |
228 | zones_size[ZONE_DMA] = (end_iomem >> PAGE_SHIFT) - (uml_physmem >> PAGE_SHIFT); | 228 | zones_size[ZONE_DMA] = (end_iomem >> PAGE_SHIFT) - (uml_physmem >> PAGE_SHIFT); |
229 | #ifdef CONFIG_HIGHMEM | ||
229 | zones_size[ZONE_HIGHMEM] = highmem >> PAGE_SHIFT; | 230 | zones_size[ZONE_HIGHMEM] = highmem >> PAGE_SHIFT; |
231 | #endif | ||
230 | free_area_init(zones_size); | 232 | free_area_init(zones_size); |
231 | 233 | ||
232 | /* | 234 | /* |
diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 14610b56c132..2a2153ebfe0b 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h | |||
@@ -9,17 +9,19 @@ struct vm_area_struct; | |||
9 | 9 | ||
10 | /* | 10 | /* |
11 | * GFP bitmasks.. | 11 | * GFP bitmasks.. |
12 | * | ||
13 | * Zone modifiers (see linux/mmzone.h - low three bits) | ||
14 | * | ||
15 | * These may be masked by GFP_ZONEMASK to make allocations with this bit | ||
16 | * set fall back to ZONE_NORMAL. | ||
17 | * | ||
18 | * Do not put any conditional on these. If necessary modify the definitions | ||
19 | * without the underscores and use the consistently. The definitions here may | ||
20 | * be used in bit comparisons. | ||
12 | */ | 21 | */ |
13 | /* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low three bits) */ | ||
14 | #define __GFP_DMA ((__force gfp_t)0x01u) | 22 | #define __GFP_DMA ((__force gfp_t)0x01u) |
15 | #define __GFP_HIGHMEM ((__force gfp_t)0x02u) | 23 | #define __GFP_HIGHMEM ((__force gfp_t)0x02u) |
16 | #ifndef CONFIG_ZONE_DMA32 | 24 | #define __GFP_DMA32 ((__force gfp_t)0x04u) |
17 | #define __GFP_DMA32 ((__force gfp_t)0x01) /* ZONE_DMA is ZONE_DMA32 */ | ||
18 | #elif BITS_PER_LONG < 64 | ||
19 | #define __GFP_DMA32 ((__force gfp_t)0x00) /* ZONE_NORMAL is ZONE_DMA32 */ | ||
20 | #else | ||
21 | #define __GFP_DMA32 ((__force gfp_t)0x04) /* Has own ZONE_DMA32 */ | ||
22 | #endif | ||
23 | 25 | ||
24 | /* | 26 | /* |
25 | * Action modifiers - doesn't change the zoning | 27 | * Action modifiers - doesn't change the zoning |
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index adae3c915938..76d33e688593 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
@@ -123,6 +123,7 @@ enum zone_type { | |||
123 | * transfers to all addressable memory. | 123 | * transfers to all addressable memory. |
124 | */ | 124 | */ |
125 | ZONE_NORMAL, | 125 | ZONE_NORMAL, |
126 | #ifdef CONFIG_HIGHMEM | ||
126 | /* | 127 | /* |
127 | * A memory area that is only addressable by the kernel through | 128 | * A memory area that is only addressable by the kernel through |
128 | * mapping portions into its own address space. This is for example | 129 | * mapping portions into its own address space. This is for example |
@@ -132,11 +133,10 @@ enum zone_type { | |||
132 | * access. | 133 | * access. |
133 | */ | 134 | */ |
134 | ZONE_HIGHMEM, | 135 | ZONE_HIGHMEM, |
135 | 136 | #endif | |
136 | MAX_NR_ZONES | 137 | MAX_NR_ZONES |
137 | }; | 138 | }; |
138 | 139 | ||
139 | #define ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */ | ||
140 | 140 | ||
141 | /* | 141 | /* |
142 | * When a memory allocation must conform to specific limitations (such | 142 | * When a memory allocation must conform to specific limitations (such |
@@ -163,12 +163,34 @@ enum zone_type { | |||
163 | * | 163 | * |
164 | * NOTE! Make sure this matches the zones in <linux/gfp.h> | 164 | * NOTE! Make sure this matches the zones in <linux/gfp.h> |
165 | */ | 165 | */ |
166 | #define GFP_ZONETYPES ((GFP_ZONEMASK + 1) / 2 + 1) /* Loner */ | ||
167 | 166 | ||
168 | #ifdef CONFIG_ZONE_DMA32 | 167 | #ifdef CONFIG_ZONE_DMA32 |
168 | |||
169 | #ifdef CONFIG_HIGHMEM | ||
170 | #define GFP_ZONETYPES ((GFP_ZONEMASK + 1) / 2 + 1) /* Loner */ | ||
169 | #define GFP_ZONEMASK 0x07 | 171 | #define GFP_ZONEMASK 0x07 |
172 | #define ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */ | ||
170 | #else | 173 | #else |
174 | #define GFP_ZONETYPES ((0x07 + 1) / 2 + 1) /* Loner */ | ||
175 | /* Mask __GFP_HIGHMEM */ | ||
176 | #define GFP_ZONEMASK 0x05 | ||
177 | #define ZONES_SHIFT 2 | ||
178 | #endif | ||
179 | |||
180 | #else | ||
181 | #ifdef CONFIG_HIGHMEM | ||
182 | |||
171 | #define GFP_ZONEMASK 0x03 | 183 | #define GFP_ZONEMASK 0x03 |
184 | #define ZONES_SHIFT 2 | ||
185 | #define GFP_ZONETYPES 3 | ||
186 | |||
187 | #else | ||
188 | |||
189 | #define GFP_ZONEMASK 0x01 | ||
190 | #define ZONES_SHIFT 1 | ||
191 | #define GFP_ZONETYPES 2 | ||
192 | |||
193 | #endif | ||
172 | #endif | 194 | #endif |
173 | 195 | ||
174 | struct zone { | 196 | struct zone { |
@@ -409,7 +431,11 @@ static inline int populated_zone(struct zone *zone) | |||
409 | 431 | ||
410 | static inline int is_highmem_idx(enum zone_type idx) | 432 | static inline int is_highmem_idx(enum zone_type idx) |
411 | { | 433 | { |
434 | #ifdef CONFIG_HIGHMEM | ||
412 | return (idx == ZONE_HIGHMEM); | 435 | return (idx == ZONE_HIGHMEM); |
436 | #else | ||
437 | return 0; | ||
438 | #endif | ||
413 | } | 439 | } |
414 | 440 | ||
415 | static inline int is_normal_idx(enum zone_type idx) | 441 | static inline int is_normal_idx(enum zone_type idx) |
@@ -425,7 +451,11 @@ static inline int is_normal_idx(enum zone_type idx) | |||
425 | */ | 451 | */ |
426 | static inline int is_highmem(struct zone *zone) | 452 | static inline int is_highmem(struct zone *zone) |
427 | { | 453 | { |
454 | #ifdef CONFIG_HIGHMEM | ||
428 | return zone == zone->zone_pgdat->node_zones + ZONE_HIGHMEM; | 455 | return zone == zone->zone_pgdat->node_zones + ZONE_HIGHMEM; |
456 | #else | ||
457 | return 0; | ||
458 | #endif | ||
429 | } | 459 | } |
430 | 460 | ||
431 | static inline int is_normal(struct zone *zone) | 461 | static inline int is_normal(struct zone *zone) |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 5b5cbb5e1816..6c7c2dd1b3ed 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -73,7 +73,9 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = { | |||
73 | #ifdef CONFIG_ZONE_DMA32 | 73 | #ifdef CONFIG_ZONE_DMA32 |
74 | 256, | 74 | 256, |
75 | #endif | 75 | #endif |
76 | #ifdef CONFIG_HIGHMEM | ||
76 | 32 | 77 | 32 |
78 | #endif | ||
77 | }; | 79 | }; |
78 | 80 | ||
79 | EXPORT_SYMBOL(totalram_pages); | 81 | EXPORT_SYMBOL(totalram_pages); |
@@ -91,7 +93,9 @@ static char *zone_names[MAX_NR_ZONES] = { | |||
91 | "DMA32", | 93 | "DMA32", |
92 | #endif | 94 | #endif |
93 | "Normal", | 95 | "Normal", |
96 | #ifdef CONFIG_HIGHMEM | ||
94 | "HighMem" | 97 | "HighMem" |
98 | #endif | ||
95 | }; | 99 | }; |
96 | 100 | ||
97 | int min_free_kbytes = 1024; | 101 | int min_free_kbytes = 1024; |
@@ -1375,8 +1379,10 @@ static int __meminit build_zonelists_node(pg_data_t *pgdat, | |||
1375 | static inline int highest_zone(int zone_bits) | 1379 | static inline int highest_zone(int zone_bits) |
1376 | { | 1380 | { |
1377 | int res = ZONE_NORMAL; | 1381 | int res = ZONE_NORMAL; |
1382 | #ifdef CONFIG_HIGHMEM | ||
1378 | if (zone_bits & (__force int)__GFP_HIGHMEM) | 1383 | if (zone_bits & (__force int)__GFP_HIGHMEM) |
1379 | res = ZONE_HIGHMEM; | 1384 | res = ZONE_HIGHMEM; |
1385 | #endif | ||
1380 | #ifdef CONFIG_ZONE_DMA32 | 1386 | #ifdef CONFIG_ZONE_DMA32 |
1381 | if (zone_bits & (__force int)__GFP_DMA32) | 1387 | if (zone_bits & (__force int)__GFP_DMA32) |
1382 | res = ZONE_DMA32; | 1388 | res = ZONE_DMA32; |