All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <kafai@fb.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 07/12] perf tools: Check maps for bpf programs
Date: Tue, 16 Apr 2019 18:01:22 +0200	[thread overview]
Message-ID: <20190416160127.30203-8-jolsa@kernel.org> (raw)
In-Reply-To: <20190416160127.30203-1-jolsa@kernel.org>

From: Song Liu <songliubraving@fb.com>

As reported by Jiri Olsa in:

  "[BUG] perf: intel_pt won't display kernel function"
  https://lore.kernel.org/lkml/20190403143738.GB32001@krava

Recent changes to support PERF_RECORD_KSYMBOL and PERF_RECORD_BPF_EVENT
broke --kallsyms option. This is because it broke test __map__is_kmodule.

This patch fixes this by adding check for bpf program, so that these maps
are not mistaken as kernel modules.

Reported-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Fixes: 76193a94522f ("perf, bpf: Introduce PERF_RECORD_KSYMBOL")
Link: https://lore.kernel.org/lkml/20190403145353.GE32553@kernel.org

Signed-off-by: Song Liu <songliubraving@fb.com>
Link: http://lkml.kernel.org/n/tip-gnffkcoc4nauqcpgvsmwka2w@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/map.c | 16 ++++++++++++++++
 tools/perf/util/map.h |  4 +++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index e32628cd20a7..28d484ef74ae 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -261,6 +261,22 @@ bool __map__is_extra_kernel_map(const struct map *map)
 	return kmap && kmap->name[0];
 }
 
+bool __map__is_bpf_prog(const struct map *map)
+{
+	const char *name;
+
+	if (map->dso->binary_type == DSO_BINARY_TYPE__BPF_PROG_INFO)
+		return true;
+
+	/*
+	 * If PERF_RECORD_BPF_EVENT is not included, the dso will not have
+	 * type of DSO_BINARY_TYPE__BPF_PROG_INFO. In such cases, we can
+	 * guess the type based on name.
+	 */
+	name = map->dso->short_name;
+	return name && (strstr(name, "bpf_prog_") == name);
+}
+
 bool map__has_symbols(const struct map *map)
 {
 	return dso__has_symbols(map->dso);
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 0e20749f2c55..dc93787c74f0 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -159,10 +159,12 @@ int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name,
 
 bool __map__is_kernel(const struct map *map);
 bool __map__is_extra_kernel_map(const struct map *map);
+bool __map__is_bpf_prog(const struct map *map);
 
 static inline bool __map__is_kmodule(const struct map *map)
 {
-	return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map);
+	return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map) &&
+	       !__map__is_bpf_prog(map);
 }
 
 bool map__has_symbols(const struct map *map);
-- 
2.17.2


  parent reply	other threads:[~2019-04-16 16:02 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16 16:01 [PATCH 00/12] perf tools: Display eBPF code in intel_pt trace Jiri Olsa
2019-04-16 16:01 ` [PATCH 01/12] perf tools: Separate generic code in dso__data_file_size Jiri Olsa
2019-04-16 16:01 ` [PATCH 02/12] perf tools: Separate generic code in dso_cache__read Jiri Olsa
2019-04-16 17:17   ` Stanislav Fomichev
2019-04-16 18:21     ` Jiri Olsa
2019-04-16 16:01 ` [PATCH 03/12] perf tools: Simplify dso_cache__read function Jiri Olsa
2019-04-16 16:01 ` [PATCH 04/12] perf tools: Add bpf dso read and size hooks Jiri Olsa
2019-04-16 16:01 ` [PATCH 05/12] perf tools: Read also the end of the kernel Jiri Olsa
2019-04-16 16:01 ` [PATCH 06/12] perf tools: Do not erase uncovered maps by kcore Jiri Olsa
2019-04-23  9:32   ` Adrian Hunter
2019-04-23 14:55     ` Jiri Olsa
2019-04-16 16:01 ` Jiri Olsa [this message]
2019-04-16 19:31   ` [PATCH 07/12] perf tools: Check maps for bpf programs Arnaldo Carvalho de Melo
2019-04-19 17:18   ` [tip:perf/urgent] " tip-bot for Song Liu
2019-04-16 16:01 ` [PATCH 08/12] perf tools: Fix side band thread draining Jiri Olsa
2019-04-16 19:33   ` Arnaldo Carvalho de Melo
2019-04-16 20:41   ` Song Liu
2019-04-19 17:19   ` [tip:perf/urgent] perf evlist: " tip-bot for Jiri Olsa
2019-04-16 16:01 ` [PATCH 09/12] perf tools: Fix map reference counting Jiri Olsa
2019-04-16 19:36   ` Arnaldo Carvalho de Melo
2019-04-19 17:20   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2019-04-16 16:01 ` [PATCH 10/12] perf tools: Keep zero in pgoff bpf map Jiri Olsa
2019-04-16 16:01 ` [PATCH 11/12] perf tools: Reuse shared eBPF dso objects Jiri Olsa
2019-04-17  6:35   ` Adrian Hunter
2019-04-17  6:51     ` Jiri Olsa
2019-04-17  6:55       ` Adrian Hunter
2019-04-17  7:32         ` Jiri Olsa
2019-04-17 16:56           ` Song Liu
2019-04-16 16:01 ` [PATCH 12/12] perf script: Pad dso name for --call-trace Jiri Olsa

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=20190416160127.30203-8-jolsa@kernel.org \
    --to=jolsa@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.