linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tests vmlinux-kallsyms: ignore hidden symbols
@ 2021-07-08 12:28 Michael Petlan
  2021-07-13  9:57 ` Jiri Olsa
  2021-07-23  9:03 ` Michael Petlan
  0 siblings, 2 replies; 6+ messages in thread
From: Michael Petlan @ 2021-07-08 12:28 UTC (permalink / raw)
  To: linux-perf-users, acme; +Cc: jolsa

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.

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

diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index 193b7c91b4e2..11cd276ec8fd 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -14,6 +14,41 @@
 
 #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 +204,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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf tests vmlinux-kallsyms: ignore hidden symbols
  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
  1 sibling, 1 reply; 6+ messages in thread
From: Jiri Olsa @ 2021-07-13  9:57 UTC (permalink / raw)
  To: Michael Petlan; +Cc: linux-perf-users, acme

On Thu, Jul 08, 2021 at 02:28:05PM +0200, Michael Petlan wrote:
> 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.

there's also other arrays like ignored_suffixes, ignored_matches ...
should we have them as well? should we take the whole is_ignored_symbol
function?

> 
> 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.
> 
> Signed-off-by: Michael Petlan <mpetlan@redhat.com>
> ---
>  tools/perf/tests/vmlinux-kallsyms.c | 41 +++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
> index 193b7c91b4e2..11cd276ec8fd 100644
> --- a/tools/perf/tests/vmlinux-kallsyms.c
> +++ b/tools/perf/tests/vmlinux-kallsyms.c
> @@ -14,6 +14,41 @@
>  
>  #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;

please check your patch with scripts/checkpatch.pl before posting

thanks,
jirka


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf tests vmlinux-kallsyms: ignore hidden symbols
  2021-07-13  9:57 ` Jiri Olsa
@ 2021-07-23  8:54   ` Michael Petlan
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Petlan @ 2021-07-23  8:54 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: linux-perf-users, acme

On Tue, 13 Jul 2021, Jiri Olsa wrote:
> On Thu, Jul 08, 2021 at 02:28:05PM +0200, Michael Petlan wrote:
> > 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.
> 
> there's also other arrays like ignored_suffixes, ignored_matches ...
> should we have them as well? should we take the whole is_ignored_symbol
> function?

Well, maybe? There hasn't been a problem with the others yet... :-)

Arnaldo, should I do a v2 with the above?
> 
> > 
> > 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.
> > 
> > Signed-off-by: Michael Petlan <mpetlan@redhat.com>
> > ---
> >  tools/perf/tests/vmlinux-kallsyms.c | 41 +++++++++++++++++++++++++++++
> >  1 file changed, 41 insertions(+)
> > 
> > diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
> > index 193b7c91b4e2..11cd276ec8fd 100644
> > --- a/tools/perf/tests/vmlinux-kallsyms.c
> > +++ b/tools/perf/tests/vmlinux-kallsyms.c
> > @@ -14,6 +14,41 @@
> >  
> >  #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;
> 
> please check your patch with scripts/checkpatch.pl before posting
> 
> thanks,
> jirka
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] perf tests vmlinux-kallsyms: ignore hidden symbols
  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  9:03 ` Michael Petlan
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Petlan @ 2021-07-23  9:03 UTC (permalink / raw)
  To: linux-perf-users, jolsa; +Cc: acme

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf tests vmlinux-kallsyms: ignore hidden symbols
  2021-09-22 15:27 Michael Petlan
@ 2021-09-22 16:36 ` Ian Rogers
  0 siblings, 0 replies; 6+ messages in thread
From: Ian Rogers @ 2021-09-22 16:36 UTC (permalink / raw)
  To: Michael Petlan; +Cc: linux-perf-users, acme, jolsa

On Wed, Sep 22, 2021 at 8:27 AM Michael Petlan <mpetlan@redhat.com> wrote:
>
> Certain kernel symbols are purposely hidden from kallsyms. The function
> is_ignored_symbol() from scripts/kallsyms.c decides if a symbol should
> be hidden or not.
>
> 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 function is_ignored_symbol() has been copied from scripts/kallsyms.c
> and needs to be updated along with the original.
>
> Signed-off-by: Michael Petlan <mpetlan@redhat.com>

Acked-by: Ian Rogers <irogers@google.com>

It is a shame this can't be a library to ensure the function is kept in sync.

> ---
>  tools/perf/tests/vmlinux-kallsyms.c | 102 ++++++++++++++++++++++++++++
>  1 file changed, 102 insertions(+)
>
> diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
> index 193b7c91b4e2..4f884aabc7f4 100644
> --- a/tools/perf/tests/vmlinux-kallsyms.c
> +++ b/tools/perf/tests/vmlinux-kallsyms.c
> @@ -3,6 +3,7 @@
>  #include <linux/rbtree.h>
>  #include <inttypes.h>
>  #include <string.h>
> +#include <ctype.h>
>  #include <stdlib.h>
>  #include "dso.h"
>  #include "map.h"
> @@ -14,6 +15,102 @@
>
>  #define UM(x) kallsyms_map->unmap_ip(kallsyms_map, (x))
>
> +static bool is_ignored_symbol(const char *name, char type)
> +{
> +       /* Symbol names that exactly match to the following are ignored.*/
> +       static const char * const ignored_symbols[] = {
> +               /*
> +                * Symbols which vary between passes. Passes 1 and 2 must have
> +                * identical symbol lists. The kallsyms_* symbols below are
> +                * only added after pass 1, they would be included in pass 2
> +                * when --all-symbols is specified so exclude them to get a
> +                * stable symbol list.
> +                */
> +               "kallsyms_addresses",
> +               "kallsyms_offsets",
> +               "kallsyms_relative_base",
> +               "kallsyms_num_syms",
> +               "kallsyms_names",
> +               "kallsyms_markers",
> +               "kallsyms_token_table",
> +               "kallsyms_token_index",
> +               /* Exclude linker generated symbols which vary between passes */
> +               "_SDA_BASE_",           /* ppc */
> +               "_SDA2_BASE_",          /* ppc */

Do values like this belong behind an architecture #ifdef? I know
that's not currently the case in scripts/kallsyms.c.

> +               NULL
> +       };
> +
> +       /* Symbol names that begin with the following are ignored.*/
> +       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
> +       };
> +
> +       /* Symbol names that end with the following are ignored.*/
> +       static const char * const ignored_suffixes[] = {
> +               "_from_arm",            /* arm */
> +               "_from_thumb",          /* arm */
> +               "_veneer",              /* arm */
> +               NULL
> +       };
> +
> +       /* Symbol names that contain the following are ignored.*/
> +       static const char * const ignored_matches[] = {
> +               ".long_branch.",        /* ppc stub */
> +               ".plt_branch.",         /* ppc stub */
> +               NULL
> +       };
> +
> +       const char * const *p;
> +
> +       for (p = ignored_symbols; *p; p++)
> +               if (!strcmp(name, *p))
> +                       return true;
> +
> +       for (p = ignored_prefixes; *p; p++)
> +               if (!strncmp(name, *p, strlen(*p)))
> +                       return true;
> +
> +       for (p = ignored_suffixes; *p; p++) {
> +               int l = strlen(name) - strlen(*p);
> +
> +               if (l >= 0 && !strcmp(name + l, *p))
> +                       return true;
> +       }
> +
> +       for (p = ignored_matches; *p; p++) {
> +               if (strstr(name, *p))
> +                       return true;
> +       }
> +
> +       if (type == 'U' || type == 'u')
> +               return true;
> +       /* exclude debugging symbols */
> +       if (type == 'N' || type == 'n')
> +               return true;
> +
> +       if (toupper(type) == 'A') {
> +               /* Keep these useful absolute symbols */
> +               if (strcmp(name, "__kernel_syscall_via_break") &&
> +                   strcmp(name, "__kernel_syscall_via_epc") &&
> +                   strcmp(name, "__kernel_sigtramp") &&
> +                   strcmp(name, "__gp"))
> +                       return true;
> +       }
> +
> +       return false;
> +}
> +
>  int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest __maybe_unused)
>  {
>         int err = -1;
> @@ -169,6 +266,11 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest
>                          * such as __indirect_thunk_end.
>                          */
>                         continue;
> +               } else if (is_ignored_symbol(sym->name, sym->type)) {
> +                       /*
> +                        * Ignore hidden symbols, see scripts/kallsyms.c for the details
> +                        */
> +                       continue;
>                 } else {
>                         pr_debug("ERR : %#" PRIx64 ": %s not on kallsyms\n",
>                                  mem_start, sym->name);
> --
> 2.18.4
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] perf tests vmlinux-kallsyms: ignore hidden symbols
@ 2021-09-22 15:27 Michael Petlan
  2021-09-22 16:36 ` Ian Rogers
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Petlan @ 2021-09-22 15:27 UTC (permalink / raw)
  To: linux-perf-users, acme; +Cc: jolsa

Certain kernel symbols are purposely hidden from kallsyms. The function
is_ignored_symbol() from scripts/kallsyms.c decides if a symbol should
be hidden or not.

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 function is_ignored_symbol() has been copied from scripts/kallsyms.c
and needs to be updated along with the original.

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

diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index 193b7c91b4e2..4f884aabc7f4 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -3,6 +3,7 @@
 #include <linux/rbtree.h>
 #include <inttypes.h>
 #include <string.h>
+#include <ctype.h>
 #include <stdlib.h>
 #include "dso.h"
 #include "map.h"
@@ -14,6 +15,102 @@
 
 #define UM(x) kallsyms_map->unmap_ip(kallsyms_map, (x))
 
+static bool is_ignored_symbol(const char *name, char type)
+{
+	/* Symbol names that exactly match to the following are ignored.*/
+	static const char * const ignored_symbols[] = {
+		/*
+		 * Symbols which vary between passes. Passes 1 and 2 must have
+		 * identical symbol lists. The kallsyms_* symbols below are
+		 * only added after pass 1, they would be included in pass 2
+		 * when --all-symbols is specified so exclude them to get a
+		 * stable symbol list.
+		 */
+		"kallsyms_addresses",
+		"kallsyms_offsets",
+		"kallsyms_relative_base",
+		"kallsyms_num_syms",
+		"kallsyms_names",
+		"kallsyms_markers",
+		"kallsyms_token_table",
+		"kallsyms_token_index",
+		/* Exclude linker generated symbols which vary between passes */
+		"_SDA_BASE_",		/* ppc */
+		"_SDA2_BASE_",		/* ppc */
+		NULL
+	};
+
+	/* Symbol names that begin with the following are ignored.*/
+	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
+	};
+
+	/* Symbol names that end with the following are ignored.*/
+	static const char * const ignored_suffixes[] = {
+		"_from_arm",		/* arm */
+		"_from_thumb",		/* arm */
+		"_veneer",		/* arm */
+		NULL
+	};
+
+	/* Symbol names that contain the following are ignored.*/
+	static const char * const ignored_matches[] = {
+		".long_branch.",	/* ppc stub */
+		".plt_branch.",		/* ppc stub */
+		NULL
+	};
+
+	const char * const *p;
+
+	for (p = ignored_symbols; *p; p++)
+		if (!strcmp(name, *p))
+			return true;
+
+	for (p = ignored_prefixes; *p; p++)
+		if (!strncmp(name, *p, strlen(*p)))
+			return true;
+
+	for (p = ignored_suffixes; *p; p++) {
+		int l = strlen(name) - strlen(*p);
+
+		if (l >= 0 && !strcmp(name + l, *p))
+			return true;
+	}
+
+	for (p = ignored_matches; *p; p++) {
+		if (strstr(name, *p))
+			return true;
+	}
+
+	if (type == 'U' || type == 'u')
+		return true;
+	/* exclude debugging symbols */
+	if (type == 'N' || type == 'n')
+		return true;
+
+	if (toupper(type) == 'A') {
+		/* Keep these useful absolute symbols */
+		if (strcmp(name, "__kernel_syscall_via_break") &&
+		    strcmp(name, "__kernel_syscall_via_epc") &&
+		    strcmp(name, "__kernel_sigtramp") &&
+		    strcmp(name, "__gp"))
+			return true;
+	}
+
+	return false;
+}
+
 int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest __maybe_unused)
 {
 	int err = -1;
@@ -169,6 +266,11 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest
 			 * such as __indirect_thunk_end.
 			 */
 			continue;
+		} else if (is_ignored_symbol(sym->name, sym->type)) {
+			/*
+			 * Ignore hidden symbols, see scripts/kallsyms.c for the details
+			 */
+			continue;
 		} else {
 			pr_debug("ERR : %#" PRIx64 ": %s not on kallsyms\n",
 				 mem_start, sym->name);
-- 
2.18.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-22 16:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2021-09-22 15:27 Michael Petlan
2021-09-22 16:36 ` Ian Rogers

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox