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/evsel.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/evsel.c')
-rw-r--r-- | tools/perf/util/evsel.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 3612183e2cc5..0ce9febf1ba0 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -27,6 +27,7 @@ | |||
27 | static struct { | 27 | static struct { |
28 | bool sample_id_all; | 28 | bool sample_id_all; |
29 | bool exclude_guest; | 29 | bool exclude_guest; |
30 | bool mmap2; | ||
30 | } perf_missing_features; | 31 | } perf_missing_features; |
31 | 32 | ||
32 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) | 33 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) |
@@ -676,8 +677,9 @@ void perf_evsel__config(struct perf_evsel *evsel, | |||
676 | if (opts->sample_weight) | 677 | if (opts->sample_weight) |
677 | attr->sample_type |= PERF_SAMPLE_WEIGHT; | 678 | attr->sample_type |= PERF_SAMPLE_WEIGHT; |
678 | 679 | ||
679 | attr->mmap = track; | 680 | attr->mmap = track; |
680 | attr->comm = track; | 681 | attr->mmap2 = track && !perf_missing_features.mmap2; |
682 | attr->comm = track; | ||
681 | 683 | ||
682 | /* | 684 | /* |
683 | * XXX see the function comment above | 685 | * XXX see the function comment above |
@@ -1016,6 +1018,8 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, | |||
1016 | } | 1018 | } |
1017 | 1019 | ||
1018 | fallback_missing_features: | 1020 | fallback_missing_features: |
1021 | if (perf_missing_features.mmap2) | ||
1022 | evsel->attr.mmap2 = 0; | ||
1019 | if (perf_missing_features.exclude_guest) | 1023 | if (perf_missing_features.exclude_guest) |
1020 | evsel->attr.exclude_guest = evsel->attr.exclude_host = 0; | 1024 | evsel->attr.exclude_guest = evsel->attr.exclude_host = 0; |
1021 | retry_sample_id: | 1025 | retry_sample_id: |
@@ -1080,8 +1084,11 @@ try_fallback: | |||
1080 | if (err != -EINVAL || cpu > 0 || thread > 0) | 1084 | if (err != -EINVAL || cpu > 0 || thread > 0) |
1081 | goto out_close; | 1085 | goto out_close; |
1082 | 1086 | ||
1083 | if (!perf_missing_features.exclude_guest && | 1087 | if (!perf_missing_features.mmap2 && evsel->attr.mmap2) { |
1084 | (evsel->attr.exclude_guest || evsel->attr.exclude_host)) { | 1088 | perf_missing_features.mmap2 = true; |
1089 | goto fallback_missing_features; | ||
1090 | } else if (!perf_missing_features.exclude_guest && | ||
1091 | (evsel->attr.exclude_guest || evsel->attr.exclude_host)) { | ||
1085 | perf_missing_features.exclude_guest = true; | 1092 | perf_missing_features.exclude_guest = true; |
1086 | goto fallback_missing_features; | 1093 | goto fallback_missing_features; |
1087 | } else if (!perf_missing_features.sample_id_all) { | 1094 | } else if (!perf_missing_features.sample_id_all) { |
@@ -1925,6 +1932,7 @@ int perf_evsel__fprintf(struct perf_evsel *evsel, | |||
1925 | if_print(exclude_hv); | 1932 | if_print(exclude_hv); |
1926 | if_print(exclude_idle); | 1933 | if_print(exclude_idle); |
1927 | if_print(mmap); | 1934 | if_print(mmap); |
1935 | if_print(mmap2); | ||
1928 | if_print(comm); | 1936 | if_print(comm); |
1929 | if_print(freq); | 1937 | if_print(freq); |
1930 | if_print(inherit_stat); | 1938 | if_print(inherit_stat); |