Re: [PATCH 05/12] perf tools: Read also the end of the kernel
On Fri, May 24, 2019 at 03:46:07PM -0300, Arnaldo Carvalho de Melo wrote: > Em Fri, May 24, 2019 at 03:17:17PM -0300, Arnaldo Carvalho de Melo escreveu: > > Em Fri, May 24, 2019 at 03:15:06PM -0300, Arnaldo Carvalho de Melo escreveu: > > > Em Wed, May 08, 2019 at 03:20:03PM +0200, Jiri Olsa escreveu: > > > > We mark the end of kernel based on the first module, > > > > but that could cover some bpf program maps. Reading > > > > _etext symbol if it's present to get precise kernel > > > > map end. > > > > > > Investigating... Have you run 'perf test' before hitting the send > > > button? :-) > > > > > > > > > [root@quaco c]# perf test -v 1 > > > 1: vmlinux symtab matches kallsyms : > > > > > --- start --- > > > ERR : 0x8cc00e41: __indirect_thunk_end not on kallsyms > > > > > test child finished with -1 > > > end > > > vmlinux symtab matches kallsyms: FAILED! > > > [root@quaco c]# > > > > So... > > > > [root@quaco c]# grep __indirect_thunk_end /proc/kallsyms > > 8cc00e41 T __indirect_thunk_end > > [root@quaco c]# grep -w _etext /proc/kallsyms > > 8cc00e41 T _etext > > [root@quaco c]# > > > > [root@quaco c]# grep -w 8cc00e41 /proc/kallsyms > > 8cc00e41 T _etext > > 8cc00e41 T __indirect_thunk_end > > [root@quaco c]# > > > > Lemme try to fix this. > > So, I got this right before your patch: > > commit 1d1c54c5bbf55256e691bedb47b0d14745043e80 > Author: Arnaldo Carvalho de Melo > Date: Fri May 24 15:39:00 2019 -0300 > > perf test vmlinux-kallsyms: Ignore aliases to _etext when searching on > kallsyms > > No need to search for aliases for the symbol that marks the end of the > kernel text segment, the following patch will make such symbols not to > be found when searching in the kallsyms maps causing this test to fail. > > So as a prep patch to avoid breaking bisection, ignore such symbols. > > Cc: Adrian Hunter > Cc: Alexander Shishkin > Cc: Andi Kleen > Cc: Jiri Olsa > Cc: Namhyung Kim > Cc: Peter Zijlstra > Cc: Song Liu > Cc: Stanislav Fomichev > Cc: Thomas Richter > Link: > https://lkml.kernel.org/n/tip-qfwuih8cvmk9doh7k5k24...@git.kernel.org > Signed-off-by: Arnaldo Carvalho de Melo works for me Tested-by: Jiri Olsa thanks, jirka
Re: [PATCH 05/12] perf tools: Read also the end of the kernel
On Fri, May 24, 2019 at 03:15:06PM -0300, Arnaldo Carvalho de Melo wrote: > Em Wed, May 08, 2019 at 03:20:03PM +0200, Jiri Olsa escreveu: > > We mark the end of kernel based on the first module, > > but that could cover some bpf program maps. Reading > > _etext symbol if it's present to get precise kernel > > map end. > > Investigating... Have you run 'perf test' before hitting the send > button? :-) yea, I got skip test.. for not having the vmlinux in place [jolsa@krava perf]$ sudo ./perf test 1 1: vmlinux symtab matches kallsyms : Skip did not realized it would break.. because I have 'Skip' in this one always :-\ sry jirka > > - Arnaldo > > [root@quaco c]# perf test 1 > 1: vmlinux symtab matches kallsyms : FAILED! > [root@quaco c]# perf test -v 1 > 1: vmlinux symtab matches kallsyms : > --- start --- > test child forked, pid 17488 > Looking at the vmlinux_path (8 entries long) > Using /lib/modules/5.2.0-rc1+/build/vmlinux for symbols > WARN: 0x8c001000: diff name v: hypercall_page k: > xen_hypercall_set_trap_table > WARN: 0x8c0275c0: diff name v: __ia32_sys_rt_sigreturn k: > __x64_sys_rt_sigreturn > WARN: 0x8c06ac31: diff name v: end_irq_irq_disable k: > start_irq_irq_enable > WARN: 0x8c06ac32: diff name v: end_irq_irq_enable k: > start_irq_restore_fl > WARN: 0x8c06ac34: diff name v: end_irq_restore_fl k: start_irq_save_fl > WARN: 0x8c06ac36: diff name v: end_irq_save_fl k: start_mmu_read_cr2 > WARN: 0x8c06ac3c: diff name v: end_mmu_read_cr3 k: start_mmu_write_cr3 > WARN: 0x8c06ac3f: diff name v: end_mmu_write_cr3 k: start_cpu_wbinvd > WARN: 0x8c06ac41: diff name v: end_cpu_wbinvd k: > start_cpu_usergs_sysret64 > WARN: 0x8c06ac47: diff name v: end_cpu_usergs_sysret64 k: > start_cpu_swapgs > WARN: 0x8c06ac4a: diff name v: end_cpu_swapgs k: start__mov64 > WARN: 0x8c0814b0: diff end addr for aesni_gcm_dec v: > 0x8c083606 k: 0x8c0817c7 > WARN: 0x8c083610: diff end addr for aesni_gcm_enc v: > 0x8c0856f2 k: 0x8c083927 > WARN: 0x8c085c00: diff end addr for aesni_gcm_enc_update v: > 0x8c087556 k: 0x8c085c31 > WARN: 0x8c087560: diff end addr for aesni_gcm_dec_update v: > 0x8c088f2a k: 0x8c087591 > WARN: 0x8c08b7c0: diff end addr for aesni_gcm_enc_update_avx_gen2 v: > 0x8c09b13c k: 0x8c08b818 > WARN: 0x8c08fac1: diff name v: _initial_blocks_done2259 k: > _initial_blocks_encrypted15 > WARN: 0x8c094943: diff name v: _initial_blocks_done4447 k: > _initial_blocks_encrypted2497 > WARN: 0x8c09a023: diff name v: _initial_blocks_done7187 k: > _initial_blocks_encrypted4649 > WARN: 0x8c09b140: diff end addr for aesni_gcm_dec_update_avx_gen2 v: > 0x8c0ab05f k: 0x8c09b198 > WARN: 0x8c09f5b6: diff name v: _initial_blocks_done9706 k: > _initial_blocks_encrypted7462 > WARN: 0x8c0a4619: diff name v: _initial_blocks_done11894 k: > _initial_blocks_encrypted9944 > WARN: 0x8c0a9eda: diff name v: _initial_blocks_done14634 k: > _initial_blocks_encrypted12096 > WARN: 0x8c0abcd0: diff end addr for aesni_gcm_enc_update_avx_gen4 v: > 0x8c0ba4a6 k: 0x8c0abd28 > WARN: 0x8c0afaa5: diff name v: _initial_blocks_done17291 k: > _initial_blocks_encrypted15047 > WARN: 0x8c0b4345: diff name v: _initial_blocks_done19479 k: > _initial_blocks_encrypted17529 > WARN: 0x8c0b9443: diff name v: _initial_blocks_done22219 k: > _initial_blocks_encrypted19681 > WARN: 0x8c0ba4b0: diff end addr for aesni_gcm_dec_update_avx_gen4 v: > 0x8c0c9229 k: 0x8c0ba508 > WARN: 0x8c0be3fa: diff name v: _initial_blocks_done24738 k: > _initial_blocks_encrypted22494 > WARN: 0x8c0c2e7b: diff name v: _initial_blocks_done26926 k: > _initial_blocks_encrypted24976 > WARN: 0x8c0c815a: diff name v: _initial_blocks_done29666 k: > _initial_blocks_encrypted27128 > WARN: 0x8c0dc2b0: diff name v: __ia32_sys_fork k: __x64_sys_fork > WARN: 0x8c0dc2d0: diff name v: __ia32_sys_vfork k: __x64_sys_vfork > WARN: 0x8c0e9eb0: diff name v: __ia32_sys_restart_syscall k: > __x64_sys_restart_syscall > WARN: 0x8c0e9f30: diff name v: __ia32_sys_sgetmask k: > __x64_sys_sgetmask > WARN: 0x8c0ea4b0: diff name v: __ia32_sys_pause k: __x64_sys_pause > WARN: 0x8c0f1610: diff name v: __ia32_sys_gettid k: __x64_sys_gettid > WARN: 0x8c0f1630: diff name v: __ia32_sys_getpid k: __x64_sys_getpid > WARN: 0x8c0f1650: diff name v: __ia32_sys_getppid k: __x64_sys_getppid > WARN: 0x8c0f1980: diff name v: __ia32_sys_getuid k: __x64_sys_getuid > WARN: 0x8c0f19b0: diff name v: __ia32_sys_geteuid k: __x64_sys_geteuid > WARN: 0x8c0f1b30: diff name v: __ia32_sys_getgid
Re: [PATCH 05/12] perf tools: Read also the end of the kernel
Em Fri, May 24, 2019 at 03:17:17PM -0300, Arnaldo Carvalho de Melo escreveu: > Em Fri, May 24, 2019 at 03:15:06PM -0300, Arnaldo Carvalho de Melo escreveu: > > Em Wed, May 08, 2019 at 03:20:03PM +0200, Jiri Olsa escreveu: > > > We mark the end of kernel based on the first module, > > > but that could cover some bpf program maps. Reading > > > _etext symbol if it's present to get precise kernel > > > map end. > > > > Investigating... Have you run 'perf test' before hitting the send > > button? :-) > > > > > [root@quaco c]# perf test -v 1 > > 1: vmlinux symtab matches kallsyms : > > > --- start --- > > ERR : 0x8cc00e41: __indirect_thunk_end not on kallsyms > > > test child finished with -1 > > end > > vmlinux symtab matches kallsyms: FAILED! > > [root@quaco c]# > > So... > > [root@quaco c]# grep __indirect_thunk_end /proc/kallsyms > 8cc00e41 T __indirect_thunk_end > [root@quaco c]# grep -w _etext /proc/kallsyms > 8cc00e41 T _etext > [root@quaco c]# > > [root@quaco c]# grep -w 8cc00e41 /proc/kallsyms > 8cc00e41 T _etext > 8cc00e41 T __indirect_thunk_end > [root@quaco c]# > > Lemme try to fix this. So, I got this right before your patch: commit 1d1c54c5bbf55256e691bedb47b0d14745043e80 Author: Arnaldo Carvalho de Melo Date: Fri May 24 15:39:00 2019 -0300 perf test vmlinux-kallsyms: Ignore aliases to _etext when searching on kallsyms No need to search for aliases for the symbol that marks the end of the kernel text segment, the following patch will make such symbols not to be found when searching in the kallsyms maps causing this test to fail. So as a prep patch to avoid breaking bisection, ignore such symbols. Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Song Liu Cc: Stanislav Fomichev Cc: Thomas Richter Link: https://lkml.kernel.org/n/tip-qfwuih8cvmk9doh7k5k24...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c index 7691980b7df1..f101576d1c72 100644 --- a/tools/perf/tests/vmlinux-kallsyms.c +++ b/tools/perf/tests/vmlinux-kallsyms.c @@ -161,9 +161,16 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest continue; } - } else + } else if (mem_start == kallsyms.vmlinux_map->end) { + /* +* Ignore aliases to _etext, i.e. to the end of the kernel text area, +* such as __indirect_thunk_end. +*/ + continue; + } else { pr_debug("ERR : %#" PRIx64 ": %s not on kallsyms\n", mem_start, sym->name); + } err = -1; }
Re: [PATCH 05/12] perf tools: Read also the end of the kernel
Em Fri, May 24, 2019 at 03:15:06PM -0300, Arnaldo Carvalho de Melo escreveu: > Em Wed, May 08, 2019 at 03:20:03PM +0200, Jiri Olsa escreveu: > > We mark the end of kernel based on the first module, > > but that could cover some bpf program maps. Reading > > _etext symbol if it's present to get precise kernel > > map end. > > Investigating... Have you run 'perf test' before hitting the send > button? :-) > [root@quaco c]# perf test -v 1 > 1: vmlinux symtab matches kallsyms : > --- start --- > ERR : 0x8cc00e41: __indirect_thunk_end not on kallsyms > test child finished with -1 > end > vmlinux symtab matches kallsyms: FAILED! > [root@quaco c]# So... [root@quaco c]# grep __indirect_thunk_end /proc/kallsyms 8cc00e41 T __indirect_thunk_end [root@quaco c]# grep -w _etext /proc/kallsyms 8cc00e41 T _etext [root@quaco c]# [root@quaco c]# grep -w 8cc00e41 /proc/kallsyms 8cc00e41 T _etext 8cc00e41 T __indirect_thunk_end [root@quaco c]# Lemme try to fix this. - Arnaldo > [acme@quaco perf]$ git bisect good > 7d98e1a73bd7dae6cb321ec8b0b97b9fed7c0e1b is the first bad commit > commit 7d98e1a73bd7dae6cb321ec8b0b97b9fed7c0e1b > Author: Jiri Olsa > Date: Wed May 8 15:20:03 2019 +0200 > > perf machine: Read also the end of the kernel > > We mark the end of kernel based on the first module, but that could > cover some bpf program maps. Reading _etext symbol if it's present to > get precise kernel map end. > > Signed-off-by: Jiri Olsa > Acked-by: Song Liu > Cc: Adrian Hunter > Cc: Alexander Shishkin > Cc: Andi Kleen > Cc: Namhyung Kim > Cc: Peter Zijlstra > Cc: Stanislav Fomichev > Cc: Thomas Richter > Link: http://lkml.kernel.org/r/20190508132010.14512-6-jo...@kernel.org > Signed-off-by: Arnaldo Carvalho de Melo > > :04 04 4ca5fa4c6f15fd8cf9a0eee870efbd01e9fe309d > 8311b30f94e9cf9a863dc9619b0499863f64960e Mtools > [acme@quaco perf]$ > > > Link: http://lkml.kernel.org/n/tip-ynut991ttyyhvo1sbhlm4...@git.kernel.org > > Signed-off-by: Jiri Olsa > > --- > > tools/perf/util/machine.c | 27 ++- > > 1 file changed, 18 insertions(+), 9 deletions(-) > > > > diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c > > index 3c520baa198c..ad0205fbb506 100644 > > --- a/tools/perf/util/machine.c > > +++ b/tools/perf/util/machine.c > > @@ -924,7 +924,8 @@ const char *ref_reloc_sym_names[] = {"_text", "_stext", > > NULL}; > > * symbol_name if it's not that important. > > */ > > static int machine__get_running_kernel_start(struct machine *machine, > > -const char **symbol_name, u64 > > *start) > > +const char **symbol_name, > > +u64 *start, u64 *end) > > { > > char filename[PATH_MAX]; > > int i, err = -1; > > @@ -949,6 +950,11 @@ static int machine__get_running_kernel_start(struct > > machine *machine, > > *symbol_name = name; > > > > *start = addr; > > + > > + err = kallsyms__get_function_start(filename, "_etext", ); > > + if (!err) > > + *end = addr; > > + > > return 0; > > } > > > > @@ -1440,7 +1446,7 @@ int machine__create_kernel_maps(struct machine > > *machine) > > struct dso *kernel = machine__get_kernel(machine); > > const char *name = NULL; > > struct map *map; > > - u64 addr = 0; > > + u64 start = 0, end = ~0ULL; > > int ret; > > > > if (kernel == NULL) > > @@ -1459,9 +1465,9 @@ int machine__create_kernel_maps(struct machine > > *machine) > > "continuing anyway...\n", machine->pid); > > } > > > > - if (!machine__get_running_kernel_start(machine, , )) { > > + if (!machine__get_running_kernel_start(machine, , , )) { > > if (name && > > - map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, > > addr)) { > > + map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, > > start)) { > > machine__destroy_kernel_maps(machine); > > ret = -1; > > goto out_put; > > @@ -1471,16 +1477,19 @@ int machine__create_kernel_maps(struct machine > > *machine) > > * we have a real start address now, so re-order the kmaps > > * assume it's the last in the kmaps > > */ > > - machine__update_kernel_mmap(machine, addr, ~0ULL); > > + machine__update_kernel_mmap(machine, start, end); > > } > > > > if (machine__create_extra_kernel_maps(machine, kernel)) > > pr_debug("Problems creating extra kernel maps, continuing > > anyway...\n"); > > > > - /* update end address of the kernel map using adjacent module address */ > > - map = map__next(machine__kernel_map(machine)); > > - if (map) > > -
Re: [PATCH 05/12] perf tools: Read also the end of the kernel
Em Wed, May 08, 2019 at 03:20:03PM +0200, Jiri Olsa escreveu: > We mark the end of kernel based on the first module, > but that could cover some bpf program maps. Reading > _etext symbol if it's present to get precise kernel > map end. Investigating... Have you run 'perf test' before hitting the send button? :-) - Arnaldo [root@quaco c]# perf test 1 1: vmlinux symtab matches kallsyms : FAILED! [root@quaco c]# perf test -v 1 1: vmlinux symtab matches kallsyms : --- start --- test child forked, pid 17488 Looking at the vmlinux_path (8 entries long) Using /lib/modules/5.2.0-rc1+/build/vmlinux for symbols WARN: 0x8c001000: diff name v: hypercall_page k: xen_hypercall_set_trap_table WARN: 0x8c0275c0: diff name v: __ia32_sys_rt_sigreturn k: __x64_sys_rt_sigreturn WARN: 0x8c06ac31: diff name v: end_irq_irq_disable k: start_irq_irq_enable WARN: 0x8c06ac32: diff name v: end_irq_irq_enable k: start_irq_restore_fl WARN: 0x8c06ac34: diff name v: end_irq_restore_fl k: start_irq_save_fl WARN: 0x8c06ac36: diff name v: end_irq_save_fl k: start_mmu_read_cr2 WARN: 0x8c06ac3c: diff name v: end_mmu_read_cr3 k: start_mmu_write_cr3 WARN: 0x8c06ac3f: diff name v: end_mmu_write_cr3 k: start_cpu_wbinvd WARN: 0x8c06ac41: diff name v: end_cpu_wbinvd k: start_cpu_usergs_sysret64 WARN: 0x8c06ac47: diff name v: end_cpu_usergs_sysret64 k: start_cpu_swapgs WARN: 0x8c06ac4a: diff name v: end_cpu_swapgs k: start__mov64 WARN: 0x8c0814b0: diff end addr for aesni_gcm_dec v: 0x8c083606 k: 0x8c0817c7 WARN: 0x8c083610: diff end addr for aesni_gcm_enc v: 0x8c0856f2 k: 0x8c083927 WARN: 0x8c085c00: diff end addr for aesni_gcm_enc_update v: 0x8c087556 k: 0x8c085c31 WARN: 0x8c087560: diff end addr for aesni_gcm_dec_update v: 0x8c088f2a k: 0x8c087591 WARN: 0x8c08b7c0: diff end addr for aesni_gcm_enc_update_avx_gen2 v: 0x8c09b13c k: 0x8c08b818 WARN: 0x8c08fac1: diff name v: _initial_blocks_done2259 k: _initial_blocks_encrypted15 WARN: 0x8c094943: diff name v: _initial_blocks_done4447 k: _initial_blocks_encrypted2497 WARN: 0x8c09a023: diff name v: _initial_blocks_done7187 k: _initial_blocks_encrypted4649 WARN: 0x8c09b140: diff end addr for aesni_gcm_dec_update_avx_gen2 v: 0x8c0ab05f k: 0x8c09b198 WARN: 0x8c09f5b6: diff name v: _initial_blocks_done9706 k: _initial_blocks_encrypted7462 WARN: 0x8c0a4619: diff name v: _initial_blocks_done11894 k: _initial_blocks_encrypted9944 WARN: 0x8c0a9eda: diff name v: _initial_blocks_done14634 k: _initial_blocks_encrypted12096 WARN: 0x8c0abcd0: diff end addr for aesni_gcm_enc_update_avx_gen4 v: 0x8c0ba4a6 k: 0x8c0abd28 WARN: 0x8c0afaa5: diff name v: _initial_blocks_done17291 k: _initial_blocks_encrypted15047 WARN: 0x8c0b4345: diff name v: _initial_blocks_done19479 k: _initial_blocks_encrypted17529 WARN: 0x8c0b9443: diff name v: _initial_blocks_done22219 k: _initial_blocks_encrypted19681 WARN: 0x8c0ba4b0: diff end addr for aesni_gcm_dec_update_avx_gen4 v: 0x8c0c9229 k: 0x8c0ba508 WARN: 0x8c0be3fa: diff name v: _initial_blocks_done24738 k: _initial_blocks_encrypted22494 WARN: 0x8c0c2e7b: diff name v: _initial_blocks_done26926 k: _initial_blocks_encrypted24976 WARN: 0x8c0c815a: diff name v: _initial_blocks_done29666 k: _initial_blocks_encrypted27128 WARN: 0x8c0dc2b0: diff name v: __ia32_sys_fork k: __x64_sys_fork WARN: 0x8c0dc2d0: diff name v: __ia32_sys_vfork k: __x64_sys_vfork WARN: 0x8c0e9eb0: diff name v: __ia32_sys_restart_syscall k: __x64_sys_restart_syscall WARN: 0x8c0e9f30: diff name v: __ia32_sys_sgetmask k: __x64_sys_sgetmask WARN: 0x8c0ea4b0: diff name v: __ia32_sys_pause k: __x64_sys_pause WARN: 0x8c0f1610: diff name v: __ia32_sys_gettid k: __x64_sys_gettid WARN: 0x8c0f1630: diff name v: __ia32_sys_getpid k: __x64_sys_getpid WARN: 0x8c0f1650: diff name v: __ia32_sys_getppid k: __x64_sys_getppid WARN: 0x8c0f1980: diff name v: __ia32_sys_getuid k: __x64_sys_getuid WARN: 0x8c0f19b0: diff name v: __ia32_sys_geteuid k: __x64_sys_geteuid WARN: 0x8c0f1b30: diff name v: __ia32_sys_getgid k: __x64_sys_getgid WARN: 0x8c0f1b60: diff name v: __ia32_sys_getegid k: __x64_sys_getegid WARN: 0x8c0f2130: diff name v: __ia32_sys_getpgrp k: __x64_sys_getpgrp WARN: 0x8c0f52f0: diff name v: __ia32_sys_setsid k: __x64_sys_setsid WARN: 0x8c1016d0: diff name v: sys_ni_syscall k: __x64_sys_vm86old WARN: 0x8c10b400: diff name v: __ia32_sys_sched_yield k: __x64_sys_sched_yield WARN: 0x8c1775a0: diff name v: __ia32_sys_getuid16 k: __x64_sys_getuid16 WARN:
[PATCH 05/12] perf tools: Read also the end of the kernel
We mark the end of kernel based on the first module, but that could cover some bpf program maps. Reading _etext symbol if it's present to get precise kernel map end. Link: http://lkml.kernel.org/n/tip-ynut991ttyyhvo1sbhlm4...@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/machine.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 3c520baa198c..ad0205fbb506 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -924,7 +924,8 @@ const char *ref_reloc_sym_names[] = {"_text", "_stext", NULL}; * symbol_name if it's not that important. */ static int machine__get_running_kernel_start(struct machine *machine, -const char **symbol_name, u64 *start) +const char **symbol_name, +u64 *start, u64 *end) { char filename[PATH_MAX]; int i, err = -1; @@ -949,6 +950,11 @@ static int machine__get_running_kernel_start(struct machine *machine, *symbol_name = name; *start = addr; + + err = kallsyms__get_function_start(filename, "_etext", ); + if (!err) + *end = addr; + return 0; } @@ -1440,7 +1446,7 @@ int machine__create_kernel_maps(struct machine *machine) struct dso *kernel = machine__get_kernel(machine); const char *name = NULL; struct map *map; - u64 addr = 0; + u64 start = 0, end = ~0ULL; int ret; if (kernel == NULL) @@ -1459,9 +1465,9 @@ int machine__create_kernel_maps(struct machine *machine) "continuing anyway...\n", machine->pid); } - if (!machine__get_running_kernel_start(machine, , )) { + if (!machine__get_running_kernel_start(machine, , , )) { if (name && - map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, addr)) { + map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, start)) { machine__destroy_kernel_maps(machine); ret = -1; goto out_put; @@ -1471,16 +1477,19 @@ int machine__create_kernel_maps(struct machine *machine) * we have a real start address now, so re-order the kmaps * assume it's the last in the kmaps */ - machine__update_kernel_mmap(machine, addr, ~0ULL); + machine__update_kernel_mmap(machine, start, end); } if (machine__create_extra_kernel_maps(machine, kernel)) pr_debug("Problems creating extra kernel maps, continuing anyway...\n"); - /* update end address of the kernel map using adjacent module address */ - map = map__next(machine__kernel_map(machine)); - if (map) - machine__set_kernel_mmap(machine, addr, map->start); + if (end == ~0ULL) { + /* update end address of the kernel map using adjacent module address */ + map = map__next(machine__kernel_map(machine)); + if (map) + machine__set_kernel_mmap(machine, start, map->start); + } + out_put: dso__put(kernel); return ret; -- 2.20.1
[PATCH 05/12] perf tools: Read also the end of the kernel
We mark the end of kernel based on the first module, but that could cover some bpf program maps. Reading _etext symbol if it's present to get precise kernel map end. Link: http://lkml.kernel.org/n/tip-ynut991ttyyhvo1sbhlm4...@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/machine.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 3c520baa198c..ad0205fbb506 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -924,7 +924,8 @@ const char *ref_reloc_sym_names[] = {"_text", "_stext", NULL}; * symbol_name if it's not that important. */ static int machine__get_running_kernel_start(struct machine *machine, -const char **symbol_name, u64 *start) +const char **symbol_name, +u64 *start, u64 *end) { char filename[PATH_MAX]; int i, err = -1; @@ -949,6 +950,11 @@ static int machine__get_running_kernel_start(struct machine *machine, *symbol_name = name; *start = addr; + + err = kallsyms__get_function_start(filename, "_etext", ); + if (!err) + *end = addr; + return 0; } @@ -1440,7 +1446,7 @@ int machine__create_kernel_maps(struct machine *machine) struct dso *kernel = machine__get_kernel(machine); const char *name = NULL; struct map *map; - u64 addr = 0; + u64 start = 0, end = ~0ULL; int ret; if (kernel == NULL) @@ -1459,9 +1465,9 @@ int machine__create_kernel_maps(struct machine *machine) "continuing anyway...\n", machine->pid); } - if (!machine__get_running_kernel_start(machine, , )) { + if (!machine__get_running_kernel_start(machine, , , )) { if (name && - map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, addr)) { + map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, start)) { machine__destroy_kernel_maps(machine); ret = -1; goto out_put; @@ -1471,16 +1477,19 @@ int machine__create_kernel_maps(struct machine *machine) * we have a real start address now, so re-order the kmaps * assume it's the last in the kmaps */ - machine__update_kernel_mmap(machine, addr, ~0ULL); + machine__update_kernel_mmap(machine, start, end); } if (machine__create_extra_kernel_maps(machine, kernel)) pr_debug("Problems creating extra kernel maps, continuing anyway...\n"); - /* update end address of the kernel map using adjacent module address */ - map = map__next(machine__kernel_map(machine)); - if (map) - machine__set_kernel_mmap(machine, addr, map->start); + if (end == ~0ULL) { + /* update end address of the kernel map using adjacent module address */ + map = map__next(machine__kernel_map(machine)); + if (map) + machine__set_kernel_mmap(machine, start, map->start); + } + out_put: dso__put(kernel); return ret; -- 2.20.1
[PATCH 05/12] perf tools: Read also the end of the kernel
We mark the end of kernel based on the first module, but that could cover some bpf program maps. Reading _etext symbol if it's present to get precise kernel map end. Link: http://lkml.kernel.org/n/tip-ynut991ttyyhvo1sbhlm4...@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/machine.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 3c520baa198c..ad0205fbb506 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -924,7 +924,8 @@ const char *ref_reloc_sym_names[] = {"_text", "_stext", NULL}; * symbol_name if it's not that important. */ static int machine__get_running_kernel_start(struct machine *machine, -const char **symbol_name, u64 *start) +const char **symbol_name, +u64 *start, u64 *end) { char filename[PATH_MAX]; int i, err = -1; @@ -949,6 +950,11 @@ static int machine__get_running_kernel_start(struct machine *machine, *symbol_name = name; *start = addr; + + err = kallsyms__get_function_start(filename, "_etext", ); + if (!err) + *end = addr; + return 0; } @@ -1440,7 +1446,7 @@ int machine__create_kernel_maps(struct machine *machine) struct dso *kernel = machine__get_kernel(machine); const char *name = NULL; struct map *map; - u64 addr = 0; + u64 start = 0, end = ~0ULL; int ret; if (kernel == NULL) @@ -1459,9 +1465,9 @@ int machine__create_kernel_maps(struct machine *machine) "continuing anyway...\n", machine->pid); } - if (!machine__get_running_kernel_start(machine, , )) { + if (!machine__get_running_kernel_start(machine, , , )) { if (name && - map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, addr)) { + map__set_kallsyms_ref_reloc_sym(machine->vmlinux_map, name, start)) { machine__destroy_kernel_maps(machine); ret = -1; goto out_put; @@ -1471,16 +1477,19 @@ int machine__create_kernel_maps(struct machine *machine) * we have a real start address now, so re-order the kmaps * assume it's the last in the kmaps */ - machine__update_kernel_mmap(machine, addr, ~0ULL); + machine__update_kernel_mmap(machine, start, end); } if (machine__create_extra_kernel_maps(machine, kernel)) pr_debug("Problems creating extra kernel maps, continuing anyway...\n"); - /* update end address of the kernel map using adjacent module address */ - map = map__next(machine__kernel_map(machine)); - if (map) - machine__set_kernel_mmap(machine, addr, map->start); + if (end == ~0ULL) { + /* update end address of the kernel map using adjacent module address */ + map = map__next(machine__kernel_map(machine)); + if (map) + machine__set_kernel_mmap(machine, start, map->start); + } + out_put: dso__put(kernel); return ret; -- 2.17.2