aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/gfp.h2
-rw-r--r--include/linux/mmzone.h26
-rw-r--r--include/linux/slab_def.h30
-rw-r--r--include/linux/vmstat.h17
4 files changed, 60 insertions, 15 deletions
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 063799ea6be0..2a7d15bcde46 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -85,8 +85,10 @@ struct vm_area_struct;
85 85
86static inline enum zone_type gfp_zone(gfp_t flags) 86static inline enum zone_type gfp_zone(gfp_t flags)
87{ 87{
88#ifdef CONFIG_ZONE_DMA
88 if (flags & __GFP_DMA) 89 if (flags & __GFP_DMA)
89 return ZONE_DMA; 90 return ZONE_DMA;
91#endif
90#ifdef CONFIG_ZONE_DMA32 92#ifdef CONFIG_ZONE_DMA32
91 if (flags & __GFP_DMA32) 93 if (flags & __GFP_DMA32)
92 return ZONE_DMA32; 94 return ZONE_DMA32;
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 398f2ec55f54..ee9e3143df4f 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -96,6 +96,7 @@ struct per_cpu_pageset {
96#endif 96#endif
97 97
98enum zone_type { 98enum zone_type {
99#ifdef CONFIG_ZONE_DMA
99 /* 100 /*
100 * ZONE_DMA is used when there are devices that are not able 101 * ZONE_DMA is used when there are devices that are not able
101 * to do DMA to all of addressable memory (ZONE_NORMAL). Then we 102 * to do DMA to all of addressable memory (ZONE_NORMAL). Then we
@@ -116,6 +117,7 @@ enum zone_type {
116 * <16M. 117 * <16M.
117 */ 118 */
118 ZONE_DMA, 119 ZONE_DMA,
120#endif
119#ifdef CONFIG_ZONE_DMA32 121#ifdef CONFIG_ZONE_DMA32
120 /* 122 /*
121 * x86_64 needs two ZONE_DMAs because it supports devices that are 123 * x86_64 needs two ZONE_DMAs because it supports devices that are
@@ -152,11 +154,27 @@ enum zone_type {
152 * match the requested limits. See gfp_zone() in include/linux/gfp.h 154 * match the requested limits. See gfp_zone() in include/linux/gfp.h
153 */ 155 */
154 156
155#if !defined(CONFIG_ZONE_DMA32) && !defined(CONFIG_HIGHMEM) 157/*
158 * Count the active zones. Note that the use of defined(X) outside
159 * #if and family is not necessarily defined so ensure we cannot use
160 * it later. Use __ZONE_COUNT to work out how many shift bits we need.
161 */
162#define __ZONE_COUNT ( \
163 defined(CONFIG_ZONE_DMA) \
164 + defined(CONFIG_ZONE_DMA32) \
165 + 1 \
166 + defined(CONFIG_HIGHMEM) \
167)
168#if __ZONE_COUNT < 2
169#define ZONES_SHIFT 0
170#elif __ZONE_COUNT <= 2
156#define ZONES_SHIFT 1 171#define ZONES_SHIFT 1
157#else 172#elif __ZONE_COUNT <= 4
158#define ZONES_SHIFT 2 173#define ZONES_SHIFT 2
174#else
175#error ZONES_SHIFT -- too many zones configured adjust calculation
159#endif 176#endif
177#undef __ZONE_COUNT
160 178
161struct zone { 179struct zone {
162 /* Fields commonly accessed by the page allocator */ 180 /* Fields commonly accessed by the page allocator */
@@ -523,7 +541,11 @@ static inline int is_dma32(struct zone *zone)
523 541
524static inline int is_dma(struct zone *zone) 542static inline int is_dma(struct zone *zone)
525{ 543{
544#ifdef CONFIG_ZONE_DMA
526 return zone == zone->zone_pgdat->node_zones + ZONE_DMA; 545 return zone == zone->zone_pgdat->node_zones + ZONE_DMA;
546#else
547 return 0;
548#endif
527} 549}
528 550
529/* These two functions are used to setup the per zone pages min values */ 551/* These two functions are used to setup the per zone pages min values */
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index 4b463e66ddea..5e4364644ed1 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -19,7 +19,9 @@
19struct cache_sizes { 19struct cache_sizes {
20 size_t cs_size; 20 size_t cs_size;
21 struct kmem_cache *cs_cachep; 21 struct kmem_cache *cs_cachep;
22#ifdef CONFIG_ZONE_DMA
22 struct kmem_cache *cs_dmacachep; 23 struct kmem_cache *cs_dmacachep;
24#endif
23}; 25};
24extern struct cache_sizes malloc_sizes[]; 26extern struct cache_sizes malloc_sizes[];
25 27
@@ -39,9 +41,12 @@ static inline void *kmalloc(size_t size, gfp_t flags)
39 __you_cannot_kmalloc_that_much(); 41 __you_cannot_kmalloc_that_much();
40 } 42 }
41found: 43found:
42 return kmem_cache_alloc((flags & GFP_DMA) ? 44#ifdef CONFIG_ZONE_DMA
43 malloc_sizes[i].cs_dmacachep : 45 if (flags & GFP_DMA)
44 malloc_sizes[i].cs_cachep, flags); 46 return kmem_cache_alloc(malloc_sizes[i].cs_dmacachep,
47 flags);
48#endif
49 return kmem_cache_alloc(malloc_sizes[i].cs_cachep, flags);
45 } 50 }
46 return __kmalloc(size, flags); 51 return __kmalloc(size, flags);
47} 52}
@@ -62,9 +67,12 @@ static inline void *kzalloc(size_t size, gfp_t flags)
62 __you_cannot_kzalloc_that_much(); 67 __you_cannot_kzalloc_that_much();
63 } 68 }
64found: 69found:
65 return kmem_cache_zalloc((flags & GFP_DMA) ? 70#ifdef CONFIG_ZONE_DMA
66 malloc_sizes[i].cs_dmacachep : 71 if (flags & GFP_DMA)
67 malloc_sizes[i].cs_cachep, flags); 72 return kmem_cache_zalloc(malloc_sizes[i].cs_dmacachep,
73 flags);
74#endif
75 return kmem_cache_zalloc(malloc_sizes[i].cs_cachep, flags);
68 } 76 }
69 return __kzalloc(size, flags); 77 return __kzalloc(size, flags);
70} 78}
@@ -88,9 +96,13 @@ static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
88 __you_cannot_kmalloc_that_much(); 96 __you_cannot_kmalloc_that_much();
89 } 97 }
90found: 98found:
91 return kmem_cache_alloc_node((flags & GFP_DMA) ? 99#ifdef CONFIG_ZONE_DMA
92 malloc_sizes[i].cs_dmacachep : 100 if (flags & GFP_DMA)
93 malloc_sizes[i].cs_cachep, flags, node); 101 return kmem_cache_alloc_node(malloc_sizes[i].cs_dmacachep,
102 flags, node);
103#endif
104 return kmem_cache_alloc_node(malloc_sizes[i].cs_cachep,
105 flags, node);
94 } 106 }
95 return __kmalloc_node(size, flags, node); 107 return __kmalloc_node(size, flags, node);
96} 108}
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 77caf911969c..7ba91f2839fa 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -19,6 +19,12 @@
19 * generated will simply be the increment of a global address. 19 * generated will simply be the increment of a global address.
20 */ 20 */
21 21
22#ifdef CONFIG_ZONE_DMA
23#define DMA_ZONE(xx) xx##_DMA,
24#else
25#define DMA_ZONE(xx)
26#endif
27
22#ifdef CONFIG_ZONE_DMA32 28#ifdef CONFIG_ZONE_DMA32
23#define DMA32_ZONE(xx) xx##_DMA32, 29#define DMA32_ZONE(xx) xx##_DMA32,
24#else 30#else
@@ -31,7 +37,7 @@
31#define HIGHMEM_ZONE(xx) 37#define HIGHMEM_ZONE(xx)
32#endif 38#endif
33 39
34#define FOR_ALL_ZONES(xx) xx##_DMA, DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx) 40#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx)
35 41
36enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, 42enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
37 FOR_ALL_ZONES(PGALLOC), 43 FOR_ALL_ZONES(PGALLOC),
@@ -96,7 +102,8 @@ static inline void vm_events_fold_cpu(int cpu)
96#endif /* CONFIG_VM_EVENT_COUNTERS */ 102#endif /* CONFIG_VM_EVENT_COUNTERS */
97 103
98#define __count_zone_vm_events(item, zone, delta) \ 104#define __count_zone_vm_events(item, zone, delta) \
99 __count_vm_events(item##_DMA + zone_idx(zone), delta) 105 __count_vm_events(item##_NORMAL - ZONE_NORMAL + \
106 zone_idx(zone), delta)
100 107
101/* 108/*
102 * Zone based page accounting with per cpu differentials. 109 * Zone based page accounting with per cpu differentials.
@@ -143,14 +150,16 @@ static inline unsigned long node_page_state(int node,
143 struct zone *zones = NODE_DATA(node)->node_zones; 150 struct zone *zones = NODE_DATA(node)->node_zones;
144 151
145 return 152 return
153#ifdef CONFIG_ZONE_DMA
154 zone_page_state(&zones[ZONE_DMA], item) +
155#endif
146#ifdef CONFIG_ZONE_DMA32 156#ifdef CONFIG_ZONE_DMA32
147 zone_page_state(&zones[ZONE_DMA32], item) + 157 zone_page_state(&zones[ZONE_DMA32], item) +
148#endif 158#endif
149 zone_page_state(&zones[ZONE_NORMAL], item) +
150#ifdef CONFIG_HIGHMEM 159#ifdef CONFIG_HIGHMEM
151 zone_page_state(&zones[ZONE_HIGHMEM], item) + 160 zone_page_state(&zones[ZONE_HIGHMEM], item) +
152#endif 161#endif
153 zone_page_state(&zones[ZONE_DMA], item); 162 zone_page_state(&zones[ZONE_NORMAL], item);
154} 163}
155 164
156extern void zone_statistics(struct zonelist *, struct zone *); 165extern void zone_statistics(struct zonelist *, struct zone *);