diff options
-rw-r--r-- | fs/exec.c | 4 | ||||
-rw-r--r-- | fs/proc/base.c | 3 | ||||
-rw-r--r-- | include/trace/events/oom.h | 33 | ||||
-rw-r--r-- | include/trace/events/task.h | 61 | ||||
-rw-r--r-- | kernel/fork.c | 6 | ||||
-rw-r--r-- | mm/oom_kill.c | 6 |
6 files changed, 113 insertions, 0 deletions
@@ -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 | ||
64 | int core_uses_pid; | 66 | int 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); | ||
1013 | err_sighand: | 1015 | err_sighand: |
1014 | unlock_task_sighand(task, &flags); | 1016 | unlock_task_sighand(task, &flags); |
1015 | err_task_lock: | 1017 | err_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. |
diff --git a/include/trace/events/oom.h b/include/trace/events/oom.h new file mode 100644 index 000000000000..dd4ba3b92002 --- /dev/null +++ b/include/trace/events/oom.h | |||
@@ -0,0 +1,33 @@ | |||
1 | #undef TRACE_SYSTEM | ||
2 | #define TRACE_SYSTEM oom | ||
3 | |||
4 | #if !defined(_TRACE_OOM_H) || defined(TRACE_HEADER_MULTI_READ) | ||
5 | #define _TRACE_OOM_H | ||
6 | #include <linux/tracepoint.h> | ||
7 | |||
8 | TRACE_EVENT(oom_score_adj_update, | ||
9 | |||
10 | TP_PROTO(struct task_struct *task), | ||
11 | |||
12 | TP_ARGS(task), | ||
13 | |||
14 | TP_STRUCT__entry( | ||
15 | __field( pid_t, pid) | ||
16 | __array( char, comm, TASK_COMM_LEN ) | ||
17 | __field( int, oom_score_adj) | ||
18 | ), | ||
19 | |||
20 | TP_fast_assign( | ||
21 | __entry->pid = task->pid; | ||
22 | memcpy(__entry->comm, task->comm, TASK_COMM_LEN); | ||
23 | __entry->oom_score_adj = task->signal->oom_score_adj; | ||
24 | ), | ||
25 | |||
26 | TP_printk("pid=%d comm=%s oom_score_adj=%d", | ||
27 | __entry->pid, __entry->comm, __entry->oom_score_adj) | ||
28 | ); | ||
29 | |||
30 | #endif | ||
31 | |||
32 | /* This part must be outside protection */ | ||
33 | #include <trace/define_trace.h> | ||
diff --git a/include/trace/events/task.h b/include/trace/events/task.h new file mode 100644 index 000000000000..b53add02e929 --- /dev/null +++ b/include/trace/events/task.h | |||
@@ -0,0 +1,61 @@ | |||
1 | #undef TRACE_SYSTEM | ||
2 | #define TRACE_SYSTEM task | ||
3 | |||
4 | #if !defined(_TRACE_TASK_H) || defined(TRACE_HEADER_MULTI_READ) | ||
5 | #define _TRACE_TASK_H | ||
6 | #include <linux/tracepoint.h> | ||
7 | |||
8 | TRACE_EVENT(task_newtask, | ||
9 | |||
10 | TP_PROTO(struct task_struct *task, unsigned long clone_flags), | ||
11 | |||
12 | TP_ARGS(task, clone_flags), | ||
13 | |||
14 | TP_STRUCT__entry( | ||
15 | __field( pid_t, pid) | ||
16 | __array( char, comm, TASK_COMM_LEN) | ||
17 | __field( unsigned long, clone_flags) | ||
18 | __field( int, oom_score_adj) | ||
19 | ), | ||
20 | |||
21 | TP_fast_assign( | ||
22 | __entry->pid = task->pid; | ||
23 | memcpy(__entry->comm, task->comm, TASK_COMM_LEN); | ||
24 | __entry->clone_flags = clone_flags; | ||
25 | __entry->oom_score_adj = task->signal->oom_score_adj; | ||
26 | ), | ||
27 | |||
28 | TP_printk("pid=%d comm=%s clone_flags=%lx oom_score_adj=%d", | ||
29 | __entry->pid, __entry->comm, | ||
30 | __entry->clone_flags, __entry->oom_score_adj) | ||
31 | ); | ||
32 | |||
33 | TRACE_EVENT(task_rename, | ||
34 | |||
35 | TP_PROTO(struct task_struct *task, char *comm), | ||
36 | |||
37 | TP_ARGS(task, comm), | ||
38 | |||
39 | TP_STRUCT__entry( | ||
40 | __field( pid_t, pid) | ||
41 | __array( char, oldcomm, TASK_COMM_LEN) | ||
42 | __array( char, newcomm, TASK_COMM_LEN) | ||
43 | __field( int, oom_score_adj) | ||
44 | ), | ||
45 | |||
46 | TP_fast_assign( | ||
47 | __entry->pid = task->pid; | ||
48 | memcpy(entry->oldcomm, task->comm, TASK_COMM_LEN); | ||
49 | memcpy(entry->newcomm, comm, TASK_COMM_LEN); | ||
50 | __entry->oom_score_adj = task->signal->oom_score_adj; | ||
51 | ), | ||
52 | |||
53 | TP_printk("pid=%d oldcomm=%s newcomm=%s oom_score_adj=%d", | ||
54 | __entry->pid, __entry->oldcomm, | ||
55 | __entry->newcomm, __entry->oom_score_adj) | ||
56 | ); | ||
57 | |||
58 | #endif | ||
59 | |||
60 | /* This part must be outside protection */ | ||
61 | #include <trace/define_trace.h> | ||
diff --git a/kernel/fork.c b/kernel/fork.c index b00711ce7c13..5e1391b5ade0 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -76,6 +76,9 @@ | |||
76 | 76 | ||
77 | #include <trace/events/sched.h> | 77 | #include <trace/events/sched.h> |
78 | 78 | ||
79 | #define CREATE_TRACE_POINTS | ||
80 | #include <trace/events/task.h> | ||
81 | |||
79 | /* | 82 | /* |
80 | * Protected counters by write_lock_irq(&tasklist_lock) | 83 | * Protected counters by write_lock_irq(&tasklist_lock) |
81 | */ | 84 | */ |
@@ -1370,6 +1373,9 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1370 | if (clone_flags & CLONE_THREAD) | 1373 | if (clone_flags & CLONE_THREAD) |
1371 | threadgroup_change_end(current); | 1374 | threadgroup_change_end(current); |
1372 | perf_event_fork(p); | 1375 | perf_event_fork(p); |
1376 | |||
1377 | trace_task_newtask(p, clone_flags); | ||
1378 | |||
1373 | return p; | 1379 | return p; |
1374 | 1380 | ||
1375 | bad_fork_free_pid: | 1381 | bad_fork_free_pid: |
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index eeb27e27dce3..7c122faa05c5 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
@@ -33,6 +33,10 @@ | |||
33 | #include <linux/security.h> | 33 | #include <linux/security.h> |
34 | #include <linux/ptrace.h> | 34 | #include <linux/ptrace.h> |
35 | #include <linux/freezer.h> | 35 | #include <linux/freezer.h> |
36 | #include <linux/ftrace.h> | ||
37 | |||
38 | #define CREATE_TRACE_POINTS | ||
39 | #include <trace/events/oom.h> | ||
36 | 40 | ||
37 | int sysctl_panic_on_oom; | 41 | int sysctl_panic_on_oom; |
38 | int sysctl_oom_kill_allocating_task; | 42 | int sysctl_oom_kill_allocating_task; |
@@ -55,6 +59,7 @@ void compare_swap_oom_score_adj(int old_val, int new_val) | |||
55 | spin_lock_irq(&sighand->siglock); | 59 | spin_lock_irq(&sighand->siglock); |
56 | if (current->signal->oom_score_adj == old_val) | 60 | if (current->signal->oom_score_adj == old_val) |
57 | current->signal->oom_score_adj = new_val; | 61 | current->signal->oom_score_adj = new_val; |
62 | trace_oom_score_adj_update(current); | ||
58 | spin_unlock_irq(&sighand->siglock); | 63 | spin_unlock_irq(&sighand->siglock); |
59 | } | 64 | } |
60 | 65 | ||
@@ -74,6 +79,7 @@ int test_set_oom_score_adj(int new_val) | |||
74 | spin_lock_irq(&sighand->siglock); | 79 | spin_lock_irq(&sighand->siglock); |
75 | old_val = current->signal->oom_score_adj; | 80 | old_val = current->signal->oom_score_adj; |
76 | current->signal->oom_score_adj = new_val; | 81 | current->signal->oom_score_adj = new_val; |
82 | trace_oom_score_adj_update(current); | ||
77 | spin_unlock_irq(&sighand->siglock); | 83 | spin_unlock_irq(&sighand->siglock); |
78 | 84 | ||
79 | return old_val; | 85 | return old_val; |