perf script: Move evname print code to process_event()
Namhyung Kim
maintainerPATCH 1/3 perf script: Move evname print code to process_event()
The print_sample_start() will be reused by other printing routine for internal events like COMM, FORK and EXIT from next patch. And because they're not tied to a specific event, move the evname print code to its caller.
--- tools/perf/builtin-script.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
tools/perf/builtin-script.c +5 -6
@@ -288,7 +288,6 @@ static void print_sample_start(struct perf_sample *sample, struct perf_evsel *evsel) {struct perf_event_attr *attr = &evsel->attr; -const char *evname =NULL ;unsigned long secs;unsigned long usecs;unsigned long long nsecs;
@@ -323,11 +322,6 @@ static void print_sample_start(struct perf_sample *sample, usecs = nsecs /NSECS_PER_USEC ;printf ("%5lu.%06lu: " , secs, usecs); } - -if (PRINT_FIELD (EVNAME )) { - evname =perf_evsel__name (evsel); -printf ("%s: " , evname ? evname :"[unknown]" ); - } }static bool is_bts_event (struct perf_event_attr *attr)
@@ -434,6 +428,11 @@ static void process_event(union perf_event *event, struct perf_sample *sample,print_sample_start (sample, thread, evsel); +if (PRINT_FIELD (EVNAME )) { +const char *evname =perf_evsel__name (evsel); +printf ("%s: " , evname ? evname :"[unknown]" ); + } +if (is_bts_event (attr)) {print_sample_bts (event, sample, evsel, machine, thread);return ;
Signature · 1 line
1.7.11.7
Namhyung Kim
maintainerPATCH 2/3 perf script: Print comm, fork and exit events also
If --show-task option is given, also print internal COMM, FORK and EXIT events. It would be helpful for debugging.
--- tools/perf/Documentation/perf-script.txt | 3 + tools/perf/builtin-script.c | 110 +++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+)
tools/perf/Documentation/perf-script.txt +3 -0
@@ -203,6 +203,9 @@ OPTIONS --show-kernel-path:: Try to resolve the path of [kernel.kallsyms] +--show-task + Display task related events (e.g. FORK, COMM, EXIT). + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-script-perl[1],
tools/perf/builtin-script.c +110 -0
134 lines not on this page · raw message
Signature · 1 line
1.7.11.7
Re: [RFC/PATCH 2/3] perf script: Print comm, fork and exit events also
Quoted 28 lines · Namhyung Kim
tools/perf/builtin-script.c +24
-0@@ -578,6 +579,106 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,return perf_evsel__check_attr (evsel, scr->session); } +static int process_comm_event (struct perf_tool *tool, +union perf_event *event, +struct perf_sample *sample, +struct machine *machine) +{ +struct thread *thread; + struct perf_script *script = container_of(tool, struct perf_script, tool); +struct perf_session *session = script->session; +struct perf_evsel *evsel =perf_evlist__first (session->evlist); +char *oldname; + + thread =machine__findnew_thread (machine, event->comm.pid, event->comm.tid); +if (thread ==NULL ) { +pr_debug ("problem processing COMM event, skipping it.\n" ); +return -1 ; + } + + oldname =strdup (thread__comm_str (thread)); +if (oldname ==NULL ) { +pr_debug ("problem processing COMM event, skipping it.\n" ); +return -1 ; + } + +if (perf_event__process_comm (tool, event, sample, machine) <0 )
tools/perf/builtin-script.c static int process_attr(struct perf_tool *tool, union perf_event *event, · line 615
Quoted 10 lines
tools/perf/builtin-script.c +10
-0+return -1 ; + +if (!evsel->attr.sample_id_all) { + sample->cpu =0 ; + sample->time =0 ; + sample->tid = event->comm.tid; + sample->pid = event->comm.pid; + } +print_sample_start (sample, thread, evsel); +printf ("comm: %s --> %s\n" , oldname, event->comm.comm);
free(oldname)
David
Namhyung Kim
maintainerPATCH 3/3 perf script: Print mmap[2] events also
In reply to Namhyung KimIf --show-mmap option is given, also print internal MMAP and MMAP2 events. It would be helpful for debugging.
--- tools/perf/Documentation/perf-script.txt | 3 ++ tools/perf/builtin-script.c | 78 ++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+)
tools/perf/Documentation/perf-script.txt +3 -0
@@ -206,6 +206,9 @@ OPTIONS --show-task Display task related events (e.g. FORK, COMM, EXIT). +--show-mmap + Display mmap related events (e.g. MMAP, MMAP2). + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-script-perl[1],
tools/perf/builtin-script.c +78 -0
102 lines not on this page · raw message
Signature · 1 line
1.7.11.7
Re: [RFC/PATCH 3/3] perf script: Print mmap[2] events also
Quoted 5 lines · Namhyung Kim
If --show-mmap option is given, also print internal MMAP and MMAP2 events. It would be helpful for debugging.
Suggested-by Frederic Weisbecker <[email protected]>Signed-off-by Namhyung Kim <[email protected]>
Outside of the free following a strdup, the 3 patches looked good to me. Procrastination worked in my favor. Once these go in I'll do the move to perf-dump.
For all 3:
Namhyung Kim
maintainerRe: [RFC/PATCH 3/3] perf script: Print mmap[2] events also
Hi David,
Quoted 7 lines · David Ahern
Quoted 5 lines · Namhyung Kim
If --show-mmap option is given, also print internal MMAP and MMAP2 events. It would be helpful for debugging.
Suggested-by Frederic Weisbecker <[email protected]>Signed-off-by Namhyung Kim <[email protected]>
Quoted 6 lines
Outside of the free following a strdup, the 3 patches looked good to me. Procrastination worked in my favor. Once these go in I'll do the move to perf-dump.
For all 3:
Reviewed-by David Ahern <[email protected]>
Thank you for quick review!
I'll fix the bug you mentioned and resend.
Thanks,
Namhyung