diff options
author | Stephane Eranian <eranian@google.com> | 2013-08-21 06:10:25 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-09-11 09:09:32 -0400 |
commit | 5c5e854bc760a2e2c878df3cfcf2afa4febcd511 (patch) | |
tree | cc0c44e8d8d9804f30c90f067d08c6cb4c9565ac /tools/perf/util/session.c | |
parent | e71aa28312b208a14cd87fa61e941ac8c85072f4 (diff) |
perf tools: Add attr->mmap2 support
This patch adds support for the new PERF_RECORD_MMAP2 record type
exposed by the kernel. This is an extended PERF_RECORD_MMAP record.
It adds for each file-backed mapping the device major, minor number and
the inode number and generation.
This triplet uniquely identifies the source of a file-backed mapping. It
can be used to detect identical virtual mappings between processes, for
instance.
The patch will prefer MMAP2 over MMAP.
Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1377079825-19057-3-git-send-email-eranian@google.com
[ Cope with 314add6 "Change machine__findnew_thread() to set thread pid",
fix 'perf test' regression test entry affected,
use perf_missing_features.mmap2 to fallback to not using .mmap2 in older kernels,
so that new tools can work with kernels where this feature is not present ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r-- | tools/perf/util/session.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 0308d9ee7a77..51f5edf2a6d0 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -351,6 +351,25 @@ static void perf_event__mmap_swap(union perf_event *event, | |||
351 | } | 351 | } |
352 | } | 352 | } |
353 | 353 | ||
354 | static void perf_event__mmap2_swap(union perf_event *event, | ||
355 | bool sample_id_all) | ||
356 | { | ||
357 | event->mmap2.pid = bswap_32(event->mmap2.pid); | ||
358 | event->mmap2.tid = bswap_32(event->mmap2.tid); | ||
359 | event->mmap2.start = bswap_64(event->mmap2.start); | ||
360 | event->mmap2.len = bswap_64(event->mmap2.len); | ||
361 | event->mmap2.pgoff = bswap_64(event->mmap2.pgoff); | ||
362 | event->mmap2.maj = bswap_32(event->mmap2.maj); | ||
363 | event->mmap2.min = bswap_32(event->mmap2.min); | ||
364 | event->mmap2.ino = bswap_64(event->mmap2.ino); | ||
365 | |||
366 | if (sample_id_all) { | ||
367 | void *data = &event->mmap2.filename; | ||
368 | |||
369 | data += PERF_ALIGN(strlen(data) + 1, sizeof(u64)); | ||
370 | swap_sample_id_all(event, data); | ||
371 | } | ||
372 | } | ||
354 | static void perf_event__task_swap(union perf_event *event, bool sample_id_all) | 373 | static void perf_event__task_swap(union perf_event *event, bool sample_id_all) |
355 | { | 374 | { |
356 | event->fork.pid = bswap_32(event->fork.pid); | 375 | event->fork.pid = bswap_32(event->fork.pid); |
@@ -455,6 +474,7 @@ typedef void (*perf_event__swap_op)(union perf_event *event, | |||
455 | 474 | ||
456 | static perf_event__swap_op perf_event__swap_ops[] = { | 475 | static perf_event__swap_op perf_event__swap_ops[] = { |
457 | [PERF_RECORD_MMAP] = perf_event__mmap_swap, | 476 | [PERF_RECORD_MMAP] = perf_event__mmap_swap, |
477 | [PERF_RECORD_MMAP2] = perf_event__mmap2_swap, | ||
458 | [PERF_RECORD_COMM] = perf_event__comm_swap, | 478 | [PERF_RECORD_COMM] = perf_event__comm_swap, |
459 | [PERF_RECORD_FORK] = perf_event__task_swap, | 479 | [PERF_RECORD_FORK] = perf_event__task_swap, |
460 | [PERF_RECORD_EXIT] = perf_event__task_swap, | 480 | [PERF_RECORD_EXIT] = perf_event__task_swap, |
@@ -851,7 +871,8 @@ static struct machine * | |||
851 | (cpumode == PERF_RECORD_MISC_GUEST_USER))) { | 871 | (cpumode == PERF_RECORD_MISC_GUEST_USER))) { |
852 | u32 pid; | 872 | u32 pid; |
853 | 873 | ||
854 | if (event->header.type == PERF_RECORD_MMAP) | 874 | if (event->header.type == PERF_RECORD_MMAP |
875 | || event->header.type == PERF_RECORD_MMAP2) | ||
855 | pid = event->mmap.pid; | 876 | pid = event->mmap.pid; |
856 | else | 877 | else |
857 | pid = sample->pid; | 878 | pid = sample->pid; |
@@ -978,6 +999,8 @@ static int perf_session_deliver_event(struct perf_session *session, | |||
978 | sample, evsel, machine); | 999 | sample, evsel, machine); |
979 | case PERF_RECORD_MMAP: | 1000 | case PERF_RECORD_MMAP: |
980 | return tool->mmap(tool, event, sample, machine); | 1001 | return tool->mmap(tool, event, sample, machine); |
1002 | case PERF_RECORD_MMAP2: | ||
1003 | return tool->mmap2(tool, event, sample, machine); | ||
981 | case PERF_RECORD_COMM: | 1004 | case PERF_RECORD_COMM: |
982 | return tool->comm(tool, event, sample, machine); | 1005 | return tool->comm(tool, event, sample, machine); |
983 | case PERF_RECORD_FORK: | 1006 | case PERF_RECORD_FORK: |