forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
Showing
6 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#undef TRACE_SYSTEM | ||
#define TRACE_SYSTEM oom | ||
|
||
#if !defined(_TRACE_OOM_H) || defined(TRACE_HEADER_MULTI_READ) | ||
#define _TRACE_OOM_H | ||
#include <linux/tracepoint.h> | ||
|
||
TRACE_EVENT(oom_score_adj_update, | ||
|
||
TP_PROTO(struct task_struct *task), | ||
|
||
TP_ARGS(task), | ||
|
||
TP_STRUCT__entry( | ||
__field( pid_t, pid) | ||
__array( char, comm, TASK_COMM_LEN ) | ||
__field( int, oom_score_adj) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->pid = task->pid; | ||
memcpy(__entry->comm, task->comm, TASK_COMM_LEN); | ||
__entry->oom_score_adj = task->signal->oom_score_adj; | ||
), | ||
|
||
TP_printk("pid=%d comm=%s oom_score_adj=%d", | ||
__entry->pid, __entry->comm, __entry->oom_score_adj) | ||
); | ||
|
||
#endif | ||
|
||
/* This part must be outside protection */ | ||
#include <trace/define_trace.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#undef TRACE_SYSTEM | ||
#define TRACE_SYSTEM task | ||
|
||
#if !defined(_TRACE_TASK_H) || defined(TRACE_HEADER_MULTI_READ) | ||
#define _TRACE_TASK_H | ||
#include <linux/tracepoint.h> | ||
|
||
TRACE_EVENT(task_newtask, | ||
|
||
TP_PROTO(struct task_struct *task, unsigned long clone_flags), | ||
|
||
TP_ARGS(task, clone_flags), | ||
|
||
TP_STRUCT__entry( | ||
__field( pid_t, pid) | ||
__array( char, comm, TASK_COMM_LEN) | ||
__field( unsigned long, clone_flags) | ||
__field( int, oom_score_adj) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->pid = task->pid; | ||
memcpy(__entry->comm, task->comm, TASK_COMM_LEN); | ||
__entry->clone_flags = clone_flags; | ||
__entry->oom_score_adj = task->signal->oom_score_adj; | ||
), | ||
|
||
TP_printk("pid=%d comm=%s clone_flags=%lx oom_score_adj=%d", | ||
__entry->pid, __entry->comm, | ||
__entry->clone_flags, __entry->oom_score_adj) | ||
); | ||
|
||
TRACE_EVENT(task_rename, | ||
|
||
TP_PROTO(struct task_struct *task, char *comm), | ||
|
||
TP_ARGS(task, comm), | ||
|
||
TP_STRUCT__entry( | ||
__field( pid_t, pid) | ||
__array( char, oldcomm, TASK_COMM_LEN) | ||
__array( char, newcomm, TASK_COMM_LEN) | ||
__field( int, oom_score_adj) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->pid = task->pid; | ||
memcpy(entry->oldcomm, task->comm, TASK_COMM_LEN); | ||
memcpy(entry->newcomm, comm, TASK_COMM_LEN); | ||
__entry->oom_score_adj = task->signal->oom_score_adj; | ||
), | ||
|
||
TP_printk("pid=%d oldcomm=%s newcomm=%s oom_score_adj=%d", | ||
__entry->pid, __entry->oldcomm, | ||
__entry->newcomm, __entry->oom_score_adj) | ||
); | ||
|
||
#endif | ||
|
||
/* This part must be outside protection */ | ||
#include <trace/define_trace.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters