Message ID | 66ea9420976071558fa0c1a3a891f29f720826d0.1459354581.git.naveen.n.rao@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
On 2016/03/30 10:13PM, Naveen N Rao wrote: > While trying to address the kallsyms perf test failure on ppc64le, > Ananth noticed that we were not necessarily probing at the expected > address when an offset to the function was specified. > > So far, we used to treat probe point offsets as being offset from the > LEP. However, userspace applications (objdump/readelf) always show > disassembly and offsets from the function GEP. This is confusing to the > user. Fix this by changing how we modify probe address with perf. > > If only the function name is provided, we assume the user needs the LEP. > Otherwise, if an offset is specified, we assume that the user knows the > exact address to probe based on function disassembly, and so we just > place the probe from the GEP offset. > > Tested lightly. Needs more testing. > > Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com> > Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> > Cc: Michael Ellerman <mpe@ellerman.id.au> > Reported-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com> > Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> > --- > tools/perf/arch/powerpc/util/sym-handling.c | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) > > diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c > index 3e98a61..36f6eb0 100644 > --- a/tools/perf/arch/powerpc/util/sym-handling.c > +++ b/tools/perf/arch/powerpc/util/sym-handling.c > @@ -65,16 +65,23 @@ void arch__fix_tev_from_maps(struct perf_probe_event *pev, > struct probe_trace_event *tev, struct map *map, > struct symbol *sym) > { > + int lep_offset = PPC64_LOCAL_ENTRY_OFFSET(sym->elf_st_other); > + > /* > * ppc64 ABIv2 local entry point is currently always 2 instructions > - * (8 bytes) after the global entry point. > + * (8 bytes) after the global entry point. When probing at a function > + * entry point, we normally always want the LEP since that catches calls > + * to the function through both the GEP and the LEP. However, if the user > + * specifies an offset, we fall back to using the GEP since all userspace > + * applications (objdump/readelf) show function disassembly with offsets > + * from the GEP. > */ > - if (!pev->uprobes && map->dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS) { > - tev->point.address += PPC64LE_LEP_OFFSET; > + if (pev->point.offset) This needs to be: if (pev->point.offset || pev->point.retprobe) return; kretprobes fails otherwise. - Naveen > + return; > + > + if (!pev->uprobes && map->dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS) > tev->point.offset += PPC64LE_LEP_OFFSET; > - } else if (PPC64_LOCAL_ENTRY_OFFSET(sym->elf_st_other)) { > - tev->point.address += PPC64_LOCAL_ENTRY_OFFSET(sym->elf_st_other); > - tev->point.offset += PPC64_LOCAL_ENTRY_OFFSET(sym->elf_st_other); > - } > + else if (lep_offset) > + tev->point.offset += lep_offset; > } > #endif > -- > 2.7.4 > > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/linuxppc-dev
diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c index 3e98a61..36f6eb0 100644 --- a/tools/perf/arch/powerpc/util/sym-handling.c +++ b/tools/perf/arch/powerpc/util/sym-handling.c @@ -65,16 +65,23 @@ void arch__fix_tev_from_maps(struct perf_probe_event *pev, struct probe_trace_event *tev, struct map *map, struct symbol *sym) { + int lep_offset = PPC64_LOCAL_ENTRY_OFFSET(sym->elf_st_other); + /* * ppc64 ABIv2 local entry point is currently always 2 instructions - * (8 bytes) after the global entry point. + * (8 bytes) after the global entry point. When probing at a function + * entry point, we normally always want the LEP since that catches calls + * to the function through both the GEP and the LEP. However, if the user + * specifies an offset, we fall back to using the GEP since all userspace + * applications (objdump/readelf) show function disassembly with offsets + * from the GEP. */ - if (!pev->uprobes && map->dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS) { - tev->point.address += PPC64LE_LEP_OFFSET; + if (pev->point.offset) + return; + + if (!pev->uprobes && map->dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS) tev->point.offset += PPC64LE_LEP_OFFSET; - } else if (PPC64_LOCAL_ENTRY_OFFSET(sym->elf_st_other)) { - tev->point.address += PPC64_LOCAL_ENTRY_OFFSET(sym->elf_st_other); - tev->point.offset += PPC64_LOCAL_ENTRY_OFFSET(sym->elf_st_other); - } + else if (lep_offset) + tev->point.offset += lep_offset; } #endif
While trying to address the kallsyms perf test failure on ppc64le, Ananth noticed that we were not necessarily probing at the expected address when an offset to the function was specified. So far, we used to treat probe point offsets as being offset from the LEP. However, userspace applications (objdump/readelf) always show disassembly and offsets from the function GEP. This is confusing to the user. Fix this by changing how we modify probe address with perf. If only the function name is provided, we assume the user needs the LEP. Otherwise, if an offset is specified, we assume that the user knows the exact address to probe based on function disassembly, and so we just place the probe from the GEP offset. Tested lightly. Needs more testing. Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Reported-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> --- tools/perf/arch/powerpc/util/sym-handling.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)