[23/36] compound pages: vmstat support

clameter
2007-08-28T19:11:26Z

[-- Attachment #1: 0023-compound-pages-vmstat-support.patch --]
[-- Type: text/plain, Size: 2650 bytes --]

Add support for compound pages so that

inc_xxxx and dec_xxx

will increment the ZVCs by the number of base pages of the compound page.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
include/linux/vmstat.h | 5 ++---
mm/vmstat.c | 18 +++++++++++++-----
2 files changed, 15 insertions(+), 8 deletions(-)

Index: linux-2.6/include/linux/vmstat.h
===================================================================
--- linux-2.6.orig/include/linux/vmstat.h 2007-08-27 19:22:13.000000000 -0700
+++ linux-2.6/include/linux/vmstat.h 2007-08-27 20:59:42.000000000 -0700
@@ -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: linux-2.6/mm/vmstat.c
===================================================================
--- linux-2.6.orig/mm/vmstat.c 2007-08-27 19:22:13.000000000 -0700
+++ linux-2.6/mm/vmstat.c 2007-08-27 20:59:42.000000000 -0700
@@ -225,7 +225,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);

@@ -246,7 +251,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);

@@ -262,11 +272,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);

--