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>
This commit is contained in:

committed by
Ingo Molnar

parent
ec00010972
commit
82b897782d
@@ -5090,7 +5090,7 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event)
|
||||
NULL);
|
||||
}
|
||||
|
||||
void perf_event_comm(struct task_struct *task)
|
||||
void perf_event_comm(struct task_struct *task, bool exec)
|
||||
{
|
||||
struct perf_comm_event comm_event;
|
||||
|
||||
@@ -5104,7 +5104,7 @@ void perf_event_comm(struct task_struct *task)
|
||||
.event_id = {
|
||||
.header = {
|
||||
.type = PERF_RECORD_COMM,
|
||||
.misc = 0,
|
||||
.misc = exec ? PERF_RECORD_MISC_COMM_EXEC : 0,
|
||||
/* .size */
|
||||
},
|
||||
/* .pid */
|
||||
|
Reference in New Issue
Block a user