Single Zone Optimizations If we only have a single zone then various macros can be optimized. We do not need to protect higher zones, we know that zones are always present, etc etc. Signed-off-by: Christoph Lameter Index: linux-2.6.18-rc6-mm1/mm/vmstat.c =================================================================== --- linux-2.6.18-rc6-mm1.orig/mm/vmstat.c 2006-09-11 20:50:19.234607044 -0500 +++ linux-2.6.18-rc6-mm1/mm/vmstat.c 2006-09-11 20:50:24.771204715 -0500 @@ -553,7 +553,7 @@ for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) seq_printf(m, "\n %-12s %lu", vmstat_text[i], zone_page_state(zone, i)); - +#ifdef MULTI_ZONE seq_printf(m, "\n protection: (%lu", zone->lowmem_reserve[0]); @@ -562,6 +562,7 @@ seq_printf(m, ")" "\n pagesets"); +#endif for_each_online_cpu(i) { struct per_cpu_pageset *pageset; int j; Index: linux-2.6.18-rc6-mm1/mm/page_alloc.c =================================================================== --- linux-2.6.18-rc6-mm1.orig/mm/page_alloc.c 2006-09-11 20:50:19.187728109 -0500 +++ linux-2.6.18-rc6-mm1/mm/page_alloc.c 2006-09-11 20:50:24.795620827 -0500 @@ -59,6 +59,7 @@ static void __free_pages_ok(struct page *page, unsigned int order); +#ifdef MULTI_ZONE /* * results with 256, 32 in the lowmem_reserve sysctl: * 1G machine -> (16M dma, 800M-16M normal, 1G-800M high) @@ -81,6 +82,7 @@ 32 #endif }; +#endif EXPORT_SYMBOL(totalram_pages); @@ -919,8 +921,11 @@ min -= min / 2; if (alloc_flags & ALLOC_HARDER) min -= min / 4; - +#ifdef SINGLE_ZONE + if (free_pages <= min) +#else if (free_pages <= min + z->lowmem_reserve[classzone_idx]) +#endif return 0; for (o = 0; o < order; o++) { /* At the next order, this order's pages become unavailable */ @@ -1464,10 +1469,12 @@ zone->pages_scanned, (zone->all_unreclaimable ? "yes" : "no") ); +#ifdef MULTI_ZONE printk("lowmem_reserve[]:"); for (i = 0; i < MAX_NR_ZONES; i++) printk(" %lu", zone->lowmem_reserve[i]); printk("\n"); +#endif } for_each_zone(zone) { @@ -2881,12 +2888,13 @@ struct zone *zone = pgdat->node_zones + i; unsigned long max = 0; +#ifdef MULTI_ZONE /* Find valid and maximum lowmem_reserve in the zone */ for (j = i; j < MAX_NR_ZONES; j++) { if (zone->lowmem_reserve[j] > max) max = zone->lowmem_reserve[j]; } - +#endif /* we treat pages_high as reserved pages. */ max += zone->pages_high; @@ -2906,6 +2914,7 @@ */ static void setup_per_zone_lowmem_reserve(void) { +#ifdef MULTI_ZONE struct pglist_data *pgdat; enum zone_type j, idx; @@ -2935,6 +2944,7 @@ /* update totalreserve_pages */ calculate_totalreserve_pages(); +#endif } /* @@ -3084,6 +3094,7 @@ } #endif +#ifdef MULTI_ZONE /* * lowmem_reserve_ratio_sysctl_handler - just a wrapper around * proc_dointvec() so that we can call setup_per_zone_lowmem_reserve() @@ -3100,6 +3111,7 @@ setup_per_zone_lowmem_reserve(); return 0; } +#endif /* * percpu_pagelist_fraction - changes the pcp->high for each zone on each Index: linux-2.6.18-rc6-mm1/kernel/sysctl.c =================================================================== --- linux-2.6.18-rc6-mm1.orig/kernel/sysctl.c 2006-09-11 18:15:47.600449531 -0500 +++ linux-2.6.18-rc6-mm1/kernel/sysctl.c 2006-09-11 20:50:24.815153718 -0500 @@ -901,6 +901,7 @@ .proc_handler = &proc_dointvec, }, #endif +#ifdef MULTI_ZONE { .ctl_name = VM_LOWMEM_RESERVE_RATIO, .procname = "lowmem_reserve_ratio", @@ -910,6 +911,7 @@ .proc_handler = &lowmem_reserve_ratio_sysctl_handler, .strategy = &sysctl_intvec, }, +#endif { .ctl_name = VM_DROP_PAGECACHE, .procname = "drop_caches", Index: linux-2.6.18-rc6-mm1/include/linux/mmzone.h =================================================================== --- linux-2.6.18-rc6-mm1.orig/include/linux/mmzone.h 2006-09-11 20:50:19.167218574 -0500 +++ linux-2.6.18-rc6-mm1/include/linux/mmzone.h 2006-09-11 20:53:51.820809168 -0500 @@ -151,6 +151,7 @@ #if !defined(CONFIG_ZONE_DMA32) && !defined(CONFIG_HIGHMEM) #if !defined(CONFIG_ZONE_DMA) #define ZONES_SHIFT 0 +#define SINGLE_ZONE #else #define ZONES_SHIFT 1 #endif @@ -158,10 +159,15 @@ #define ZONES_SHIFT 2 #endif +#ifndef SINGLE_ZONE +#define MULTI_ZONE +#endif + struct zone { /* Fields commonly accessed by the page allocator */ unsigned long free_pages; unsigned long pages_min, pages_low, pages_high; +#ifdef MULTI_ZONE /* * We don't know if the memory that we're going to allocate will be freeable * or/and it will be released eventually, so to avoid totally wasting several @@ -171,6 +177,7 @@ * sysctl_lowmem_reserve_ratio sysctl changes. */ unsigned long lowmem_reserve[MAX_NR_ZONES]; +#endif #ifdef CONFIG_NUMA /* @@ -401,11 +408,19 @@ /* * zone_idx() returns 0 for the ZONE_DMA zone, 1 for the ZONE_NORMAL zone, etc. */ +#ifdef MULTI_ZONE #define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones) +#else +#define zone_idx(zone) ZONE_NORMAL +#endif static inline int populated_zone(struct zone *zone) { +#ifdef MULTI_ZONE return (!!zone->present_pages); +#else + return 1; +#endif } static inline int is_highmem_idx(enum zone_type idx) @@ -419,7 +434,11 @@ static inline int is_normal_idx(enum zone_type idx) { +#ifdef MULTI_ZONE return (idx == ZONE_NORMAL); +#else + return 1; +#endif } /** @@ -439,7 +458,11 @@ static inline int is_normal(struct zone *zone) { +#ifdef MULTI_ZONE return zone == zone->zone_pgdat->node_zones + ZONE_NORMAL; +#else + return 1; +#endif } static inline int is_dma32(struct zone *zone) @@ -465,9 +488,11 @@ struct file; int min_free_kbytes_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); +#ifdef MULTI_ZONE extern int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1]; int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); +#endif int percpu_pagelist_fraction_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); int sysctl_min_unmapped_ratio_sysctl_handler(struct ctl_table *, int,