aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mmzone.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/mmzone.h')
-rw-r--r--include/linux/mmzone.h137
1 files changed, 91 insertions, 46 deletions
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index f45163c528e8..59855b8718a0 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -51,12 +51,14 @@ enum zone_stat_item {
51 NR_FILE_MAPPED, /* pagecache pages mapped into pagetables. 51 NR_FILE_MAPPED, /* pagecache pages mapped into pagetables.
52 only modified from process context */ 52 only modified from process context */
53 NR_FILE_PAGES, 53 NR_FILE_PAGES,
54 NR_SLAB, /* Pages used by slab allocator */ 54 NR_SLAB_RECLAIMABLE,
55 NR_SLAB_UNRECLAIMABLE,
55 NR_PAGETABLE, /* used for pagetables */ 56 NR_PAGETABLE, /* used for pagetables */
56 NR_FILE_DIRTY, 57 NR_FILE_DIRTY,
57 NR_WRITEBACK, 58 NR_WRITEBACK,
58 NR_UNSTABLE_NFS, /* NFS unstable pages */ 59 NR_UNSTABLE_NFS, /* NFS unstable pages */
59 NR_BOUNCE, 60 NR_BOUNCE,
61 NR_VMSCAN_WRITE,
60#ifdef CONFIG_NUMA 62#ifdef CONFIG_NUMA
61 NUMA_HIT, /* allocated in intended node */ 63 NUMA_HIT, /* allocated in intended node */
62 NUMA_MISS, /* allocated in non intended node */ 64 NUMA_MISS, /* allocated in non intended node */
@@ -88,53 +90,68 @@ struct per_cpu_pageset {
88#define zone_pcp(__z, __cpu) (&(__z)->pageset[(__cpu)]) 90#define zone_pcp(__z, __cpu) (&(__z)->pageset[(__cpu)])
89#endif 91#endif
90 92
91#define ZONE_DMA 0 93enum zone_type {
92#define ZONE_DMA32 1 94 /*
93#define ZONE_NORMAL 2 95 * ZONE_DMA is used when there are devices that are not able
94#define ZONE_HIGHMEM 3 96 * to do DMA to all of addressable memory (ZONE_NORMAL). Then we
95 97 * carve out the portion of memory that is needed for these devices.
96#define MAX_NR_ZONES 4 /* Sync this with ZONES_SHIFT */ 98 * The range is arch specific.
97#define ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */ 99 *
98 100 * Some examples
101 *
102 * Architecture Limit
103 * ---------------------------
104 * parisc, ia64, sparc <4G
105 * s390 <2G
106 * arm26 <48M
107 * arm Various
108 * alpha Unlimited or 0-16MB.
109 *
110 * i386, x86_64 and multiple other arches
111 * <16M.
112 */
113 ZONE_DMA,
114#ifdef CONFIG_ZONE_DMA32
115 /*
116 * x86_64 needs two ZONE_DMAs because it supports devices that are
117 * only able to do DMA to the lower 16M but also 32 bit devices that
118 * can only do DMA areas below 4G.
119 */
120 ZONE_DMA32,
121#endif
122 /*
123 * Normal addressable memory is in ZONE_NORMAL. DMA operations can be
124 * performed on pages in ZONE_NORMAL if the DMA devices support
125 * transfers to all addressable memory.
126 */
127 ZONE_NORMAL,
128#ifdef CONFIG_HIGHMEM
129 /*
130 * A memory area that is only addressable by the kernel through
131 * mapping portions into its own address space. This is for example
132 * used by i386 to allow the kernel to address the memory beyond
133 * 900MB. The kernel will set up special mappings (page
134 * table entries on i386) for each page that the kernel needs to
135 * access.
136 */
137 ZONE_HIGHMEM,
138#endif
139 MAX_NR_ZONES
140};
99 141
100/* 142/*
101 * When a memory allocation must conform to specific limitations (such 143 * When a memory allocation must conform to specific limitations (such
102 * as being suitable for DMA) the caller will pass in hints to the 144 * as being suitable for DMA) the caller will pass in hints to the
103 * allocator in the gfp_mask, in the zone modifier bits. These bits 145 * allocator in the gfp_mask, in the zone modifier bits. These bits
104 * are used to select a priority ordered list of memory zones which 146 * are used to select a priority ordered list of memory zones which
105 * match the requested limits. GFP_ZONEMASK defines which bits within 147 * match the requested limits. See gfp_zone() in include/linux/gfp.h
106 * the gfp_mask should be considered as zone modifiers. Each valid
107 * combination of the zone modifier bits has a corresponding list
108 * of zones (in node_zonelists). Thus for two zone modifiers there
109 * will be a maximum of 4 (2 ** 2) zonelists, for 3 modifiers there will
110 * be 8 (2 ** 3) zonelists. GFP_ZONETYPES defines the number of possible
111 * combinations of zone modifiers in "zone modifier space".
112 *
113 * As an optimisation any zone modifier bits which are only valid when
114 * no other zone modifier bits are set (loners) should be placed in
115 * the highest order bits of this field. This allows us to reduce the
116 * extent of the zonelists thus saving space. For example in the case
117 * of three zone modifier bits, we could require up to eight zonelists.
118 * If the left most zone modifier is a "loner" then the highest valid
119 * zonelist would be four allowing us to allocate only five zonelists.
120 * Use the first form for GFP_ZONETYPES when the left most bit is not
121 * a "loner", otherwise use the second.
122 *
123 * NOTE! Make sure this matches the zones in <linux/gfp.h>
124 */ 148 */
125#define GFP_ZONEMASK 0x07
126/* #define GFP_ZONETYPES (GFP_ZONEMASK + 1) */ /* Non-loner */
127#define GFP_ZONETYPES ((GFP_ZONEMASK + 1) / 2 + 1) /* Loner */
128 149
129/* 150#if !defined(CONFIG_ZONE_DMA32) && !defined(CONFIG_HIGHMEM)
130 * On machines where it is needed (eg PCs) we divide physical memory 151#define ZONES_SHIFT 1
131 * into multiple physical zones. On a 32bit PC we have 4 zones: 152#else
132 * 153#define ZONES_SHIFT 2
133 * ZONE_DMA < 16 MB ISA DMA capable memory 154#endif
134 * ZONE_DMA32 0 MB Empty
135 * ZONE_NORMAL 16-896 MB direct mapped by the kernel
136 * ZONE_HIGHMEM > 896 MB only page cache and user processes
137 */
138 155
139struct zone { 156struct zone {
140 /* Fields commonly accessed by the page allocator */ 157 /* Fields commonly accessed by the page allocator */
@@ -151,10 +168,12 @@ struct zone {
151 unsigned long lowmem_reserve[MAX_NR_ZONES]; 168 unsigned long lowmem_reserve[MAX_NR_ZONES];
152 169
153#ifdef CONFIG_NUMA 170#ifdef CONFIG_NUMA
171 int node;
154 /* 172 /*
155 * zone reclaim becomes active if more unmapped pages exist. 173 * zone reclaim becomes active if more unmapped pages exist.
156 */ 174 */
157 unsigned long min_unmapped_ratio; 175 unsigned long min_unmapped_pages;
176 unsigned long min_slab_pages;
158 struct per_cpu_pageset *pageset[NR_CPUS]; 177 struct per_cpu_pageset *pageset[NR_CPUS];
159#else 178#else
160 struct per_cpu_pageset pageset[NR_CPUS]; 179 struct per_cpu_pageset pageset[NR_CPUS];
@@ -266,7 +285,6 @@ struct zone {
266 char *name; 285 char *name;
267} ____cacheline_internodealigned_in_smp; 286} ____cacheline_internodealigned_in_smp;
268 287
269
270/* 288/*
271 * The "priority" of VM scanning is how much of the queues we will scan in one 289 * The "priority" of VM scanning is how much of the queues we will scan in one
272 * go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the 290 * go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the
@@ -289,6 +307,18 @@ struct zonelist {
289 struct zone *zones[MAX_NUMNODES * MAX_NR_ZONES + 1]; // NULL delimited 307 struct zone *zones[MAX_NUMNODES * MAX_NR_ZONES + 1]; // NULL delimited
290}; 308};
291 309
310#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
311struct node_active_region {
312 unsigned long start_pfn;
313 unsigned long end_pfn;
314 int nid;
315};
316#endif /* CONFIG_ARCH_POPULATES_NODE_MAP */
317
318#ifndef CONFIG_DISCONTIGMEM
319/* The array of struct pages - for discontigmem use pgdat->lmem_map */
320extern struct page *mem_map;
321#endif
292 322
293/* 323/*
294 * The pg_data_t structure is used in machines with CONFIG_DISCONTIGMEM 324 * The pg_data_t structure is used in machines with CONFIG_DISCONTIGMEM
@@ -304,7 +334,7 @@ struct zonelist {
304struct bootmem_data; 334struct bootmem_data;
305typedef struct pglist_data { 335typedef struct pglist_data {
306 struct zone node_zones[MAX_NR_ZONES]; 336 struct zone node_zones[MAX_NR_ZONES];
307 struct zonelist node_zonelists[GFP_ZONETYPES]; 337 struct zonelist node_zonelists[MAX_NR_ZONES];
308 int nr_zones; 338 int nr_zones;
309#ifdef CONFIG_FLAT_NODE_MEM_MAP 339#ifdef CONFIG_FLAT_NODE_MEM_MAP
310 struct page *node_mem_map; 340 struct page *node_mem_map;
@@ -373,12 +403,16 @@ static inline int populated_zone(struct zone *zone)
373 return (!!zone->present_pages); 403 return (!!zone->present_pages);
374} 404}
375 405
376static inline int is_highmem_idx(int idx) 406static inline int is_highmem_idx(enum zone_type idx)
377{ 407{
408#ifdef CONFIG_HIGHMEM
378 return (idx == ZONE_HIGHMEM); 409 return (idx == ZONE_HIGHMEM);
410#else
411 return 0;
412#endif
379} 413}
380 414
381static inline int is_normal_idx(int idx) 415static inline int is_normal_idx(enum zone_type idx)
382{ 416{
383 return (idx == ZONE_NORMAL); 417 return (idx == ZONE_NORMAL);
384} 418}
@@ -391,7 +425,11 @@ static inline int is_normal_idx(int idx)
391 */ 425 */
392static inline int is_highmem(struct zone *zone) 426static inline int is_highmem(struct zone *zone)
393{ 427{
428#ifdef CONFIG_HIGHMEM
394 return zone == zone->zone_pgdat->node_zones + ZONE_HIGHMEM; 429 return zone == zone->zone_pgdat->node_zones + ZONE_HIGHMEM;
430#else
431 return 0;
432#endif
395} 433}
396 434
397static inline int is_normal(struct zone *zone) 435static inline int is_normal(struct zone *zone)
@@ -401,7 +439,11 @@ static inline int is_normal(struct zone *zone)
401 439
402static inline int is_dma32(struct zone *zone) 440static inline int is_dma32(struct zone *zone)
403{ 441{
442#ifdef CONFIG_ZONE_DMA32
404 return zone == zone->zone_pgdat->node_zones + ZONE_DMA32; 443 return zone == zone->zone_pgdat->node_zones + ZONE_DMA32;
444#else
445 return 0;
446#endif
405} 447}
406 448
407static inline int is_dma(struct zone *zone) 449static inline int is_dma(struct zone *zone)
@@ -421,6 +463,8 @@ int percpu_pagelist_fraction_sysctl_handler(struct ctl_table *, int, struct file
421 void __user *, size_t *, loff_t *); 463 void __user *, size_t *, loff_t *);
422int sysctl_min_unmapped_ratio_sysctl_handler(struct ctl_table *, int, 464int sysctl_min_unmapped_ratio_sysctl_handler(struct ctl_table *, int,
423 struct file *, void __user *, size_t *, loff_t *); 465 struct file *, void __user *, size_t *, loff_t *);
466int sysctl_min_slab_ratio_sysctl_handler(struct ctl_table *, int,
467 struct file *, void __user *, size_t *, loff_t *);
424 468
425#include <linux/topology.h> 469#include <linux/topology.h>
426/* Returns the number of the current Node. */ 470/* Returns the number of the current Node. */
@@ -488,7 +532,8 @@ extern struct zone *next_zone(struct zone *zone);
488 532
489#endif 533#endif
490 534
491#ifndef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID 535#if !defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID) && \
536 !defined(CONFIG_ARCH_POPULATES_NODE_MAP)
492#define early_pfn_to_nid(nid) (0UL) 537#define early_pfn_to_nid(nid) (0UL)
493#endif 538#endif
494 539