From: Jiri Olsa <jolsa@redhat.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Michael Petlan <mpetlan@redhat.com>,
Ian Rogers <irogers@google.com>
Subject: [PATCH 09/10] perf report: Display build id fails stats
Date: Tue, 22 Jun 2021 17:39:17 +0200 [thread overview]
Message-ID: <20210622153918.688500-10-jolsa@kernel.org> (raw)
In-Reply-To: <20210622153918.688500-1-jolsa@kernel.org>
Adding support to display build id fails in --stats option:
# perf report --stat
Aggregated stats:
TOTAL events: 104
COMM events: 2 ( 1.9%)
....
BUILD_ID fails: 4 (14.3%)
This stat is displayed only for session recorded with --buildid-mmap
and contains HEADER_BUILD_ID_MMAP header feature.
We process all MMAP2 events and in case it does not contain build id
and it should - it's regular file, we count the BUILD_ID fail and
display it.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-report.c | 35 +++++++++++++++++++++++++++++++++++
tools/perf/util/map.h | 15 +++++++++++++++
2 files changed, 50 insertions(+)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index bc5c393021dc..b5c03bcc4395 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -13,6 +13,7 @@
#include "util/annotate.h"
#include "util/color.h"
#include "util/dso.h"
+#include "util/vdso.h"
#include <linux/list.h>
#include <linux/rbtree.h>
#include <linux/err.h>
@@ -100,6 +101,8 @@ struct report {
u64 nr_entries;
u64 queue_size;
u64 total_cycles;
+ u64 buildid_fails;
+ u64 buildid_total;
int socket_filter;
DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
struct branch_type_stat brtype_stat;
@@ -729,10 +732,36 @@ static int count_sample_event(struct perf_tool *tool __maybe_unused,
return 0;
}
+static int count_buildid_fails(struct perf_tool *tool,
+ union perf_event *event,
+ struct perf_sample *sample __maybe_unused,
+ struct machine *machine __maybe_unused)
+{
+ struct report *rep = container_of(tool, struct report, tool);
+ struct perf_record_mmap2 *mmap2 = &event->mmap2;
+
+ /* No build id should be generated */
+ if (!is_buildid_memory(mmap2->filename))
+ return 0;
+
+ rep->buildid_total++;
+
+ /* The build id should be generated, but wasn't - fault. */
+ if (!(mmap2->header.misc & PERF_RECORD_MISC_MMAP_BUILD_ID))
+ rep->buildid_fails++;
+
+ return 0;
+}
+
static void stats_setup(struct report *rep)
{
memset(&rep->tool, 0, sizeof(rep->tool));
rep->tool.sample = count_sample_event;
+
+ if (perf_header__has_feat(&rep->session->header,
+ HEADER_BUILD_ID_MMAP))
+ rep->tool.mmap2 = count_buildid_fails;
+
rep->tool.no_warn = true;
}
@@ -742,6 +771,12 @@ static int stats_print(struct report *rep)
perf_session__fprintf_nr_events(session, stdout, rep->skip_empty);
evlist__fprintf_nr_events(session->evlist, stdout, rep->skip_empty);
+
+ if (rep->buildid_fails) {
+ fprintf(stdout, "%23s: %10" PRIu64 " (%4.1f%%)\n", "BUILD_ID fails",
+ rep->buildid_fails,
+ 100.0 * rep->buildid_fails / rep->buildid_total);
+ }
return 0;
}
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index d32f5b28c1fb..9b96ebed412d 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -10,6 +10,7 @@
#include <string.h>
#include <stdbool.h>
#include <linux/types.h>
+#include "vdso.h"
struct dso;
struct maps;
@@ -186,4 +187,18 @@ static inline int is_no_dso_memory(const char *filename)
!strncmp(filename, "/SYSV", 5) ||
!strcmp(filename, "[heap]");
}
+
+static inline int is_vsyscall_memory(const char *filename)
+{
+ return !strcmp(filename, "[vsyscall]");
+}
+
+static inline int is_buildid_memory(const char *filename)
+{
+ return !is_anon_memory(filename) &&
+ !is_vdso_map(filename) &&
+ !is_no_dso_memory(filename) &&
+ !is_vsyscall_memory(filename);
+}
+
#endif /* __PERF_MAP_H */
--
2.31.1
next prev parent reply other threads:[~2021-06-22 15:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-22 15:39 [RFC 00/10] perf: Add build id parsing fault detection/fix Jiri Olsa
2021-06-22 15:39 ` [PATCH 01/10] perf: Track build id faults for mmap2 event Jiri Olsa
2021-06-22 15:39 ` [PATCH 02/10] perf: Move build_id_parse to check only regular files Jiri Olsa
2021-06-22 15:39 ` [PATCH 03/10] perf: Add new read_format bit to read build id faults Jiri Olsa
2021-06-22 15:39 ` [PATCH 04/10] perf: Add new read_format bit to read lost events Jiri Olsa
2021-06-22 15:39 ` [PATCH 05/10] tools: Sync perf_event.h uapi Jiri Olsa
2021-06-22 15:39 ` [PATCH 06/10] libperf: Do not allow PERF_FORMAT_GROUP in perf_evsel__read Jiri Olsa
2021-06-22 15:39 ` [PATCH 07/10] perf record: Add support to read build id fails Jiri Olsa
2021-06-22 15:39 ` [PATCH 08/10] perf record: Add new HEADER_BUILD_ID_MMAP feature Jiri Olsa
2021-06-22 15:39 ` Jiri Olsa [this message]
2021-06-22 15:39 ` [PATCH 10/10] perf inject: Add --buildid-mmap2 option to fix failed build ids Jiri Olsa
2021-06-22 17:39 ` [RFC 00/10] perf: Add build id parsing fault detection/fix Arnaldo Carvalho de Melo
2021-06-22 17:47 ` Ian Rogers
2021-06-22 18:14 ` Arnaldo Carvalho de Melo
2021-06-22 21:19 ` Jiri Olsa
2021-06-23 19:48 ` Namhyung Kim
2021-06-24 11:44 ` Michael Petlan
2021-06-27 17:27 ` Jiri Olsa
2021-06-27 17:25 ` Jiri Olsa
2021-06-28 3:39 ` Namhyung Kim
2021-06-23 20:15 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210622153918.688500-10-jolsa@kernel.org \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=mpetlan@redhat.com \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®