[patch 2/2] stats for orphaned pages (-mm only)

From: Nick Piggin
Date: Mon Jun 20 2005 - 02:27:59 EST


And this.

--
SUSE Labs, Novell Inc.


Index: linux-2.6/mm/swap.c
===================================================================
--- linux-2.6.orig/mm/swap.c 2005-06-20 17:20:28.216728238 +1000
+++ linux-2.6/mm/swap.c 2005-06-20 17:21:38.253021265 +1000
@@ -114,8 +114,16 @@
struct zone *zone = page_zone(page);

spin_lock_irqsave(&zone->lru_lock, flags);
- ClearPageReferenced(page);
+ if (PageLRU(page))
+ SetPageOrphaned(page);
+ if (PageReferenced(page)) {
+ if (PageLRU(page))
+ inc_page_state(pg_orph_stripped);
+ ClearPageReferenced(page);
+ }
+
if (PageLRU(page) && PageActive(page)) {
+ inc_page_state(pg_orph_rotated);
list_move(&page->lru, &zone->inactive_list);
ClearPageActive(page);
}
Index: linux-2.6/include/linux/page-flags.h
===================================================================
--- linux-2.6.orig/include/linux/page-flags.h 2005-06-20 17:20:28.216728238 +1000
+++ linux-2.6/include/linux/page-flags.h 2005-06-20 17:20:56.005273542 +1000
@@ -77,6 +77,8 @@
#define PG_nosave_free 19 /* Free, should not be written */
#define PG_uncached 20 /* Page has been mapped as uncached */

+#define PG_orphaned 21
+
/*
* Global page accounting. One instance per CPU. Only unsigned longs are
* allowed.
@@ -132,6 +134,11 @@

unsigned long pgrotated; /* pages rotated to tail of the LRU */
unsigned long nr_bounce; /* pages for bounce buffers */
+
+ unsigned long pg_orph_stripped; /* Removed ref bit from orphaned page */
+ unsigned long pg_orph_rotated; /* Deactivated orphaned page */
+ unsigned long pg_orph_busy; /* Found orphans still busy */
+ unsigned long pg_orph_reclaim; /* Reclaimed orphan at first sight */
};

extern void get_page_state(struct page_state *ret);
@@ -306,6 +313,10 @@
#define SetPageUncached(page) set_bit(PG_uncached, &(page)->flags)
#define ClearPageUncached(page) clear_bit(PG_uncached, &(page)->flags)

+#define PageOrphaned(page) test_bit(PG_orphaned, &(page)->flags)
+#define SetPageOrphaned(page) set_bit(PG_orphaned, &(page)->flags)
+#define ClearPageOrphaned(page) clear_bit(PG_orphaned, &(page)->flags)
+
struct page; /* forward declaration */

int test_clear_page_dirty(struct page *page);
Index: linux-2.6/mm/page_alloc.c
===================================================================
--- linux-2.6.orig/mm/page_alloc.c 2005-06-20 17:20:28.216728238 +1000
+++ linux-2.6/mm/page_alloc.c 2005-06-20 17:20:56.006273417 +1000
@@ -1899,6 +1899,11 @@

"pgrotated",
"nr_bounce",
+
+ "pg_orph_stripped",
+ "pg_orph_rotated",
+ "pg_orph_busy",
+ "pg_orph_reclaim",
};

static void *vmstat_start(struct seq_file *m, loff_t *pos)
Index: linux-2.6/mm/vmscan.c
===================================================================
--- linux-2.6.orig/mm/vmscan.c 2005-06-20 17:20:28.216728238 +1000
+++ linux-2.6/mm/vmscan.c 2005-06-20 17:21:26.171523247 +1000
@@ -522,6 +522,11 @@
__put_page(page);

free_it:
+ if (PageOrphaned(page)) {
+ inc_page_state(pg_orph_reclaim);
+ ClearPageOrphaned(page);
+ }
+
unlock_page(page);
reclaimed++;
if (!pagevec_add(&freed_pvec, page))
@@ -534,6 +539,11 @@
keep_locked:
unlock_page(page);
keep:
+ if (PageOrphaned(page)) {
+ inc_page_state(pg_orph_busy);
+ ClearPageOrphaned(page);
+ }
+
list_add(&page->lru, &ret_pages);
BUG_ON(PageLRU(page));
}