mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
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 <[email protected]> Cc: KOSAKI Motohiro <[email protected]> Acked-by: David Rientjes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
6bd4837de9
commit
43d2b11324
6 changed files with 113 additions and 0 deletions
|
|
@ -59,6 +59,8 @@
|
|||
#include <asm/uaccess.h>
|
||||
#include <asm/mmu_context.h>
|
||||
#include <asm/tlb.h>
|
||||
|
||||
#include <trace/events/task.h>
|
||||
#include "internal.h"
|
||||
|
||||
int core_uses_pid;
|
||||
|
|
@ -1054,6 +1056,8 @@ void set_task_comm(struct task_struct *tsk, char *buf)
|
|||
{
|
||||
task_lock(tsk);
|
||||
|
||||
trace_task_rename(tsk, buf);
|
||||
|
||||
/*
|
||||
* Threads may access current->comm without holding
|
||||
* the task lock, so write the string carefully.
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@
|
|||
#ifdef CONFIG_HARDWALL
|
||||
#include <asm/hardwall.h>
|
||||
#endif
|
||||
#include <trace/events/oom.h>
|
||||
#include "internal.h"
|
||||
|
||||
/* NOTE:
|
||||
|
|
@ -1010,6 +1011,7 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
|
|||
else
|
||||
task->signal->oom_score_adj = (oom_adjust * OOM_SCORE_ADJ_MAX) /
|
||||
-OOM_DISABLE;
|
||||
trace_oom_score_adj_update(task);
|
||||
err_sighand:
|
||||
unlock_task_sighand(task, &flags);
|
||||
err_task_lock:
|
||||
|
|
@ -1097,6 +1099,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
|
|||
task->signal->oom_score_adj = oom_score_adj;
|
||||
if (has_capability_noaudit(current, CAP_SYS_RESOURCE))
|
||||
task->signal->oom_score_adj_min = oom_score_adj;
|
||||
trace_oom_score_adj_update(task);
|
||||
/*
|
||||
* Scale /proc/pid/oom_adj appropriately ensuring that OOM_DISABLE is
|
||||
* always attainable.
|
||||
|
|
|
|||
Loading…
Reference in a new issue