diff options
| author | Adrian Hunter <adrian.hunter@intel.com> | 2014-05-28 04:45:04 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2014-06-06 01:56:22 -0400 |
| commit | 82b897782d10fcc4930c9d4a15b175348fdd2871 (patch) | |
| tree | 82bc0bb22ef1379b901d4fce582584b6776a91ea /include/linux | |
| parent | ec00010972a0971b2c1da4fbe4e5c7d8ed1ecb05 (diff) | |
perf: Differentiate exec() and non-exec() comm events
perf tools like 'perf report' can aggregate samples by comm strings,
which generally works. However, there are other potential use-cases.
For example, to pair up 'calls' with 'returns' accurately (from branch
events like Intel BTS) it is necessary to identify whether the process
has exec'd. Although a comm event is generated when an 'exec' happens
it is also generated whenever the comm string is changed on a whim
(e.g. by prctl PR_SET_NAME). This patch adds a flag to the comm event
to differentiate one case from the other.
In order to determine whether the kernel supports the new flag, a
selection bit named 'exec' is added to struct perf_event_attr. The
bit does nothing but will cause perf_event_open() to fail if the bit
is set on kernels that do not have it defined.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/537D9EBE.7030806@intel.com
Cc: Paul Mackerras <paulus@samba.org>
Cc: Dave Jones <davej@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/perf_event.h | 4 | ||||
| -rw-r--r-- | include/linux/sched.h | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index b4c1d4685bf0..707617a8c0f6 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
| @@ -707,7 +707,7 @@ extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks * | |||
| 707 | extern int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks); | 707 | extern int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks); |
| 708 | 708 | ||
| 709 | extern void perf_event_exec(void); | 709 | extern void perf_event_exec(void); |
| 710 | extern void perf_event_comm(struct task_struct *tsk); | 710 | extern void perf_event_comm(struct task_struct *tsk, bool exec); |
| 711 | extern void perf_event_fork(struct task_struct *tsk); | 711 | extern void perf_event_fork(struct task_struct *tsk); |
| 712 | 712 | ||
| 713 | /* Callchains */ | 713 | /* Callchains */ |
| @@ -815,7 +815,7 @@ static inline int perf_unregister_guest_info_callbacks | |||
| 815 | 815 | ||
| 816 | static inline void perf_event_mmap(struct vm_area_struct *vma) { } | 816 | static inline void perf_event_mmap(struct vm_area_struct *vma) { } |
| 817 | static inline void perf_event_exec(void) { } | 817 | static inline void perf_event_exec(void) { } |
| 818 | static inline void perf_event_comm(struct task_struct *tsk) { } | 818 | static inline void perf_event_comm(struct task_struct *tsk, bool exec) { } |
| 819 | static inline void perf_event_fork(struct task_struct *tsk) { } | 819 | static inline void perf_event_fork(struct task_struct *tsk) { } |
| 820 | static inline void perf_event_init(void) { } | 820 | static inline void perf_event_init(void) { } |
| 821 | static inline int perf_swevent_get_recursion_context(void) { return -1; } | 821 | static inline int perf_swevent_get_recursion_context(void) { return -1; } |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 221b2bde3723..ad86e1d7dbc2 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -2379,7 +2379,11 @@ extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, i | |||
| 2379 | struct task_struct *fork_idle(int); | 2379 | struct task_struct *fork_idle(int); |
| 2380 | extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); | 2380 | extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); |
| 2381 | 2381 | ||
| 2382 | extern void set_task_comm(struct task_struct *tsk, const char *from); | 2382 | extern void __set_task_comm(struct task_struct *tsk, const char *from, bool exec); |
| 2383 | static inline void set_task_comm(struct task_struct *tsk, const char *from) | ||
| 2384 | { | ||
| 2385 | __set_task_comm(tsk, from, false); | ||
| 2386 | } | ||
| 2383 | extern char *get_task_comm(char *to, struct task_struct *tsk); | 2387 | extern char *get_task_comm(char *to, struct task_struct *tsk); |
| 2384 | 2388 | ||
| 2385 | #ifdef CONFIG_SMP | 2389 | #ifdef CONFIG_SMP |
