diff options
author | KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> | 2011-06-15 18:08:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-06-15 23:03:59 -0400 |
commit | 83cd81a34357a632509f7491eec81e62e71d65f7 (patch) | |
tree | cc96e65bd3000fd9090dacfabdd8810e9c66e0c9 | |
parent | a433658c30974fc87ba3ff52d7e4e6299762aa3d (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>
-rw-r--r-- | include/trace/events/vmscan.h | 77 | ||||
-rw-r--r-- | mm/thrash.c | 11 |
2 files changed, 87 insertions, 1 deletions
diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h index ea422aaa23e1..1798e0cee2a9 100644 --- a/include/trace/events/vmscan.h +++ b/include/trace/events/vmscan.h | |||
@@ -6,6 +6,8 @@ | |||
6 | 6 | ||
7 | #include <linux/types.h> | 7 | #include <linux/types.h> |
8 | #include <linux/tracepoint.h> | 8 | #include <linux/tracepoint.h> |
9 | #include <linux/mm.h> | ||
10 | #include <linux/memcontrol.h> | ||
9 | #include "gfpflags.h" | 11 | #include "gfpflags.h" |
10 | 12 | ||
11 | #define RECLAIM_WB_ANON 0x0001u | 13 | #define RECLAIM_WB_ANON 0x0001u |
@@ -310,6 +312,81 @@ TRACE_EVENT(mm_vmscan_lru_shrink_inactive, | |||
310 | show_reclaim_flags(__entry->reclaim_flags)) | 312 | show_reclaim_flags(__entry->reclaim_flags)) |
311 | ); | 313 | ); |
312 | 314 | ||
315 | TRACE_EVENT(replace_swap_token, | ||
316 | TP_PROTO(struct mm_struct *old_mm, | ||
317 | struct mm_struct *new_mm), | ||
318 | |||
319 | TP_ARGS(old_mm, new_mm), | ||
320 | |||
321 | TP_STRUCT__entry( | ||
322 | __field(struct mm_struct*, old_mm) | ||
323 | __field(unsigned int, old_prio) | ||
324 | __field(struct mm_struct*, new_mm) | ||
325 | __field(unsigned int, new_prio) | ||
326 | ), | ||
327 | |||
328 | TP_fast_assign( | ||
329 | __entry->old_mm = old_mm; | ||
330 | __entry->old_prio = old_mm ? old_mm->token_priority : 0; | ||
331 | __entry->new_mm = new_mm; | ||
332 | __entry->new_prio = new_mm->token_priority; | ||
333 | ), | ||
334 | |||
335 | TP_printk("old_token_mm=%p old_prio=%u new_token_mm=%p new_prio=%u", | ||
336 | __entry->old_mm, __entry->old_prio, | ||
337 | __entry->new_mm, __entry->new_prio) | ||
338 | ); | ||
339 | |||
340 | DECLARE_EVENT_CLASS(put_swap_token_template, | ||
341 | TP_PROTO(struct mm_struct *swap_token_mm), | ||
342 | |||
343 | TP_ARGS(swap_token_mm), | ||
344 | |||
345 | TP_STRUCT__entry( | ||
346 | __field(struct mm_struct*, swap_token_mm) | ||
347 | ), | ||
348 | |||
349 | TP_fast_assign( | ||
350 | __entry->swap_token_mm = swap_token_mm; | ||
351 | ), | ||
352 | |||
353 | TP_printk("token_mm=%p", __entry->swap_token_mm) | ||
354 | ); | ||
355 | |||
356 | DEFINE_EVENT(put_swap_token_template, put_swap_token, | ||
357 | TP_PROTO(struct mm_struct *swap_token_mm), | ||
358 | TP_ARGS(swap_token_mm) | ||
359 | ); | ||
360 | |||
361 | DEFINE_EVENT_CONDITION(put_swap_token_template, disable_swap_token, | ||
362 | TP_PROTO(struct mm_struct *swap_token_mm), | ||
363 | TP_ARGS(swap_token_mm), | ||
364 | TP_CONDITION(swap_token_mm != NULL) | ||
365 | ); | ||
366 | |||
367 | TRACE_EVENT_CONDITION(update_swap_token_priority, | ||
368 | TP_PROTO(struct mm_struct *mm, | ||
369 | unsigned int old_prio), | ||
370 | |||
371 | TP_ARGS(mm, old_prio), | ||
372 | |||
373 | TP_CONDITION(mm->token_priority != old_prio), | ||
374 | |||
375 | TP_STRUCT__entry( | ||
376 | __field(struct mm_struct*, mm) | ||
377 | __field(unsigned int, old_prio) | ||
378 | __field(unsigned int, new_prio) | ||
379 | ), | ||
380 | |||
381 | TP_fast_assign( | ||
382 | __entry->mm = mm; | ||
383 | __entry->old_prio = old_prio; | ||
384 | __entry->new_prio = mm->token_priority; | ||
385 | ), | ||
386 | |||
387 | TP_printk("mm=%p old_prio=%u new_prio=%u", | ||
388 | __entry->mm, __entry->old_prio, __entry->new_prio) | ||
389 | ); | ||
313 | 390 | ||
314 | #endif /* _TRACE_VMSCAN_H */ | 391 | #endif /* _TRACE_VMSCAN_H */ |
315 | 392 | ||
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 | |||
26 | static DEFINE_SPINLOCK(swap_token_lock); | 28 | static DEFINE_SPINLOCK(swap_token_lock); |
27 | struct mm_struct *swap_token_mm; | 29 | struct mm_struct *swap_token_mm; |
28 | struct mem_cgroup *swap_token_memcg; | 30 | struct mem_cgroup *swap_token_memcg; |
@@ -49,6 +51,7 @@ static struct mem_cgroup *swap_token_memcg_from_mm(struct mm_struct *mm) | |||
49 | void grab_swap_token(struct mm_struct *mm) | 51 | void 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 | ||
83 | update_priority: | ||
84 | trace_update_swap_token_priority(mm, old_prio); | ||
85 | |||
80 | out: | 86 | out: |
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 | ||
86 | replace_token: | 92 | replace_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 | } |