Single zone vmstat optimizations. If we have a single zone and the system is not a NUMA system then we have no need of keeping separate global and per zone statistics. Both are the same. So get rid of the statistics in a zone. The optimization is mainly useful for embedded systems. Signed-off-by: Christoph Lameter Index: linux-2.6.18-mm2/include/linux/mmzone.h =================================================================== --- linux-2.6.18-mm2.orig/include/linux/mmzone.h 2006-09-28 16:48:53.752702030 -0500 +++ linux-2.6.18-mm2/include/linux/mmzone.h 2006-09-28 16:49:03.702763441 -0500 @@ -235,8 +235,10 @@ struct zone { /* A count of how many reclaimers are scanning this zone */ atomic_t reclaim_in_progress; +#if defined(CONFIG_NUMA) || defined(MULTI_ZONE) /* Zone statistics */ atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS]; +#endif /* * prev_priority holds the scanning priority for this zone. It is Index: linux-2.6.18-mm2/include/linux/vmstat.h =================================================================== --- linux-2.6.18-mm2.orig/include/linux/vmstat.h 2006-09-28 15:29:45.386200968 -0500 +++ linux-2.6.18-mm2/include/linux/vmstat.h 2006-09-28 16:49:03.712529893 -0500 @@ -105,7 +105,9 @@ extern atomic_long_t vm_stat[NR_VM_ZONE_ static inline void zone_page_state_add(long x, struct zone *zone, enum zone_stat_item item) { +#if defined(CONFIG_NUMA) || defined(MULTI_ZONE) atomic_long_add(x, &zone->vm_stat[item]); +#endif atomic_long_add(x, &vm_stat[item]); } @@ -122,11 +124,17 @@ static inline unsigned long global_page_ static inline unsigned long zone_page_state(struct zone *zone, enum zone_stat_item item) { - long x = atomic_long_read(&zone->vm_stat[item]); + long x; + +#if defined(CONFIG_NUMA) || defined(MULTI_ZONE) + x = atomic_long_read(&zone->vm_stat[item]); #ifdef CONFIG_SMP if (x < 0) x = 0; #endif +#else + x = atomic_long_read(&vm_stat[item]); +#endif return x; } @@ -173,7 +181,9 @@ extern void zone_statistics(struct zonel static inline void zap_zone_vm_stats(struct zone *zone) { +#if defined(CONFIG_NUMA) || defined(MULTI_ZONE) memset(zone->vm_stat, 0, sizeof(zone->vm_stat)); +#endif } extern void inc_zone_state(struct zone *, enum zone_stat_item); @@ -206,7 +216,9 @@ static inline void __mod_zone_page_state static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item) { +#if defined(CONFIG_NUMA) || defined(MULTI_ZONE) atomic_long_inc(&zone->vm_stat[item]); +#endif atomic_long_inc(&vm_stat[item]); } @@ -219,7 +231,9 @@ static inline void __inc_zone_page_state static inline void __dec_zone_page_state(struct page *page, enum zone_stat_item item) { +#if defined(CONFIG_NUMA) || defined(MULTI_ZONE) atomic_long_dec(&page_zone(page)->vm_stat[item]); +#endif atomic_long_dec(&vm_stat[item]); } Index: linux-2.6.18-mm2/mm/vmstat.c =================================================================== --- linux-2.6.18-mm2.orig/mm/vmstat.c 2006-09-28 16:47:53.000000000 -0500 +++ linux-2.6.18-mm2/mm/vmstat.c 2006-09-28 16:52:50.162372945 -0500 @@ -364,7 +364,11 @@ EXPORT_SYMBOL(refresh_vm_stats); */ void zone_statistics(struct zonelist *zonelist, struct zone *z) { +#ifdef MULTI_ZONE if (z->zone_pgdat == zonelist->zones[0]->zone_pgdat) { +#else + if (z == zonelist->zones[0]) { +#endif __inc_zone_state(z, NUMA_HIT); } else { __inc_zone_state(z, NUMA_MISS);