aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>2011-06-15 18:08:14 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-06-15 23:03:59 -0400
commit83cd81a34357a632509f7491eec81e62e71d65f7 (patch)
treecc96e65bd3000fd9090dacfabdd8810e9c66e0c9 /mm
parenta433658c30974fc87ba3ff52d7e4e6299762aa3d (diff)
vmscan: implement swap token trace
This is useful for observing swap token activity. example output: zsh-1845 [000] 598.962716: update_swap_token_priority: mm=ffff88015eaf7700 old_prio=1 new_prio=0 memtoy-1830 [001] 602.033900: update_swap_token_priority: mm=ffff880037a45880 old_prio=947 new_prio=949 memtoy-1830 [000] 602.041509: update_swap_token_priority: mm=ffff880037a45880 old_prio=949 new_prio=951 memtoy-1830 [000] 602.051959: update_swap_token_priority: mm=ffff880037a45880 old_prio=951 new_prio=953 memtoy-1830 [000] 602.052188: update_swap_token_priority: mm=ffff880037a45880 old_prio=953 new_prio=955 memtoy-1830 [001] 602.427184: put_swap_token: token_mm=ffff880037a45880 zsh-1789 [000] 602.427281: replace_swap_token: old_token_mm= (null) old_prio=0 new_token_mm=ffff88015eaf7018 new_prio=2 zsh-1789 [001] 602.433456: update_swap_token_priority: mm=ffff88015eaf7018 old_prio=2 new_prio=4 zsh-1789 [000] 602.437613: update_swap_token_priority: mm=ffff88015eaf7018 old_prio=4 new_prio=6 zsh-1789 [000] 602.443924: update_swap_token_priority: mm=ffff88015eaf7018 old_prio=6 new_prio=8 zsh-1789 [000] 602.451873: update_swap_token_priority: mm=ffff88015eaf7018 old_prio=8 new_prio=10 zsh-1789 [001] 602.462639: update_swap_token_priority: mm=ffff88015eaf7018 old_prio=10 new_prio=12 Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Acked-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')
-rw-r--r--mm/thrash.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/mm/thrash.c b/mm/thrash.c
index 6cdf86511385..17d9e29e4c9c 100644
--- a/mm/thrash.c
+++ b/mm/thrash.c
@@ -23,6 +23,8 @@
23#include <linux/swap.h> 23#include <linux/swap.h>
24#include <linux/memcontrol.h> 24#include <linux/memcontrol.h>
25 25
26#include <trace/events/vmscan.h>
27
26static DEFINE_SPINLOCK(swap_token_lock); 28static DEFINE_SPINLOCK(swap_token_lock);
27struct mm_struct *swap_token_mm; 29struct mm_struct *swap_token_mm;
28struct mem_cgroup *swap_token_memcg; 30struct mem_cgroup *swap_token_memcg;
@@ -49,6 +51,7 @@ static struct mem_cgroup *swap_token_memcg_from_mm(struct mm_struct *mm)
49void grab_swap_token(struct mm_struct *mm) 51void grab_swap_token(struct mm_struct *mm)
50{ 52{
51 int current_interval; 53 int current_interval;
54 unsigned int old_prio = mm->token_priority;
52 55
53 global_faults++; 56 global_faults++;
54 57
@@ -63,7 +66,7 @@ void grab_swap_token(struct mm_struct *mm)
63 66
64 if (mm == swap_token_mm) { 67 if (mm == swap_token_mm) {
65 mm->token_priority += 2; 68 mm->token_priority += 2;
66 goto out; 69 goto update_priority;
67 } 70 }
68 71
69 if (current_interval < mm->last_interval) 72 if (current_interval < mm->last_interval)
@@ -77,6 +80,9 @@ void grab_swap_token(struct mm_struct *mm)
77 if (mm->token_priority > swap_token_mm->token_priority) 80 if (mm->token_priority > swap_token_mm->token_priority)
78 goto replace_token; 81 goto replace_token;
79 82
83update_priority:
84 trace_update_swap_token_priority(mm, old_prio);
85
80out: 86out:
81 mm->faultstamp = global_faults; 87 mm->faultstamp = global_faults;
82 mm->last_interval = current_interval; 88 mm->last_interval = current_interval;
@@ -85,6 +91,7 @@ out:
85 91
86replace_token: 92replace_token:
87 mm->token_priority += 2; 93 mm->token_priority += 2;
94 trace_replace_swap_token(swap_token_mm, mm);
88 swap_token_mm = mm; 95 swap_token_mm = mm;
89 swap_token_memcg = swap_token_memcg_from_mm(mm); 96 swap_token_memcg = swap_token_memcg_from_mm(mm);
90 goto out; 97 goto out;
@@ -95,6 +102,7 @@ void __put_swap_token(struct mm_struct *mm)
95{ 102{
96 spin_lock(&swap_token_lock); 103 spin_lock(&swap_token_lock);
97 if (likely(mm == swap_token_mm)) { 104 if (likely(mm == swap_token_mm)) {
105 trace_put_swap_token(swap_token_mm);
98 swap_token_mm = NULL; 106 swap_token_mm = NULL;
99 swap_token_memcg = NULL; 107 swap_token_memcg = NULL;
100 } 108 }
@@ -118,6 +126,7 @@ void disable_swap_token(struct mem_cgroup *memcg)
118 if (match_memcg(memcg, swap_token_memcg)) { 126 if (match_memcg(memcg, swap_token_memcg)) {
119 spin_lock(&swap_token_lock); 127 spin_lock(&swap_token_lock);
120 if (match_memcg(memcg, swap_token_memcg)) { 128 if (match_memcg(memcg, swap_token_memcg)) {
129 trace_disable_swap_token(swap_token_mm);
121 swap_token_mm = NULL; 130 swap_token_mm = NULL;
122 swap_token_memcg = NULL; 131 swap_token_memcg = NULL;
123 } 132 }