aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>2012-01-10 18:08:09 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 19:30:44 -0500
commit43d2b113241d6797b890318767e0af78e313414b (patch)
tree6f25647f2660f8fca63cc8355b70ad643993dab8 /fs
parent6bd4837de96e7d9f9bf33e59117c24fc230862ac (diff)
tracepoint: add tracepoints for debugging oom_score_adj
oom_score_adj is used for guarding processes from OOM-Killer. One of problem is that it's inherited at fork(). When a daemon set oom_score_adj and make children, it's hard to know where the value is set. This patch adds some tracepoints useful for debugging. This patch adds 3 trace points. - creating new task - renaming a task (exec) - set oom_score_adj To debug, users need to enable some trace pointer. Maybe filtering is useful as # EVENT=/sys/kernel/debug/tracing/events/task/ # echo "oom_score_adj != 0" > $EVENT/task_newtask/filter # echo "oom_score_adj != 0" > $EVENT/task_rename/filter # echo 1 > $EVENT/enable # EVENT=/sys/kernel/debug/tracing/events/oom/ # echo 1 > $EVENT/enable output will be like this. # grep oom /sys/kernel/debug/tracing/trace bash-7699 [007] d..3 5140.744510: oom_score_adj_update: pid=7699 comm=bash oom_score_adj=-1000 bash-7699 [007] ...1 5151.818022: task_newtask: pid=7729 comm=bash clone_flags=1200011 oom_score_adj=-1000 ls-7729 [003] ...2 5151.818504: task_rename: pid=7729 oldcomm=bash newcomm=ls oom_score_adj=-1000 bash-7699 [002] ...1 5175.701468: task_newtask: pid=7730 comm=bash clone_flags=1200011 oom_score_adj=-1000 grep-7730 [007] ...2 5175.701993: task_rename: pid=7730 oldcomm=bash newcomm=grep oom_score_adj=-1000 Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Acked-by: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/exec.c4
-rw-r--r--fs/proc/base.c3
2 files changed, 7 insertions, 0 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 3f64b9f26e7d..aeb135c7ff5c 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -59,6 +59,8 @@
59#include <asm/uaccess.h> 59#include <asm/uaccess.h>
60#include <asm/mmu_context.h> 60#include <asm/mmu_context.h>
61#include <asm/tlb.h> 61#include <asm/tlb.h>
62
63#include <trace/events/task.h>
62#include "internal.h" 64#include "internal.h"
63 65
64int core_uses_pid; 66int core_uses_pid;
@@ -1054,6 +1056,8 @@ void set_task_comm(struct task_struct *tsk, char *buf)
1054{ 1056{
1055 task_lock(tsk); 1057 task_lock(tsk);
1056 1058
1059 trace_task_rename(tsk, buf);
1060
1057 /* 1061 /*
1058 * Threads may access current->comm without holding 1062 * Threads may access current->comm without holding
1059 * the task lock, so write the string carefully. 1063 * the task lock, so write the string carefully.
diff --git a/fs/proc/base.c b/fs/proc/base.c
index a1dddda999f2..1aab5fe05a1b 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -86,6 +86,7 @@
86#ifdef CONFIG_HARDWALL 86#ifdef CONFIG_HARDWALL
87#include <asm/hardwall.h> 87#include <asm/hardwall.h>
88#endif 88#endif
89#include <trace/events/oom.h>
89#include "internal.h" 90#include "internal.h"
90 91
91/* NOTE: 92/* NOTE:
@@ -1010,6 +1011,7 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
1010 else 1011 else
1011 task->signal->oom_score_adj = (oom_adjust * OOM_SCORE_ADJ_MAX) / 1012 task->signal->oom_score_adj = (oom_adjust * OOM_SCORE_ADJ_MAX) /
1012 -OOM_DISABLE; 1013 -OOM_DISABLE;
1014 trace_oom_score_adj_update(task);
1013err_sighand: 1015err_sighand:
1014 unlock_task_sighand(task, &flags); 1016 unlock_task_sighand(task, &flags);
1015err_task_lock: 1017err_task_lock:
@@ -1097,6 +1099,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
1097 task->signal->oom_score_adj = oom_score_adj; 1099 task->signal->oom_score_adj = oom_score_adj;
1098 if (has_capability_noaudit(current, CAP_SYS_RESOURCE)) 1100 if (has_capability_noaudit(current, CAP_SYS_RESOURCE))
1099 task->signal->oom_score_adj_min = oom_score_adj; 1101 task->signal->oom_score_adj_min = oom_score_adj;
1102 trace_oom_score_adj_update(task);
1100 /* 1103 /*
1101 * Scale /proc/pid/oom_adj appropriately ensuring that OOM_DISABLE is 1104 * Scale /proc/pid/oom_adj appropriately ensuring that OOM_DISABLE is
1102 * always attainable. 1105 * always attainable.