From ff1635cda275a5988d134dc1b58a4a63b66e3fd6 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Wed, 25 Jul 2007 20:05:37 -0700 Subject: [PATCH] compound pages: vmstat support Add support for compound pages so that inc_xxxx_state() and dec_xxx_state() will increment the ZVCs by the number of base pages of the compound page. Signed-off-by: Christoph Lameter --- include/linux/vmstat.h | 5 ++--- mm/vmstat.c | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) Index: mm/include/linux/vmstat.h =================================================================== --- mm.orig/include/linux/vmstat.h 2007-11-16 21:16:36.000000000 -0800 +++ mm/include/linux/vmstat.h 2007-11-28 14:13:27.912038810 -0800 @@ -234,7 +234,7 @@ static inline void __inc_zone_state(stru static inline void __inc_zone_page_state(struct page *page, enum zone_stat_item item) { - __inc_zone_state(page_zone(page), item); + __mod_zone_page_state(page_zone(page), item, compound_pages(page)); } static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item) @@ -246,8 +246,7 @@ static inline void __dec_zone_state(stru static inline void __dec_zone_page_state(struct page *page, enum zone_stat_item item) { - atomic_long_dec(&page_zone(page)->vm_stat[item]); - atomic_long_dec(&vm_stat[item]); + __mod_zone_page_state(page_zone(page), item, -compound_pages(page)); } /* Index: mm/mm/vmstat.c =================================================================== --- mm.orig/mm/vmstat.c 2007-11-28 12:27:32.487962592 -0800 +++ mm/mm/vmstat.c 2007-11-28 14:13:27.920976808 -0800 @@ -226,7 +226,12 @@ void __inc_zone_state(struct zone *zone, void __inc_zone_page_state(struct page *page, enum zone_stat_item item) { - __inc_zone_state(page_zone(page), item); + struct zone *z = page_zone(page); + + if (likely(!PageHead(page))) + __inc_zone_state(z, item); + else + __mod_zone_page_state(z, item, compound_pages(page)); } EXPORT_SYMBOL(__inc_zone_page_state); @@ -247,7 +252,12 @@ void __dec_zone_state(struct zone *zone, void __dec_zone_page_state(struct page *page, enum zone_stat_item item) { - __dec_zone_state(page_zone(page), item); + struct zone *z = page_zone(page); + + if (likely(!PageHead(page))) + __dec_zone_state(z, item); + else + __mod_zone_page_state(z, item, -compound_pages(page)); } EXPORT_SYMBOL(__dec_zone_page_state); @@ -263,11 +273,9 @@ void inc_zone_state(struct zone *zone, e void inc_zone_page_state(struct page *page, enum zone_stat_item item) { unsigned long flags; - struct zone *zone; - zone = page_zone(page); local_irq_save(flags); - __inc_zone_state(zone, item); + __inc_zone_page_state(page, item); local_irq_restore(flags); } EXPORT_SYMBOL(inc_zone_page_state);