linux-omap4-3.1.0: Add sched_process_exec tracing
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-omap4-3.1.0 / add_exec_tracepoint.patch
1 From 4ff16c25e2cc48cbe6956e356c38a25ac063a64d Mon Sep 17 00:00:00 2001
2 From: David Smith <dsmith@redhat.com>
3 Date: Tue, 7 Feb 2012 10:11:05 -0600
4 Subject: [PATCH] tracepoint, vfs, sched: Add exec() tracepoint
6 Added a minimal exec tracepoint. Exec is an important major event
7 in the life of a task, like fork(), clone() or exit(), all of
8 which we already trace.
10 [ We also do scheduling re-balancing during exec() - so it's useful
11   from a scheduler instrumentation POV as well. ]
13 If you want to watch a task start up, when it gets exec'ed is a good place
14 to start.  With the addition of this tracepoint, exec's can be monitored
15 and better picture of general system activity can be obtained. This
16 tracepoint will also enable better process life tracking, allowing you to
17 answer questions like "what process keeps starting up binary X?".
19 This tracepoint can also be useful in ftrace filtering and trigger
20 conditions: i.e. starting or stopping filtering when exec is called.
22 Signed-off-by: David Smith <dsmith@redhat.com>
23 Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
24 Cc: Steven Rostedt <rostedt@goodmis.org>
25 Cc: Christoph Hellwig <hch@infradead.org>
26 Cc: Al Viro <viro@zeniv.linux.org.uk>
27 Cc: Andrew Morton <akpm@linux-foundation.org>
28 Cc: Linus Torvalds <torvalds@linux-foundation.org>
29 Link: http://lkml.kernel.org/r/4F314D19.7030504@redhat.com
30 Signed-off-by: Ingo Molnar <mingo@elte.hu>
31 ---
32  fs/exec.c                    |    9 ++++++---
33  include/trace/events/sched.h |   27 +++++++++++++++++++++++++++
34  2 files changed, 33 insertions(+), 3 deletions(-)
36 diff --git a/fs/exec.c b/fs/exec.c
37 index aeb135c..d0d2080 100644
38 --- a/fs/exec.c
39 +++ b/fs/exec.c
40 @@ -63,6 +63,8 @@
41  #include <trace/events/task.h>
42  #include "internal.h"
43  
44 +#include <trace/events/sched.h>
45 +
46  int core_uses_pid;
47  char core_pattern[CORENAME_MAX_SIZE] = "core";
48  unsigned int core_pipe_limit;
49 @@ -1401,9 +1403,10 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
50                          */
51                         bprm->recursion_depth = depth;
52                         if (retval >= 0) {
53 -                               if (depth == 0)
54 -                                       ptrace_event(PTRACE_EVENT_EXEC,
55 -                                                       old_pid);
56 +                               if (depth == 0) {
57 +                                       trace_sched_process_exec(current, old_pid, bprm);
58 +                                       ptrace_event(PTRACE_EVENT_EXEC, old_pid);
59 +                               }
60                                 put_binfmt(fmt);
61                                 allow_write_access(bprm->file);
62                                 if (bprm->file)
63 diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
64 index 6ba596b..e61ddfe 100644
65 --- a/include/trace/events/sched.h
66 +++ b/include/trace/events/sched.h
67 @@ -6,6 +6,7 @@
68  
69  #include <linux/sched.h>
70  #include <linux/tracepoint.h>
71 +#include <linux/binfmts.h>
72  
73  /*
74   * Tracepoint for calling kthread_stop, performed to end a kthread:
75 @@ -276,6 +277,32 @@ TRACE_EVENT(sched_process_fork,
76  );
77  
78  /*
79 + * Tracepoint for exec:
80 + */
81 +TRACE_EVENT(sched_process_exec,
82 +
83 +       TP_PROTO(struct task_struct *p, pid_t old_pid,
84 +                struct linux_binprm *bprm),
85 +
86 +       TP_ARGS(p, old_pid, bprm),
87 +
88 +       TP_STRUCT__entry(
89 +               __string(       filename,       bprm->filename  )
90 +               __field(        pid_t,          pid             )
91 +               __field(        pid_t,          old_pid         )
92 +       ),
93 +
94 +       TP_fast_assign(
95 +               __assign_str(filename, bprm->filename);
96 +               __entry->pid            = p->pid;
97 +               __entry->old_pid        = p->pid;
98 +       ),
99 +
100 +       TP_printk("filename=%s pid=%d old_pid=%d", __get_str(filename),
101 +                 __entry->pid, __entry->old_pid)
102 +);
104 +/*
105   * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
106   *     adding sched_stat support to SCHED_FIFO/RR would be welcome.
107   */
108 -- 
109 1.7.6.5