linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Petlan <mpetlan@redhat.com>
To: linux-perf-users@vger.kernel.org, jolsa@redhat.com
Cc: acme@kernel.org
Subject: [PATCH] perf tests vmlinux-kallsyms: ignore hidden symbols
Date: Fri, 23 Jul 2021 11:03:51 +0200	[thread overview]
Message-ID: <20210723090351.6621-1-mpetlan@redhat.com> (raw)
In-Reply-To: <20210708122805.2832-1-mpetlan@redhat.com>

Symbols containing particular prefixes are purposely hidden from kallsyms.
The prefixes are listed in scripts/kallsyms.c, using ignored_prefixes[]
string array. The perf test "vmlinux symtab matches kallsyms" fails in
case perf finds some of the hidden symbols in its machine image and can't
match them to kallsyms.

Let's add a filter to check if a symbol not found isn't one of these before
failing the test.

The ignored_prefixes[] array has been copied from scripts/kallsyms.c and
needs to be updated along with the original.

v2: Fixed formatting issues.

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
---
 tools/perf/tests/vmlinux-kallsyms.c | 42 +++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index 193b7c91b4e2..fb9696bbf6f3 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -14,6 +14,42 @@
 
 #define UM(x) kallsyms_map->unmap_ip(kallsyms_map, (x))
 
+/* Symbol names that begin with the following are ignored. (a copy from scripts/kallsyms.c) */
+static const char * const ignored_prefixes[] = {
+	"$",			/* local symbols for ARM, MIPS, etc. */
+	".LASANPC",		/* s390 kasan local symbols */
+	"__crc_",		/* modversions */
+	"__efistub_",		/* arm64 EFI stub namespace */
+	"__kvm_nvhe_",		/* arm64 non-VHE KVM namespace */
+	"__AArch64ADRPThunk_",	/* arm64 lld */
+	"__ARMV5PILongThunk_",	/* arm lld */
+	"__ARMV7PILongThunk_",
+	"__ThumbV7PILongThunk_",
+	"__LA25Thunk_",		/* mips lld */
+	"__microLA25Thunk_",
+	NULL
+};
+
+static int has_prefix(const char *prefix, const char *string)
+{
+	while (*prefix)
+		if (*prefix++ != *string++)
+			return 0;
+
+	return 1;
+}
+
+static int should_be_hidden(const char *sym_name)
+{
+	int i;
+
+	for (i = 0; ignored_prefixes[i] != NULL; i++)
+		if (has_prefix(ignored_prefixes[i], sym_name))
+			return 1;
+
+	return 0;
+}
+
 int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest __maybe_unused)
 {
 	int err = -1;
@@ -169,6 +205,12 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest
 			 * such as __indirect_thunk_end.
 			 */
 			continue;
+		} else if (should_be_hidden(sym->name)) {
+			/*
+			 * Ignore hidden symbols, see scripts/kallsyms.c for the ignored_prefixes[]
+			 * array
+			 */
+			continue;
 		} else {
 			pr_debug("ERR : %#" PRIx64 ": %s not on kallsyms\n",
 				 mem_start, sym->name);
-- 
2.18.4


  parent reply	other threads:[~2021-07-23  9:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08 12:28 [PATCH] perf tests vmlinux-kallsyms: ignore hidden symbols Michael Petlan
2021-07-13  9:57 ` Jiri Olsa
2021-07-23  8:54   ` Michael Petlan
2021-07-23  9:03 ` Michael Petlan [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-09-22 15:27 Michael Petlan
2021-09-22 16:36 ` Ian Rogers
2021-09-29 17:14   ` Arnaldo Carvalho de Melo
2021-09-29 21:10   ` Arnaldo Carvalho de Melo

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=20210723090351.6621-1-mpetlan@redhat.com \
    --to=mpetlan@redhat.com \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-perf-users@vger.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;
as well as URLs for NNTP newsgroup(s).