Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176268
b: refs/heads/master
c: f50de2d
h: refs/heads/master
v: v3
  • Loading branch information
Mel Gorman authored and Linus Torvalds committed Dec 15, 2009
1 parent a76cb5f commit 572f2f7
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 273f047e36d83179573dc7e3a8af6aceaa8c599e
refs/heads/master: f50de2d3811081957156b5d736778799379c29de
1 change: 1 addition & 0 deletions trunk/include/linux/vmstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
PGSCAN_ZONE_RECLAIM_FAILED,
#endif
PGINODESTEAL, SLABS_SCANNED, KSWAPD_STEAL, KSWAPD_INODESTEAL,
KSWAPD_PREMATURE_FAST, KSWAPD_PREMATURE_SLOW,
PAGEOUTRUN, ALLOCSTALL, PGROTATED,
#ifdef CONFIG_HUGETLB_PAGE
HTLB_BUDDY_PGALLOC, HTLB_BUDDY_PGALLOC_FAIL,
Expand Down
44 changes: 42 additions & 2 deletions trunk/mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,24 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
}
#endif

/* is kswapd sleeping prematurely? */
static int sleeping_prematurely(int order, long remaining)
{
struct zone *zone;

/* If a direct reclaimer woke kswapd within HZ/10, it's premature */
if (remaining)
return 1;

/* If after HZ/10, a zone is below the high mark, it's premature */
for_each_populated_zone(zone)
if (!zone_watermark_ok(zone, order, high_wmark_pages(zone),
0, 0))
return 1;

return 0;
}

/*
* For kswapd, balance_pgdat() will work across all this node's zones until
* they are all at high_wmark_pages(zone).
Expand Down Expand Up @@ -2185,8 +2203,30 @@ static int kswapd(void *p)
*/
order = new_order;
} else {
if (!freezing(current) && !kthread_should_stop())
schedule();
if (!freezing(current) && !kthread_should_stop()) {
long remaining = 0;

/* Try to sleep for a short interval */
if (!sleeping_prematurely(order, remaining)) {
remaining = schedule_timeout(HZ/10);
finish_wait(&pgdat->kswapd_wait, &wait);
prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
}

/*
* After a short sleep, check if it was a
* premature sleep. If not, then go fully
* to sleep until explicitly woken up
*/
if (!sleeping_prematurely(order, remaining))
schedule();
else {
if (remaining)
count_vm_event(KSWAPD_PREMATURE_FAST);
else
count_vm_event(KSWAPD_PREMATURE_SLOW);
}
}

order = pgdat->kswapd_max_order;
}
Expand Down
2 changes: 2 additions & 0 deletions trunk/mm/vmstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,8 @@ static const char * const vmstat_text[] = {
"slabs_scanned",
"kswapd_steal",
"kswapd_inodesteal",
"kswapd_slept_prematurely_fast",
"kswapd_slept_prematurely_slow",
"pageoutrun",
"allocstall",

Expand Down

0 comments on commit 572f2f7

Please sign in to comment.