perf symbol: ignore $a/$d symbols for ARM modules
Subsystems (2)
PATCH 1/1 perf symbol: ignore $a/$d symbols for ARM modules
On ARM machine, kernel symbols from modules can be resolved to $a instead of printing the actual symbol name. Ignore symbols starting with "$" when building kallsyms rbtree.
A sample stacktrace is shown as follows:
c0f2e39c schedule_hrtimeout+0x14 ([kernel.kallsyms]) bf4a66d8 $a+0x78 ([test_module])c0a4f5f4 kthread+0x15c ([kernel.kallsyms]) c0a001f8 ret_from_fork+0x14 ([kernel.kallsyms])
On ARM machine, $a/$d symbols are used by the compiler to mark the beginning of code/data part in code section. These symbols are filtered out when linking vmlinux(see scripts/kallsyms.c ignored_prefixes), but are left on modules. So there are $a symbols in /proc/kallsyms which share the same addresses with the actual module symbols and confuses perf when resolving symbols.
After this patch, the module symbol name is printed:
c0f2e39c schedule_hrtimeout+0x14 ([kernel.kallsyms]) bf4a66d8 test_func+0x78 ([test_module]) c0a4f5f4 kthread+0x15c ([kernel.kallsyms]) c0a001f8 ret_from_fork+0x14 ([kernel.kallsyms])
--- tools/perf/util/symbol.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/perf/util/symbol.c +4 -0
@@ -702,6 +702,10 @@ static int map__process_kallsym_symbol(void *arg, const char *name,if (!symbol_type__filter (type))return 0 ; +/* Ignore local symbols for ARM modules */ +if (name[0 ] =='$' ) +return 0 ; +/* * module symbols are not sorted so we add all * symbols, setting length to 0, and rely on
Signature · 1 line
2.12.3
Quoted 11 lines · Lexi Shao
On ARM machine, kernel symbols from modules can be resolved to $a instead of printing the actual symbol name. Ignore symbols starting with "$" when building kallsyms rbtree.
A sample stacktrace is shown as follows:
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8$a+0x78 ([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])
Quoted 6 lines
On ARM machine, $a/$d symbols are used by the compiler to mark the beginning of code/data part in code section. These symbols are filtered out when linking
vmlinux(see scripts/kallsyms.c ignored_prefixes), but are left on modules. So there are $a symbols in/proc/kallsymswhich share the same addresses with the actual module symbols and confuses perf when resolving symbols.
Hi Lexi,
Is it worth using or re-implementing the entire is_ignored_symbol() function from scripts/kallsyms.c? It seems like this change only fixes one occurrence, but is_ignored_symbol() has a big list of other cases.
Unless those cases are different?
Thanks
James
Quoted 29 lines
After this patch, the module symbol name is printed:
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8test_func+0x78([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])Signed-off-by Lexi Shao <[email protected]>--- tools/perf/util/symbol.c | 4 ++++ 1 file changed, 4 insertions(+)tools/perf/util/symbol.c +4
-0@@ -702,6 +702,10 @@ static int map__process_kallsym_symbol(void *arg, const char *name,if (!symbol_type__filter (type))return 0 ; +/* Ignore local symbols for ARM modules */ +if (name[0 ] =='$' ) +return 0 ; +/* * module symbols are not sorted so we add all * symbols, setting length to 0, and rely on
Quoted 21 lines · James Clark
Quoted 11 lines · Lexi Shao
On ARM machine, kernel symbols from modules can be resolved to $a instead of printing the actual symbol name. Ignore symbols starting with "$" when building kallsyms rbtree.
A sample stacktrace is shown as follows:
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8$a+0x78 ([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])Quoted 6 lines
On ARM machine, $a/$d symbols are used by the compiler to mark the beginning of code/data part in code section. These symbols are filtered out when linking
vmlinux(see scripts/kallsyms.c ignored_prefixes), but are left on modules. So there are $a symbols in/proc/kallsymswhich share the same addresses with the actual module symbols and confuses perf when resolving symbols.Hi Lexi,
Quoted 8 lines
Is it worth using or re-implementing the entire
is_ignored_symbol()function fromscripts/kallsyms.c? It seems like this change only fixes one occurrence, butis_ignored_symbol()has a big list of other cases.Unless those cases are different?
Thanks
James
Hi James,
I don't think it's necessary to cover all the cases listed in is_ignored_symbol(). As long as the symbols are unique and not overlapping with each other, they should't cause problems in resolving symbols. So most of the cases in is_ignored_symbol() should be irrelevant.
Lexi
Quoted 31 lines
Quoted 30 lines
After this patch, the module symbol name is printed:
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8test_func+0x78([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])Signed-off-by Lexi Shao <[email protected]>--- tools/perf/util/symbol.c | 4 ++++ 1 file changed, 4 insertions(+)tools/perf/util/symbol.c +4
-0@@ -702,6 +702,10 @@ static int map__process_kallsym_symbol(void *arg, const char *name,if (!symbol_type__filter (type))return 0 ; +/* Ignore local symbols for ARM modules */ +if (name[0 ] =='$' ) +return 0 ; +/* * module symbols are not sorted so we add all * symbols, setting length to 0, and rely on
Quoted 31 lines · Lexi Shao
Quoted 21 lines · James Clark
Quoted 11 lines · Lexi Shao
On ARM machine, kernel symbols from modules can be resolved to $a instead of printing the actual symbol name. Ignore symbols starting with "$" when building kallsyms rbtree.
A sample stacktrace is shown as follows:
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8$a+0x78 ([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])Quoted 6 lines
On ARM machine, $a/$d symbols are used by the compiler to mark the beginning of code/data part in code section. These symbols are filtered out when linking
vmlinux(see scripts/kallsyms.c ignored_prefixes), but are left on modules. So there are $a symbols in/proc/kallsymswhich share the same addresses with the actual module symbols and confuses perf when resolving symbols.Hi Lexi,
Quoted 8 lines
Is it worth using or re-implementing the entire
is_ignored_symbol()function fromscripts/kallsyms.c? It seems like this change only fixes one occurrence, butis_ignored_symbol()has a big list of other cases.Unless those cases are different?
Thanks
James
Quoted 6 lines
Hi James,
I don't think it's necessary to cover all the cases listed in
is_ignored_symbol(). As long as the symbols are unique and not overlapping with each other, they should't cause problems in resolving symbols. So most of the cases inis_ignored_symbol()should be irrelevant.
Is it possible to do the filtering of the module symbols somewhere else like in kernel/kallsyms.c? I'm not that familiar with it but it seems like at one point when populating kallsyms '$...' functions are filtered out, but when modules are loaded the symbols are not filtered because another code path is used?
If kallsyms has some duplicate addresses in there then isn't the bug in kallsyms rather than perf? And another tool could get confused too.
James
Quoted 34 lines
Lexi
Quoted 31 lines
Quoted 30 lines
After this patch, the module symbol name is printed:
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8test_func+0x78([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])Signed-off-by Lexi Shao <[email protected]>--- tools/perf/util/symbol.c | 4 ++++ 1 file changed, 4 insertions(+)tools/perf/util/symbol.c +4
-0@@ -702,6 +702,10 @@ static int map__process_kallsym_symbol(void *arg, const char *name,if (!symbol_type__filter (type))return 0 ; +/* Ignore local symbols for ARM modules */ +if (name[0 ] =='$' ) +return 0 ; +/* * module symbols are not sorted so we add all * symbols, setting length to 0, and rely on
Quoted 45 lines · James Clark
Quoted 31 lines · Lexi Shao
Quoted 21 lines · James Clark
Quoted 11 lines · Lexi Shao
On ARM machine, kernel symbols from modules can be resolved to $a instead of printing the actual symbol name. Ignore symbols starting with "$" when building kallsyms rbtree.
A sample stacktrace is shown as follows:
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8$a+0x78 ([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])Quoted 6 lines
On ARM machine, $a/$d symbols are used by the compiler to mark the beginning of code/data part in code section. These symbols are filtered out when linking
vmlinux(see scripts/kallsyms.c ignored_prefixes), but are left on modules. So there are $a symbols in/proc/kallsymswhich share the same addresses with the actual module symbols and confuses perf when resolving symbols.Hi Lexi,
Quoted 8 lines
Is it worth using or re-implementing the entire
is_ignored_symbol()function fromscripts/kallsyms.c? It seems like this change only fixes one occurrence, butis_ignored_symbol()has a big list of other cases.Unless those cases are different?
Thanks
JamesQuoted 6 lines
Hi James,
I don't think it's necessary to cover all the cases listed in
is_ignored_symbol(). As long as the symbols are unique and not overlapping with each other, they should't cause problems in resolving symbols. So most of the cases inis_ignored_symbol()should be irrelevant.Is it possible to do the filtering of the module symbols somewhere else like in
kernel/kallsyms.c? I'm not that familiar with it but it seems like at one point when populating kallsyms '$...' functions are filtered out, but when modules are loaded the symbols are not filtered because another code path is used?
Quoted 4 lines
If kallsyms has some duplicate addresses in there then isn't the bug in kallsyms rather than perf? And another tool could get confused too.
James
Yes we can filter these symbols out when adding module symbols to the kallsyms list. I will send another patch that modifies module.c to ignore '$' symbols when loading module.
I think it's worth applying this patch in the sense that perf userspace tool can be used on all 5.x kernels, and people don't have to update the kernel to fix it.
Lexi
Quoted 35 lines
Quoted 35 lines
Lexi
Quoted 31 lines
Quoted 30 lines
After this patch, the module symbol name is printed:
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8test_func+0x78([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])Signed-off-by Lexi Shao <[email protected]>--- tools/perf/util/symbol.c | 4 ++++ 1 file changed, 4 insertions(+)tools/perf/util/symbol.c +4
-0@@ -702,6 +702,10 @@ static int map__process_kallsym_symbol(void *arg, const char *name,if (!symbol_type__filter (type))return 0 ; +/* Ignore local symbols for ARM modules */ +if (name[0 ] =='$' ) +return 0 ; +/* * module symbols are not sorted so we add all * symbols, setting length to 0, and rely on
Quoted 46 lines · Lexi Shao
Quoted 45 lines · James Clark
Quoted 31 lines · Lexi Shao
Quoted 21 lines · James Clark
Quoted 11 lines · Lexi Shao
On ARM machine, kernel symbols from modules can be resolved to $a instead of printing the actual symbol name. Ignore symbols starting with "$" when building kallsyms rbtree.
A sample stacktrace is shown as follows:
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8$a+0x78 ([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])Quoted 6 lines
On ARM machine, $a/$d symbols are used by the compiler to mark the beginning of code/data part in code section. These symbols are filtered out when linking
vmlinux(see scripts/kallsyms.c ignored_prefixes), but are left on modules. So there are $a symbols in/proc/kallsymswhich share the same addresses with the actual module symbols and confuses perf when resolving symbols.Hi Lexi,
Quoted 8 lines
Is it worth using or re-implementing the entire
is_ignored_symbol()function fromscripts/kallsyms.c? It seems like this change only fixes one occurrence, butis_ignored_symbol()has a big list of other cases.Unless those cases are different?
Thanks
JamesQuoted 6 lines
Hi James,
I don't think it's necessary to cover all the cases listed in
is_ignored_symbol(). As long as the symbols are unique and not overlapping with each other, they should't cause problems in resolving symbols. So most of the cases inis_ignored_symbol()should be irrelevant.Is it possible to do the filtering of the module symbols somewhere else like in
kernel/kallsyms.c? I'm not that familiar with it but it seems like at one point when populating kallsyms '$...' functions are filtered out, but when modules are loaded the symbols are not filtered because another code path is used?
Quoted 9 lines
Quoted 4 lines
If kallsyms has some duplicate addresses in there then isn't the bug in kallsyms rather than perf? And another tool could get confused too.
James
Yes we can filter these symbols out when adding module symbols to the kallsyms list. I will send another patch that modifies
module.cto ignore '$' symbols when loading module.
That sounds great thanks.
Quoted 3 lines
I think it's worth applying this patch in the sense that perf userspace tool can be used on all 5.x kernels, and people don't have to update the kernel to fix it.
Yes you are right. In that case I will add a review tag to this change.
Thanks
James
Quoted 39 lines
Lexi
Quoted 35 lines
Quoted 35 lines
Lexi
Quoted 31 lines
Quoted 30 lines
After this patch, the module symbol name is printed:
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8test_func+0x78([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])Signed-off-by Lexi Shao <[email protected]>--- tools/perf/util/symbol.c | 4 ++++ 1 file changed, 4 insertions(+)tools/perf/util/symbol.c +4
-0@@ -702,6 +702,10 @@ static int map__process_kallsym_symbol(void *arg, const char *name,if (!symbol_type__filter (type))return 0 ; +/* Ignore local symbols for ARM modules */ +if (name[0 ] =='$' ) +return 0 ; +/* * module symbols are not sorted so we add all * symbols, setting length to 0, and rely on
v2 cover kallsyms: Ignore $a/$d symbols in kallsyms for ARM
On ARM machine, $a/$d symbols are used by the compiler to mark the beginning of code/data part in code section. These symbols are filtered out when linking vmlinux(see scripts/kallsyms.c ignored_prefixes), but are left on modules. So there are $a symbols in /proc/kallsyms whose address overlap with the actual module symbols and can confuse tools such as perf when resolving kernel symbols.
A sample stacktrace shown by perf script:c0f2e39c schedule_hrtimeout+0x14 ([kernel.kallsyms])bf4a66d8 $a+0x78 ([test_module]) // $a is shown instead of actual sym name c0a4f5f4 kthread+0x15c ([kernel.kallsyms])c0a001f8 ret_from_fork+0x14 ([kernel.kallsyms])
This patch set contains 2 patches to fix such problem:
The 1st patch modifies perf userspace tools to ignore $a/$d symbols from /proc/kallsyms. So people can use new perf tool to get correct kernel symbol on arm machines instead of updating kernel image.
The 2nd patch modifies the logic of loading modules to ignore arm mapping symbols in the first place. Being left out in vmlinux and kernelspace API (e.g. module_kallsyms_on_each_symbol) means these symbols are not used anywhere, so it should be safe to remove them from module kallsyms list.
v2:
- Add 2nd patch as discussed with James Clark, see:
https://lore.kernel.org/all/[email protected]/
Lexi Shao (2):
perf symbol: ignore $a/$d symbols for ARM modules
kallsyms: ignore arm mapping symbols when loading module
kernel/module.c | 19 +++++++++++-------- tools/perf/util/symbol.c | 4 ++++ 2 files changed, 15 insertions(+), 8 deletions(-)
Signature · 1 line
2.12.3
PATCH v2 1/2 perf symbol: ignore $a/$d symbols for ARM modules
On ARM machine, kernel symbols from modules can be resolved to $a instead of printing the actual symbol name. Ignore symbols starting with "$" when building kallsyms rbtree.
A sample stacktrace is shown as follows:
c0f2e39c schedule_hrtimeout+0x14 ([kernel.kallsyms]) bf4a66d8 $a+0x78 ([test_module])c0a4f5f4 kthread+0x15c ([kernel.kallsyms]) c0a001f8 ret_from_fork+0x14 ([kernel.kallsyms])
On ARM machine, $a/$d symbols are used by the compiler to mark the beginning of code/data part in code section. These symbols are filtered out when linking vmlinux(see scripts/kallsyms.c ignored_prefixes), but are left on modules. So there are $a symbols in /proc/kallsyms which share the same addresses with the actual module symbols and confuses perf when resolving symbols.
After this patch, the module symbol name is printed:
c0f2e39c schedule_hrtimeout+0x14 ([kernel.kallsyms]) bf4a66d8 test_func+0x78 ([test_module]) c0a4f5f4 kthread+0x15c ([kernel.kallsyms]) c0a001f8 ret_from_fork+0x14 ([kernel.kallsyms])
--- tools/perf/util/symbol.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/perf/util/symbol.c +4 -0
@@ -702,6 +702,10 @@ static int map__process_kallsym_symbol(void *arg, const char *name,if (!symbol_type__filter (type))return 0 ; +/* Ignore local symbols for ARM modules */ +if (name[0 ] =='$' ) +return 0 ; +/* * module symbols are not sorted so we add all * symbols, setting length to 0, and rely on
Signature · 1 line
2.12.3
PATCH v2 2/2 kallsyms: ignore arm mapping symbols when loading module
In reply to Lexi ShaoArm modules contains mapping symbols(e.g. $a $d) which are ignored in module_kallsyms_on_each_symbol. However, these symbols are still displayed when catting /proc/kallsyms. This confuses tools(e.g. perf) that resolves kernel symbols with address using information from /proc/kallsyms. See discussion in Link:
https://lore.kernel.org/all/[email protected]/
Being left out in vmlinux(see scripts/kallsyms.c is_ignored_symbol) and kernelspace API implies that these symbols are not used in any cases. So we can ignore them in the first place by not adding them to module kallsyms.
--- kernel/module.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
kernel/module.c +11 -8
@@ -2662,16 +2662,22 @@ static char elf_type(const Elf_Sym *sym, const struct load_info *info)return '?' ; } -static bool is_core_symbol (const Elf_Sym *src,const Elf_Shdr *sechdrs, -unsigned int shnum,unsigned int pcpundx) +static inline int is_arm_mapping_symbol (const char *str); +static bool is_core_symbol (const Elf_Sym *src,const struct load_info *info) {const Elf_Shdr *sec; +const Elf_Shdr *sechdrs = info->sechdrs; +unsigned int shnum = info->hdr->e_shnum; +unsigned int pcpundx = info->index.pcpu;if (src->st_shndx ==SHN_UNDEF || src->st_shndx >= shnum || !src->st_name)return false; +if (is_arm_mapping_symbol (&info->strtab[src->st_name])) +return false; +#ifdef CONFIG_KALLSYMS_ALL if (src->st_shndx == pcpundx)return true;
@@ -2714,8 +2720,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)/* Compute total space required for the core symbols' strtab. */ for (ndst = i =0 ; i < nsrc; i++) {if (i ==0 ||is_livepatch_module (mod) || -is_core_symbol (src+i, info->sechdrs, info->hdr->e_shnum, - info->index.pcpu)) { +is_core_symbol (src+i, info)) { strtab_size +=strlen (&info->strtab[src[i].st_name])+1 ; ndst++; }
@@ -2778,8 +2783,7 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)for (ndst = i =0 ; i < mod->kallsyms->num_symtab; i++) { mod->kallsyms->typetab[i] =elf_type (src + i, info);if (i ==0 ||is_livepatch_module (mod) || -is_core_symbol (src+i, info->sechdrs, info->hdr->e_shnum, - info->index.pcpu)) { +is_core_symbol (src+i, info)) { mod->core_kallsyms.typetab[ndst] = mod->kallsyms->typetab[i]; dst[ndst] = src[i];
@@ -4246,8 +4250,7 @@ static const char *find_kallsyms_symbol(struct module *mod,* We ignore unnamed symbols: they're uninformative * and inserted at a whim. */ -if (*kallsyms_symbol_name (kallsyms, i) =='\0' - ||is_arm_mapping_symbol (kallsyms_symbol_name (kallsyms, i))) +if (*kallsyms_symbol_name (kallsyms, i) =='\0' )continue ;if (thisval <= addr && thisval > bestval) {
Signature · 1 line
2.12.3
Re: [PATCH v2 2/2] kallsyms: ignore arm mapping symbols when loading module
Quoted 7 lines · Lexi Shao
Arm modules contains mapping symbols(e.g. $a $d) which are ignored in
module_kallsyms_on_each_symbol. However, these symbols are still displayed when catting/proc/kallsyms. This confuses tools(e.g. perf) that resolves kernel symbols with address using information from/proc/kallsyms. See discussion in Link:
https://lore.kernel.org/all/[email protected]/
Quoted 6 lines
Being left out in
vmlinux(see scripts/kallsyms.c is_ignored_symbol)and kernelspace API implies that these symbols are not used in any cases. So we can ignore them in the first place by not adding them to module kallsyms.Signed-off-by Lexi Shao <[email protected]>
I tested this and it has removed the $ symbols from kallsyms where I saw them before.
Quoted 64 lines
--- kernel/module.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)kernel/module.c +11
-8@@ -2662,16 +2662,22 @@ static char elf_type(const Elf_Sym *sym, const struct load_info *info)return '?' ; } -static bool is_core_symbol (const Elf_Sym *src,const Elf_Shdr *sechdrs, -unsigned int shnum,unsigned int pcpundx) +static inline int is_arm_mapping_symbol (const char *str); +static bool is_core_symbol (const Elf_Sym *src,const struct load_info *info) {const Elf_Shdr *sec; +const Elf_Shdr *sechdrs = info->sechdrs; +unsigned int shnum = info->hdr->e_shnum; +unsigned int pcpundx = info->index.pcpu;if (src->st_shndx ==SHN_UNDEF || src->st_shndx >= shnum || !src->st_name)return false; +if (is_arm_mapping_symbol (&info->strtab[src->st_name])) +return false; +#ifdef CONFIG_KALLSYMS_ALL if (src->st_shndx == pcpundx)return true;@@ -2714,8 +2720,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)/* Compute total space required for the core symbols' strtab. */ for (ndst = i =0 ; i < nsrc; i++) {if (i ==0 ||is_livepatch_module (mod) || -is_core_symbol (src+i, info->sechdrs, info->hdr->e_shnum, - info->index.pcpu)) { +is_core_symbol (src+i, info)) { strtab_size +=strlen (&info->strtab[src[i].st_name])+1 ; ndst++; }@@ -2778,8 +2783,7 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)for (ndst = i =0 ; i < mod->kallsyms->num_symtab; i++) { mod->kallsyms->typetab[i] =elf_type (src + i, info);if (i ==0 ||is_livepatch_module (mod) || -is_core_symbol (src+i, info->sechdrs, info->hdr->e_shnum, - info->index.pcpu)) { +is_core_symbol (src+i, info)) { mod->core_kallsyms.typetab[ndst] = mod->kallsyms->typetab[i]; dst[ndst] = src[i];@@ -4246,8 +4250,7 @@ static const char *find_kallsyms_symbol(struct module *mod,* We ignore unnamed symbols: they're uninformative * and inserted at a whim. */ -if (*kallsyms_symbol_name (kallsyms, i) =='\0' - ||is_arm_mapping_symbol (kallsyms_symbol_name (kallsyms, i))) +if (*kallsyms_symbol_name (kallsyms, i) =='\0' )continue ;if (thisval <= addr && thisval > bestval) {
Quoted 18 lines · Lexi Shao
On ARM machine, kernel symbols from modules can be resolved to $a instead of printing the actual symbol name. Ignore symbols starting with "$" when building kallsyms rbtree.
A sample stacktrace is shown as follows:
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8$a+0x78 ([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])On ARM machine, $a/$d symbols are used by the compiler to mark the beginning of code/data part in code section. These symbols are filtered out when linking
vmlinux(see scripts/kallsyms.c ignored_prefixes), but are left on modules. So there are $a symbols in/proc/kallsymswhich share the same addresses with the actual module symbols and confuses perf when resolving symbols.
Quoted 8 lines
After this patch, the module symbol name is printed:
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8test_func+0x78([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])Signed-off-by Lexi Shao <[email protected]>
Quoted 20 lines
--- tools/perf/util/symbol.c | 4 ++++ 1 file changed, 4 insertions(+)tools/perf/util/symbol.c +4
-0@@ -702,6 +702,10 @@ static int map__process_kallsym_symbol(void *arg, const char *name,if (!symbol_type__filter (type))return 0 ; +/* Ignore local symbols for ARM modules */ +if (name[0 ] =='$' ) +return 0 ; +/* * module symbols are not sorted so we add all * symbols, setting length to 0, and rely on
Em Thu, Oct 28, 2021 at 09:44:26AM +0100, James Clark escreveu:
Quoted 23 lines · Lexi Shao
Quoted 20 lines
On ARM machine, kernel symbols from modules can be resolved to $a instead of printing the actual symbol name. Ignore symbols starting with "$" when building kallsyms rbtree.
A sample stacktrace is shown as follows:
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8$a+0x78 ([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])On ARM machine, $a/$d symbols are used by the compiler to mark the beginning of code/data part in code section. These symbols are filtered out when linking
vmlinux(see scripts/kallsyms.c ignored_prefixes), but are left on modules. So there are $a symbols in/proc/kallsymswhich share the same addresses with the actual module symbols and confuses perf when resolving symbols.After this patch, the module symbol name is printed:
Quoted 8 lines
Quoted 6 lines
c0f2e39cschedule_hrtimeout+0x14([kernel.kallsyms])bf4a66d8test_func+0x78([test_module])c0a4f5f4kthread+0x15c([kernel.kallsyms])c0a001f8ret_from_fork+0x14([kernel.kallsyms])Signed-off-by Lexi Shao <[email protected]>Reviewed-by James Clark <[email protected]>
Thanks, applied.
- Arnaldo