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 /fs | |
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 'fs')
-rw-r--r-- | fs/exec.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1046,13 +1046,13 @@ EXPORT_SYMBOL_GPL(get_task_comm); | |||
1046 | * so that a new one can be started | 1046 | * so that a new one can be started |
1047 | */ | 1047 | */ |
1048 | 1048 | ||
1049 | void set_task_comm(struct task_struct *tsk, const char *buf) | 1049 | void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec) |
1050 | { | 1050 | { |
1051 | task_lock(tsk); | 1051 | task_lock(tsk); |
1052 | trace_task_rename(tsk, buf); | 1052 | trace_task_rename(tsk, buf); |
1053 | strlcpy(tsk->comm, buf, sizeof(tsk->comm)); | 1053 | strlcpy(tsk->comm, buf, sizeof(tsk->comm)); |
1054 | task_unlock(tsk); | 1054 | task_unlock(tsk); |
1055 | perf_event_comm(tsk); | 1055 | perf_event_comm(tsk, exec); |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | int flush_old_exec(struct linux_binprm * bprm) | 1058 | int flush_old_exec(struct linux_binprm * bprm) |
@@ -1111,7 +1111,7 @@ void setup_new_exec(struct linux_binprm * bprm) | |||
1111 | set_dumpable(current->mm, suid_dumpable); | 1111 | set_dumpable(current->mm, suid_dumpable); |
1112 | 1112 | ||
1113 | perf_event_exec(); | 1113 | perf_event_exec(); |
1114 | set_task_comm(current, kbasename(bprm->filename)); | 1114 | __set_task_comm(current, kbasename(bprm->filename), true); |
1115 | 1115 | ||
1116 | /* Set the new mm task size. We have to do that late because it may | 1116 | /* Set the new mm task size. We have to do that late because it may |
1117 | * depend on TIF_32BIT which is only updated in flush_thread() on | 1117 | * depend on TIF_32BIT which is only updated in flush_thread() on |