Commit 7e96bae1 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] add kswapd success accounting to /proc/vmstat

Tells us how many pages were reclaimed by kswapd.

The `pgsteal' statistic tells us how many pages were reclaimed
altogether.  So

	kswapd_steal - pgsteal

is the number of pages which were directly reclaimed by page allocating
processes.


Also, the `pgscan' data is currently counting the number of pages
scanned in shrink_cache() plus the number of pages scanned in
refill_inactive_zone().  These are rather separate concepts, so I
created the new `pgrefill' counter for refill_inactive_zone().
`pgscan' is now just the number of pages scanned in shrink_cache().
parent 15e19695
...@@ -98,7 +98,9 @@ extern struct page_state { ...@@ -98,7 +98,9 @@ extern struct page_state {
unsigned long pgfault; unsigned long pgfault;
unsigned long pgmajfault; unsigned long pgmajfault;
unsigned long pgscan; unsigned long pgscan;
unsigned long pgrefill;
unsigned long pgsteal; unsigned long pgsteal;
unsigned long kswapd_steal;
unsigned long pageoutrun; unsigned long pageoutrun;
unsigned long allocstall; unsigned long allocstall;
} ____cacheline_aligned_in_smp page_states[NR_CPUS]; } ____cacheline_aligned_in_smp page_states[NR_CPUS];
......
...@@ -433,6 +433,7 @@ do { if (atomic_dec_and_test(&(tsk)->usage)) __put_task_struct(tsk); } while(0) ...@@ -433,6 +433,7 @@ do { if (atomic_dec_and_test(&(tsk)->usage)) __put_task_struct(tsk); } while(0)
#define PF_FROZEN 0x00040000 /* frozen for system suspend */ #define PF_FROZEN 0x00040000 /* frozen for system suspend */
#define PF_SYNC 0x00080000 /* performing fsync(), etc */ #define PF_SYNC 0x00080000 /* performing fsync(), etc */
#define PF_FSTRANS 0x00100000 /* inside a filesystem transaction */ #define PF_FSTRANS 0x00100000 /* inside a filesystem transaction */
#define PF_KSWAPD 0x00200000 /* I am kswapd */
/* /*
* Ptrace flags * Ptrace flags
......
...@@ -1080,7 +1080,9 @@ static char *vmstat_text[] = { ...@@ -1080,7 +1080,9 @@ static char *vmstat_text[] = {
"pgfault", "pgfault",
"pgmajfault", "pgmajfault",
"pgscan", "pgscan",
"pgrefill",
"pgsteal", "pgsteal",
"kswapd_steal",
"pageoutrun", "pageoutrun",
"allocstall", "allocstall",
}; };
......
...@@ -313,6 +313,8 @@ shrink_list(struct list_head *page_list, int nr_pages, ...@@ -313,6 +313,8 @@ shrink_list(struct list_head *page_list, int nr_pages,
if (pagevec_count(&freed_pvec)) if (pagevec_count(&freed_pvec))
__pagevec_release_nonlru(&freed_pvec); __pagevec_release_nonlru(&freed_pvec);
mod_page_state(pgsteal, nr_pages_in - nr_pages); mod_page_state(pgsteal, nr_pages_in - nr_pages);
if (current->flags & PF_KSWAPD)
mod_page_state(kswapd_steal, nr_pages_in - nr_pages);
mod_page_state(pgactivate, pgactivate); mod_page_state(pgactivate, pgactivate);
return nr_pages; return nr_pages;
} }
...@@ -527,7 +529,7 @@ refill_inactive_zone(struct zone *zone, const int nr_pages_in) ...@@ -527,7 +529,7 @@ refill_inactive_zone(struct zone *zone, const int nr_pages_in)
spin_unlock_irq(&zone->lru_lock); spin_unlock_irq(&zone->lru_lock);
pagevec_release(&pvec); pagevec_release(&pvec);
mod_page_state(pgscan, nr_pages_in - nr_pages); mod_page_state(pgrefill, nr_pages_in - nr_pages);
mod_page_state(pgdeactivate, pgdeactivate); mod_page_state(pgdeactivate, pgdeactivate);
} }
...@@ -757,7 +759,7 @@ int kswapd(void *p) ...@@ -757,7 +759,7 @@ int kswapd(void *p)
* us from recursively trying to free more memory as we're * us from recursively trying to free more memory as we're
* trying to free the first piece of memory in the first place). * trying to free the first piece of memory in the first place).
*/ */
tsk->flags |= PF_MEMALLOC; tsk->flags |= PF_MEMALLOC|PF_KSWAPD;
/* /*
* Kswapd main loop. * Kswapd main loop.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment