aboutsummaryrefslogtreecommitdiffstats
path: root/mm/thrash.c
diff options
context:
space:
mode:
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>2011-06-15 18:08:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-06-15 23:03:59 -0400
commitd7911ef30cb7bec52234c2b7a5c275ac8f07905a (patch)
treec3d9dc8ffc5d9478da434faecc27759ee34edf83 /mm/thrash.c
parent83cd81a34357a632509f7491eec81e62e71d65f7 (diff)
vmscan: implement swap token priority aging
While testing for memcg aware swap token, I observed a swap token was often grabbed an intermittent running process (eg init, auditd) and they never release a token. Why? Some processes (eg init, auditd, audispd) wake up when a process exiting. And swap token can be get first page-in process when a process exiting makes no swap token owner. Thus such above intermittent running process often get a token. And currently, swap token priority is only decreased at page fault path. Then, if the process sleep immediately after to grab swap token, the swap token priority never be decreased. That's obviously undesirable. This patch implement very poor (and lightweight) priority aging. It only be affect to the above corner case and doesn't change swap tendency workload performance (eg multi process qsbench load) Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Reviewed-by: Rik van Riel <riel@redhat.com> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/thrash.c')
-rw-r--r--mm/thrash.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/mm/thrash.c b/mm/thrash.c
index 17d9e29e4c9c..fabf2d0f5169 100644
--- a/mm/thrash.c
+++ b/mm/thrash.c
@@ -25,10 +25,13 @@
25 25
26#include <trace/events/vmscan.h> 26#include <trace/events/vmscan.h>
27 27
28#define TOKEN_AGING_INTERVAL (0xFF)
29
28static DEFINE_SPINLOCK(swap_token_lock); 30static DEFINE_SPINLOCK(swap_token_lock);
29struct mm_struct *swap_token_mm; 31struct mm_struct *swap_token_mm;
30struct mem_cgroup *swap_token_memcg; 32struct mem_cgroup *swap_token_memcg;
31static unsigned int global_faults; 33static unsigned int global_faults;
34static unsigned int last_aging;
32 35
33#ifdef CONFIG_CGROUP_MEM_RES_CTLR 36#ifdef CONFIG_CGROUP_MEM_RES_CTLR
34static struct mem_cgroup *swap_token_memcg_from_mm(struct mm_struct *mm) 37static struct mem_cgroup *swap_token_memcg_from_mm(struct mm_struct *mm)
@@ -64,6 +67,11 @@ void grab_swap_token(struct mm_struct *mm)
64 if (!swap_token_mm) 67 if (!swap_token_mm)
65 goto replace_token; 68 goto replace_token;
66 69
70 if ((global_faults - last_aging) > TOKEN_AGING_INTERVAL) {
71 swap_token_mm->token_priority /= 2;
72 last_aging = global_faults;
73 }
74
67 if (mm == swap_token_mm) { 75 if (mm == swap_token_mm) {
68 mm->token_priority += 2; 76 mm->token_priority += 2;
69 goto update_priority; 77 goto update_priority;
@@ -81,7 +89,7 @@ void grab_swap_token(struct mm_struct *mm)
81 goto replace_token; 89 goto replace_token;
82 90
83update_priority: 91update_priority:
84 trace_update_swap_token_priority(mm, old_prio); 92 trace_update_swap_token_priority(mm, old_prio, swap_token_mm);
85 93
86out: 94out:
87 mm->faultstamp = global_faults; 95 mm->faultstamp = global_faults;
@@ -94,6 +102,7 @@ replace_token:
94 trace_replace_swap_token(swap_token_mm, mm); 102 trace_replace_swap_token(swap_token_mm, mm);
95 swap_token_mm = mm; 103 swap_token_mm = mm;
96 swap_token_memcg = swap_token_memcg_from_mm(mm); 104 swap_token_memcg = swap_token_memcg_from_mm(mm);
105 last_aging = global_faults;
97 goto out; 106 goto out;
98} 107}
99 108