[PATCH 01/16] perf top: Consider PERF_RECORD_ events with cpumode == 0

From: Arnaldo Carvalho de Melo
Date: Tue Apr 07 2015 - 12:41:21 EST


From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

Some events (PERF_RECORD_COMM,EXEC,EXIT,etc) don't set
perf_event_attr.misc with the PERF_RECORD_MISC_ bits in
PERF_RECORD_MISC_CPUMODE_MASK, and were being discarded, for those we
need just to set the machine to be used to be machines.host.

Even with those events not being considered 'top' worked because it
would create thread structs by means of machine__findnew_thread() when
processing a sample or PERF_RECORD_MMAP event, that sets the field to
PERF_RECORD_MISC_USER, and thus we could find the DSO where samples took
place, resolve IPs to symbols, etc.

But the effect was that the threads would remain in machines->threads
forever, slowly using more and more memory and making the thread lookup
to take longer than needed, fix it.

Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxx>
Cc: David Ahern <dsahern@xxxxxxxxx>
Cc: Don Zickus <dzickus@xxxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Stephane Eranian <eranian@xxxxxxxxxx>
Link: http://lkml.kernel.org/n/tip-pzzsmdr4ljsso771ul83ij1f@xxxxxxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/builtin-top.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 1cb3436276d1..67349fdc51d8 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -832,6 +832,12 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
++top->kernel_samples;
if (top->hide_kernel_symbols)
goto next_event;
+ /* Fall thru */
+ default:
+ /*
+ * For events that don't set the cpumode, like:
+ * PERF_RECORD_{COMM,FORK,EXIT,THROTTLE,UNTHROTTLE}
+ */
machine = &session->machines.host;
break;
case PERF_RECORD_MISC_GUEST_KERNEL:
@@ -845,8 +851,6 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
* TODO: we don't process guest user from host side
* except simple counting.
*/
- /* Fall thru */
- default:
goto next_event;
}

--
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/