From: Naveen N. Rao <hidden> Date: 2014-12-15 14:51:02
This patchset fixes various issues with perf probe on powerpc across ABIv1 and
ABIv2:
- in the presence of DWARF debug-info,
- in the absence of DWARF, but with the symbol table, and
- in the absence of debug-info, but with kallsyms.
Applies cleanly on -tip. Tested on ppc64 BE and LE.
Changes from previous version:
Addressed various review comments from Mike Ellerman largely to generalize
changes. Some of the simpler patches have been retained in their previous form
to limit code churn, while others have been generalized by introducing arch
helpers. Individual patches have more details.
- Naveen
Naveen N. Rao (8):
kprobes: Fix kallsyms lookup across powerpc ABIv1 and ABIv2
perf probe: Improve detection of file/function name in the probe
pattern
perf probe powerpc: Fix symbol fixup issues due to ELF type
perf probe powerpc: Handle powerpc dot symbols
perf probe powerpc: Allow matching against dot symbols
perf tools powerpc: Fix PPC64 ELF ABIv2 symbol decoding
perf probe powerpc: Use DWARF info only if necessary
perf probe powerpc: Fixup function entry if using kallsyms lookup
arch/powerpc/include/asm/kprobes.h | 63 +++++++++++++++++++---------
tools/perf/arch/powerpc/Makefile | 1 +
tools/perf/arch/powerpc/util/sym-handling.c | 64 +++++++++++++++++++++++++++++
tools/perf/config/Makefile | 2 +
tools/perf/util/probe-event.c | 48 ++++++++++++++++++----
tools/perf/util/probe-event.h | 21 ++++++++++
tools/perf/util/symbol-elf.c | 5 ++-
tools/perf/util/symbol.c | 6 +++
tools/perf/util/symbol.h | 6 +++
9 files changed, 188 insertions(+), 28 deletions(-)
create mode 100644 tools/perf/arch/powerpc/util/sym-handling.c
--
2.1.3
From: Naveen N. Rao <hidden> Date: 2014-12-15 14:51:06
Currently, perf probe considers patterns including a '.' to be a file.
However, this causes problems on powerpc ABIv1 where all functions have
a leading '.':
$ perf probe -F | grep schedule_timeout_interruptible
.schedule_timeout_interruptible
$ perf probe .schedule_timeout_interruptible
Semantic error :File always requires line number or lazy pattern.
Error: Command Parse Error.
Fix this by checking the probe pattern in more detail.
Signed-off-by: Naveen N. Rao <redacted>
---
tools/perf/util/probe-event.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
@@ -999,6 +999,24 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)arg=tmp;}+/*+*Checkargisfunctionorfilenameandcopyit.+*+*Weconsiderargtobeafilespecifandonlyifitsatisfies+*allofthebelowcriteria::+*-itdoesnotincludeanyof"+@%",+*-itincludesoneof":;",and+*-ithasaperiod'.'inthename.+*+*Otherwise,weconsiderargtobeafunctionspecification.+*/+c=0;+if(!strpbrk(arg,"+@%")&&(ptr=strpbrk(arg,";:"))!=NULL){+/* This is a file spec if it includes a '.' before ; or : */+if(memchr(arg,'.',ptr-arg))+c=1;+}+ptr=strpbrk(arg,";:+@%");if(ptr){nc=*ptr;
@@ -1009,10 +1027,9 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)if(tmp==NULL)return-ENOMEM;-/* Check arg is function or file and copy it */-if(strchr(tmp,'.'))/* File */+if(c==1)pp->file=tmp;-else/* Function */+elsepp->function=tmp;/* Parse other options */
From: Naveen N. Rao <hidden> Date: 2014-12-15 14:51:09
If using the symbol table, symbol addresses are not being fixed up
properly, resulting in probes being placed at wrong addresses:
# perf probe do_fork
Added new event:
probe:do_fork (on do_fork)
You can now use it in all perf tools, such as:
perf record -e probe:do_fork -aR sleep 1
# cat /sys/kernel/debug/tracing/kprobe_events
p:probe/do_fork _text+635952
# printf "%x" 635952
9b430
# grep do_fork /boot/System.map
c0000000000ab430 T .do_fork
Fix by checking for ELF type ET_DYN used by ppc64 kernels.
Signed-off-by: Naveen N. Rao <redacted>
---
tools/perf/util/symbol-elf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
From: Naveen N. Rao <hidden> Date: 2014-12-15 14:51:14
Fix up various perf aspects related to ppc64's usage of dot functions:
- ignore leading '.' when generating event names and when looking for
existing events.
- use the proper prefix when ignoring SyS symbol lookups.
Signed-off-by: Naveen N. Rao <redacted>
---
tools/perf/util/probe-event.c | 8 ++++++++
tools/perf/util/symbol.c | 6 ++++++
2 files changed, 14 insertions(+)
@@ -2080,6 +2080,10 @@ static int get_new_event_name(char *buf, size_t len, const char *base,{inti,ret;+/* Skip the leading dot on powerpc */+if(*base=='.')+base++;+/* Try no suffix */ret=e_snprintf(buf,len,"%s",base);if(ret<0){
@@ -2538,6 +2542,10 @@ int del_perf_probe_events(struct strlist *dellist)event=str;}+/* Skip the leading dot on powerpc */+if(event&&*event=='.')+event++;+ret=e_snprintf(buf,128,"%s:%s",group,event);if(ret<0){pr_err("Failed to copy event.");
@@ -139,6 +139,12 @@ static int choose_best_symbol(struct symbol *syma, struct symbol *symb)if(na>=10&&!strncmp(syma->name,"compat_SyS",10))returnSYMBOL_B;+/* On powerpc, ignore the dot variants */+if(na>=4&&!strncmp(syma->name,".SyS",4))+returnSYMBOL_B;+if(na>=11&&!strncmp(syma->name,".compat_SyS",11))+returnSYMBOL_B;+returnSYMBOL_A;}
From: Naveen N. Rao <hidden> Date: 2014-12-15 14:51:17
Allow perf probe to work on powerpc ABIv1 without the need to specify
the leading dot '.' for functions. 'perf probe do_fork' works with this
patch.
Introduce HAVE_ARCH_SYMBOL_HANDLING to indicate need for special
handling of symbols. In this patch, we override probe_function_filter()
on powerpc to account for dot symbols.
Signed-off-by: Naveen N. Rao <redacted>
---
Changes from the previous patchset:
Introduced arch helper to override the way probe function filter works.
tools/perf/arch/powerpc/Makefile | 1 +
tools/perf/arch/powerpc/util/sym-handling.c | 28 ++++++++++++++++++++++++++++
tools/perf/config/Makefile | 1 +
tools/perf/util/probe-event.c | 10 +++++-----
tools/perf/util/probe-event.h | 5 +++++
5 files changed, 40 insertions(+), 5 deletions(-)
create mode 100644 tools/perf/arch/powerpc/util/sym-handling.c
@@ -7,6 +7,8 @@#include"strfilter.h"externboolprobe_event_dry_run;+externchar*looking_function_name;+externintnum_matched_functions;/* kprobe-tracer and uprobe-tracer tracing point */structprobe_trace_point{
@@ -136,6 +138,9 @@ extern int show_available_vars(struct perf_probe_event *pevs, int npevs,externintshow_available_funcs(constchar*module,structstrfilter*filter,booluser);+externintprobe_function_filter(structmap*map__maybe_unused,+structsymbol*sym);+/* Maximum index number of event-name postfix */#define MAX_EVENT_INDEX 1024
From: Naveen N. Rao <hidden> Date: 2014-12-15 14:51:22
Use symbol table lookups by default if DWARF is not necessary, since
powerpc ABIv2 encodes local entry points in the symbol table and the
function entry address in DWARF may not be appropriate for kprobes, as
described here:
https://sourceware.org/bugzilla/show_bug.cgi?id=17638
"The DWARF address ranges deliberately include the *whole* function,
both global and local entry points."
...
"If you want to set probes on a local entry point, you should look up
the symbol in the main symbol table (not DWARF), and check the st_other
bits; they will indicate whether the function has a local entry point,
and what its offset from the global entry point is. Note that GDB does
the same when setting a breakpoint on a function entry."
Signed-off-by: Naveen N. Rao <redacted>
---
Changes from previous patchset:
Generalize and introduce helper to prefer symbol table over DWARF.
tools/perf/arch/powerpc/util/sym-handling.c | 9 +++++++++
tools/perf/config/Makefile | 1 +
tools/perf/util/probe-event.c | 6 ++++++
tools/perf/util/probe-event.h | 6 ++++++
4 files changed, 22 insertions(+)
@@ -2373,6 +2373,12 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev,}}+if(prefer_symtab()&&!perf_probe_event_need_dwarf(pev)){+ret=find_probe_trace_events_from_map(pev,tevs,max_tevs,target);+if(ret>0)+returnret;/* Found in symbol table */+}+/* Convert perf_probe_event with debuginfo */ret=try_to_find_probe_trace_events(pev,tevs,max_tevs,target);if(ret!=0)
@@ -141,6 +141,12 @@ extern int show_available_funcs(const char *module, struct strfilter *filter,externintprobe_function_filter(structmap*map__maybe_unused,structsymbol*sym);+#ifdef ARCH_PREFER_SYMTAB+externboolprefer_symtab(void);+#else+staticinlineboolprefer_symtab(void){returnfalse;};+#endif+/* Maximum index number of event-name postfix */#define MAX_EVENT_INDEX 1024
From: Naveen N. Rao <hidden> Date: 2014-12-15 14:51:25
On powerpc ABIv2, if no debug-info is found and we use kallsyms, we need
to fixup the function entry to point to the local entry point. Use
offset of 8 since current toolchains always generate 2 instructions (8
bytes).
Signed-off-by: Naveen N. Rao <redacted>
---
Changes:
Generalize and introduce helper to post-process trace point.
tools/perf/arch/powerpc/util/sym-handling.c | 17 +++++++++++++++++
tools/perf/util/probe-event.c | 1 +
tools/perf/util/probe-event.h | 10 ++++++++++
3 files changed, 28 insertions(+)
@@ -147,6 +147,16 @@ extern bool prefer_symtab(void);staticinlineboolprefer_symtab(void){returnfalse;};#endif+#ifdef HAVE_ARCH_SYMBOL_HANDLING+externvoidarch_fix_tev_from_maps(structperf_probe_event*pev__maybe_unused,+structprobe_trace_event*tev__maybe_unused,+structmap*map__maybe_unused);+#else+staticinlinevoidarch_fix_tev_from_maps(structperf_probe_event*pev__maybe_unused,+structprobe_trace_event*tev__maybe_unused,+structmap*map__maybe_unused){}+#endif+/* Maximum index number of event-name postfix */#define MAX_EVENT_INDEX 1024
From: Naveen N. Rao <hidden> Date: 2014-12-15 14:52:01
PPC64 ELF ABIv2 has a Global Entry Point (GEP) and a Local Entry Point
(LEP). For purposes of probing, we need the LEP. Offset to the LEP is
encoded in st_other.
Signed-off-by: Ananth N Mavinakayanahalli <redacted>
Signed-off-by: Naveen N. Rao <redacted>
---
Changes from previous patchset:
Simplified logic by adding dependancy on HAVE_ARCH_SYMBOL_HANDLING. Also
generalized arch_elf_sym_decode() to be suitable for other architectures in
future.
tools/perf/arch/powerpc/util/sym-handling.c | 10 ++++++++++
tools/perf/util/symbol-elf.c | 2 ++
tools/perf/util/symbol.h | 6 ++++++
3 files changed, 18 insertions(+)
From: Naveen N. Rao <hidden> Date: 2014-12-15 14:52:55
Currently, all non-dot symbols are being treated as function descriptors
in ABIv1. This is incorrect and is resulting in perf probe not working:
# perf probe do_fork
Added new event:
Failed to write event: Invalid argument
Error: Failed to add events.
# dmesg | tail -1
[192268.073063] Could not insert probe at _text+768432: -22
perf probe bases all kernel probes on _text and writes,
for example, "p:probe/do_fork _text+768432" to
/sys/kernel/debug/tracing/kprobe_events. In-kernel, _text is being
considered to be a function descriptor and is resulting in the above
error.
Fix this by changing how we lookup symbol addresses on ppc64. We first
check for the dot variant of a symbol and look at the non-dot variant
only if that fails. In this manner, we avoid having to look at the
function descriptor.
While at it, also separate out how this works on ABIv2 where
we don't have dot symbols, but need to use the local entry point.
Signed-off-by: Naveen N. Rao <redacted>
---
Mike,
I have restricted all changes to just the kprobe_lookup_name() macro. It has
now been split into different implementations for ABIv1 and ABIv2, hopefully
addressing the concerns you raised previously.
- Naveen
arch/powerpc/include/asm/kprobes.h | 63 ++++++++++++++++++++++++++------------
1 file changed, 44 insertions(+), 19 deletions(-)
From: Naveen N. Rao <hidden> Date: 2015-01-28 05:43:16
On 2014/12/15 08:20PM, Naveen N Rao wrote:
This patchset fixes various issues with perf probe on powerpc across ABIv1 and
ABIv2:
- in the presence of DWARF debug-info,
- in the absence of DWARF, but with the symbol table, and
- in the absence of debug-info, but with kallsyms.
Applies cleanly on -tip. Tested on ppc64 BE and LE.
Changes from previous version:
Addressed various review comments from Mike Ellerman largely to generalize
changes. Some of the simpler patches have been retained in their previous form
to limit code churn, while others have been generalized by introducing arch
helpers. Individual patches have more details.
Michael,
Can you please take a quick look at this?
- Naveen
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2015-01-28 06:14:25
On Wed, 2015-01-28 at 11:12 +0530, Naveen N. Rao wrote:
On 2014/12/15 08:20PM, Naveen N Rao wrote:
quoted
This patchset fixes various issues with perf probe on powerpc across ABIv1 and
ABIv2:
- in the presence of DWARF debug-info,
- in the absence of DWARF, but with the symbol table, and
- in the absence of debug-info, but with kallsyms.
Applies cleanly on -tip. Tested on ppc64 BE and LE.
Changes from previous version:
Addressed various review comments from Mike Ellerman largely to generalize
changes. Some of the simpler patches have been retained in their previous form
to limit code churn, while others have been generalized by introducing arch
helpers. Individual patches have more details.
Michael,
Can you please take a quick look at this?
From: Naveen N. Rao <hidden> Date: 2015-01-28 06:43:32
On 2015/01/28 05:14PM, Michael Ellerman wrote:
On Wed, 2015-01-28 at 11:12 +0530, Naveen N. Rao wrote:
quoted
On 2014/12/15 08:20PM, Naveen N Rao wrote:
quoted
This patchset fixes various issues with perf probe on powerpc across ABIv1 and
ABIv2:
- in the presence of DWARF debug-info,
- in the absence of DWARF, but with the symbol table, and
- in the absence of debug-info, but with kallsyms.
Applies cleanly on -tip. Tested on ppc64 BE and LE.
Changes from previous version:
Addressed various review comments from Mike Ellerman largely to generalize
changes. Some of the simpler patches have been retained in their previous form
to limit code churn, while others have been generalized by introducing arch
helpers. Individual patches have more details.
Michael,
Can you please take a quick look at this?
Oh, thanks! Sorry, I didn't realize you had already merged it.
I assume you are ok with my changes in v2 w.r.t your previous review
comments.
Arnaldo,
Please have a look at this revision and let me know if you have any
other concerns. Also, I have missed including Ananth's "Reviewed-by" in
this patchset. I'm guessing Ananth is ok with this revision as well.
- Naveen
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2015-01-30 02:19:41
On Wed, 2015-01-28 at 12:13 +0530, Naveen N. Rao wrote:
On 2015/01/28 05:14PM, Michael Ellerman wrote:
quoted
On Wed, 2015-01-28 at 11:12 +0530, Naveen N. Rao wrote:
quoted
On 2014/12/15 08:20PM, Naveen N Rao wrote:
quoted
This patchset fixes various issues with perf probe on powerpc across ABIv1 and
ABIv2:
- in the presence of DWARF debug-info,
- in the absence of DWARF, but with the symbol table, and
- in the absence of debug-info, but with kallsyms.
Applies cleanly on -tip. Tested on ppc64 BE and LE.
Changes from previous version:
Addressed various review comments from Mike Ellerman largely to generalize
changes. Some of the simpler patches have been retained in their previous form
to limit code churn, while others have been generalized by introducing arch
helpers. Individual patches have more details.
Michael,
Can you please take a quick look at this?
From: Arnaldo Carvalho de Melo <acme@kernel.org> Date: 2015-03-12 20:23:48
Em Mon, Dec 15, 2014 at 08:20:33PM +0530, Naveen N. Rao escreveu:
If using the symbol table, symbol addresses are not being fixed up
properly, resulting in probes being placed at wrong addresses:
# perf probe do_fork
Added new event:
probe:do_fork (on do_fork)
You can now use it in all perf tools, such as:
perf record -e probe:do_fork -aR sleep 1
# cat /sys/kernel/debug/tracing/kprobe_events
p:probe/do_fork _text+635952
# printf "%x" 635952
9b430
# grep do_fork /boot/System.map
c0000000000ab430 T .do_fork
Fix by checking for ELF type ET_DYN used by ppc64 kernels.
Sorry if this was answered already, its been a while since this was
posted/discussed... Are you completely sure this is not a problem on
!ppc?
Woudln't it be more conservative to somehow only adjust symbols for this
ET_DYN type if the arch is ppc? I.e. something like moving that
adjust_symbols logic to be arch_adjust_symbols(), provide a default and
then override it for ppc to include also ET_DYN?
Looking at the other patches...
- Arnaldo
From: Arnaldo Carvalho de Melo <acme@kernel.org> Date: 2015-03-12 20:24:20
Em Mon, Dec 15, 2014 at 08:20:32PM +0530, Naveen N. Rao escreveu:
Currently, perf probe considers patterns including a '.' to be a file.
However, this causes problems on powerpc ABIv1 where all functions have
a leading '.':
$ perf probe -F | grep schedule_timeout_interruptible
.schedule_timeout_interruptible
$ perf probe .schedule_timeout_interruptible
Semantic error :File always requires line number or lazy pattern.
Error: Command Parse Error.
Fix this by checking the probe pattern in more detail.
Masami, can I have your Acked-by or Reviewed-by?
- Arnaldo
@@ -999,6 +999,24 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)arg=tmp;}+/*+*Checkargisfunctionorfilenameandcopyit.+*+*Weconsiderargtobeafilespecifandonlyifitsatisfies+*allofthebelowcriteria::+*-itdoesnotincludeanyof"+@%",+*-itincludesoneof":;",and+*-ithasaperiod'.'inthename.+*+*Otherwise,weconsiderargtobeafunctionspecification.+*/+c=0;+if(!strpbrk(arg,"+@%")&&(ptr=strpbrk(arg,";:"))!=NULL){+/* This is a file spec if it includes a '.' before ; or : */+if(memchr(arg,'.',ptr-arg))+c=1;+}+ptr=strpbrk(arg,";:+@%");if(ptr){nc=*ptr;
@@ -1009,10 +1027,9 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)if(tmp==NULL)return-ENOMEM;-/* Check arg is function or file and copy it */-if(strchr(tmp,'.'))/* File */+if(c==1)pp->file=tmp;-else/* Function */+elsepp->function=tmp;/* Parse other options */
From: Arnaldo Carvalho de Melo <acme@kernel.org> Date: 2015-03-12 20:25:20
Em Thu, Mar 12, 2015 at 05:24:14PM -0300, Arnaldo Carvalho de Melo escreveu:
Em Mon, Dec 15, 2014 at 08:20:32PM +0530, Naveen N. Rao escreveu:
quoted
Currently, perf probe considers patterns including a '.' to be a file.
However, this causes problems on powerpc ABIv1 where all functions have
a leading '.':
$ perf probe -F | grep schedule_timeout_interruptible
.schedule_timeout_interruptible
$ perf probe .schedule_timeout_interruptible
Semantic error :File always requires line number or lazy pattern.
Error: Command Parse Error.
Fix this by checking the probe pattern in more detail.
Masami, can I have your Acked-by or Reviewed-by?
It is limited to powerpc, but I would even so be happy if you could look
at it,
Thanks,
- Arnaldo
@@ -999,6 +999,24 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)arg=tmp;}+/*+*Checkargisfunctionorfilenameandcopyit.+*+*Weconsiderargtobeafilespecifandonlyifitsatisfies+*allofthebelowcriteria::+*-itdoesnotincludeanyof"+@%",+*-itincludesoneof":;",and+*-ithasaperiod'.'inthename.+*+*Otherwise,weconsiderargtobeafunctionspecification.+*/+c=0;+if(!strpbrk(arg,"+@%")&&(ptr=strpbrk(arg,";:"))!=NULL){+/* This is a file spec if it includes a '.' before ; or : */+if(memchr(arg,'.',ptr-arg))+c=1;+}+ptr=strpbrk(arg,";:+@%");if(ptr){nc=*ptr;
@@ -1009,10 +1027,9 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)if(tmp==NULL)return-ENOMEM;-/* Check arg is function or file and copy it */-if(strchr(tmp,'.'))/* File */+if(c==1)pp->file=tmp;-else/* Function */+elsepp->function=tmp;/* Parse other options */
From: Arnaldo Carvalho de Melo <acme@kernel.org> Date: 2015-03-12 20:28:23
Em Mon, Dec 15, 2014 at 08:20:34PM +0530, Naveen N. Rao escreveu:
quoted hunk
Fix up various perf aspects related to ppc64's usage of dot functions:
- ignore leading '.' when generating event names and when looking for
existing events.
- use the proper prefix when ignoring SyS symbol lookups.
Signed-off-by: Naveen N. Rao <redacted>
---
tools/perf/util/probe-event.c | 8 ++++++++
tools/perf/util/symbol.c | 6 ++++++
2 files changed, 14 insertions(+)
@@ -2080,6 +2080,10 @@ static int get_new_event_name(char *buf, size_t len, const char *base,{inti,ret;+/* Skip the leading dot on powerpc */+if(*base=='.')+base++;+/* Try no suffix */ret=e_snprintf(buf,len,"%s",base);if(ret<0){
@@ -2538,6 +2542,10 @@ int del_perf_probe_events(struct strlist *dellist)event=str;}+/* Skip the leading dot on powerpc */
Ok, but this is not powerpc specific code, is it?
quoted hunk
+ if (event && *event == '.')
+ event++;
+
ret = e_snprintf(buf, 128, "%s:%s", group, event);
if (ret < 0) {
pr_err("Failed to copy event.");
@@ -139,6 +139,12 @@ static int choose_best_symbol(struct symbol *syma, struct symbol *symb)if(na>=10&&!strncmp(syma->name,"compat_SyS",10))returnSYMBOL_B;+/* On powerpc, ignore the dot variants */+if(na>=4&&!strncmp(syma->name,".SyS",4))+returnSYMBOL_B;+if(na>=11&&!strncmp(syma->name,".compat_SyS",11))+returnSYMBOL_B;+returnSYMBOL_A;}
From: Arnaldo Carvalho de Melo <acme@kernel.org> Date: 2015-03-12 20:31:06
Em Mon, Dec 15, 2014 at 08:20:35PM +0530, Naveen N. Rao escreveu:
Allow perf probe to work on powerpc ABIv1 without the need to specify
the leading dot '.' for functions. 'perf probe do_fork' works with this
patch.
Introduce HAVE_ARCH_SYMBOL_HANDLING to indicate need for special
handling of symbols. In this patch, we override probe_function_filter()
on powerpc to account for dot symbols.
This one looks better, does arch specific stuff in tools/perf/arch,
good, some nits below.
quoted hunk
Signed-off-by: Naveen N. Rao <redacted>
---
Changes from the previous patchset:
Introduced arch helper to override the way probe function filter works.
tools/perf/arch/powerpc/Makefile | 1 +
tools/perf/arch/powerpc/util/sym-handling.c | 28 ++++++++++++++++++++++++++++
tools/perf/config/Makefile | 1 +
tools/perf/util/probe-event.c | 10 +++++-----
tools/perf/util/probe-event.h | 5 +++++
5 files changed, 40 insertions(+), 5 deletions(-)
create mode 100644 tools/perf/arch/powerpc/util/sym-handling.c
Can't we do something like providing a weak function and let the linked
to its work? I guess we have cases like this in tools/ already. I.e. not
using the ifndef block. Minor nit tho.
/* kprobe-tracer and uprobe-tracer tracing point */
struct probe_trace_point {
@@ -136,6 +138,9 @@ extern int show_available_vars(struct perf_probe_event *pevs, int npevs, extern int show_available_funcs(const char *module, struct strfilter *filter, bool user);+extern int probe_function_filter(struct map *map __maybe_unused,+ struct symbol *sym);+
Please do not prefix function declarations with 'extern', even when we
have one just before, its not needed, patches removing the existing ones
would be accepted.
/* Maximum index number of event-name postfix */
#define MAX_EVENT_INDEX 1024
--
2.1.3
From: Arnaldo Carvalho de Melo <acme@kernel.org> Date: 2015-03-12 20:35:09
Em Mon, Dec 15, 2014 at 08:20:36PM +0530, Naveen N. Rao escreveu:
quoted hunk
PPC64 ELF ABIv2 has a Global Entry Point (GEP) and a Local Entry Point
(LEP). For purposes of probing, we need the LEP. Offset to the LEP is
encoded in st_other.
Signed-off-by: Ananth N Mavinakayanahalli <redacted>
Signed-off-by: Naveen N. Rao <redacted>
---
Changes from previous patchset:
Simplified logic by adding dependancy on HAVE_ARCH_SYMBOL_HANDLING. Also
generalized arch_elf_sym_decode() to be suitable for other architectures in
future.
tools/perf/arch/powerpc/util/sym-handling.c | 10 ++++++++++
tools/perf/util/symbol-elf.c | 2 ++
tools/perf/util/symbol.h | 6 ++++++
3 files changed, 18 insertions(+)
From: Arnaldo Carvalho de Melo <acme@kernel.org> Date: 2015-03-12 20:37:16
Em Mon, Dec 15, 2014 at 08:20:38PM +0530, Naveen N. Rao escreveu:
On powerpc ABIv2, if no debug-info is found and we use kallsyms, we need
to fixup the function entry to point to the local entry point. Use
offset of 8 since current toolchains always generate 2 instructions (8
bytes).
So perhaps we should rename ARCH_SYMBOL_HANDLING to ARCH_ABI_SYMBOL_FIXUPS?
@@ -147,6 +147,16 @@ extern bool prefer_symtab(void);staticinlineboolprefer_symtab(void){returnfalse;};#endif+#ifdef HAVE_ARCH_SYMBOL_HANDLING+externvoidarch_fix_tev_from_maps(structperf_probe_event*pev__maybe_unused,+structprobe_trace_event*tev__maybe_unused,+structmap*map__maybe_unused);+#else+staticinlinevoidarch_fix_tev_from_maps(structperf_probe_event*pev__maybe_unused,+structprobe_trace_event*tev__maybe_unused,+structmap*map__maybe_unused){}+#endif+/* Maximum index number of event-name postfix */#define MAX_EVENT_INDEX 1024
From: Ananth N Mavinakayanahalli <hidden> Date: 2015-03-13 02:02:05
On Thu, Mar 12, 2015 at 05:24:14PM -0300, Arnaldo Carvalho de Melo wrote:
Em Mon, Dec 15, 2014 at 08:20:32PM +0530, Naveen N. Rao escreveu:
quoted
Currently, perf probe considers patterns including a '.' to be a file.
However, this causes problems on powerpc ABIv1 where all functions have
a leading '.':
$ perf probe -F | grep schedule_timeout_interruptible
.schedule_timeout_interruptible
$ perf probe .schedule_timeout_interruptible
Semantic error :File always requires line number or lazy pattern.
Error: Command Parse Error.
Fix this by checking the probe pattern in more detail.
Masami, can I have your Acked-by or Reviewed-by?
Arnaldo,
FWIW, I have reviewed this code...
Reviewed-by: Ananth N Mavinakayanahalli <redacted>
@@ -999,6 +999,24 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)arg=tmp;}+/*+*Checkargisfunctionorfilenameandcopyit.+*+*Weconsiderargtobeafilespecifandonlyifitsatisfies+*allofthebelowcriteria::+*-itdoesnotincludeanyof"+@%",+*-itincludesoneof":;",and+*-ithasaperiod'.'inthename.+*+*Otherwise,weconsiderargtobeafunctionspecification.+*/+c=0;+if(!strpbrk(arg,"+@%")&&(ptr=strpbrk(arg,";:"))!=NULL){+/* This is a file spec if it includes a '.' before ; or : */+if(memchr(arg,'.',ptr-arg))+c=1;+}+ptr=strpbrk(arg,";:+@%");if(ptr){nc=*ptr;
@@ -1009,10 +1027,9 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)if(tmp==NULL)return-ENOMEM;-/* Check arg is function or file and copy it */-if(strchr(tmp,'.'))/* File */+if(c==1)pp->file=tmp;-else/* Function */+elsepp->function=tmp;/* Parse other options */
(2015/03/13 5:24), Arnaldo Carvalho de Melo wrote:
Em Mon, Dec 15, 2014 at 08:20:32PM +0530, Naveen N. Rao escreveu:
quoted
Currently, perf probe considers patterns including a '.' to be a file.
However, this causes problems on powerpc ABIv1 where all functions have
a leading '.':
$ perf probe -F | grep schedule_timeout_interruptible
.schedule_timeout_interruptible
$ perf probe .schedule_timeout_interruptible
Semantic error :File always requires line number or lazy pattern.
Error: Command Parse Error.
Fix this by checking the probe pattern in more detail.
Masami, can I have your Acked-by or Reviewed-by?
As far as I can see, this is not enough for fixing that issue.
Could you fold the first half of [4/8] to this patch?
I also have some comments on it. See below.
Oh please, don't reuse 'char c' for a boolean flag, you should
introduce new 'bool file_loc' etc.
quoted
+ if (!strpbrk(arg, "+@%") && (ptr = strpbrk(arg, ";:")) != NULL) {
+ /* This is a file spec if it includes a '.' before ; or : */
+ if (memchr(arg, '.', ptr-arg))
^^ add spaces around '-'.
Thank you,
quoted
+ c = 1;
+ }
+
ptr = strpbrk(arg, ";:+@%");
if (ptr) {
nc = *ptr;
@@ -1009,10 +1027,9 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev) if (tmp == NULL) return -ENOMEM;- /* Check arg is function or file and copy it */- if (strchr(tmp, '.')) /* File */+ if (c == 1) pp->file = tmp;- else /* Function */+ else pp->function = tmp; /* Parse other options */
--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com
From: Naveen N. Rao <hidden> Date: 2015-04-27 05:06:00
On 2015/03/13 08:20PM, Masami Hiramatsu wrote:
(2015/03/13 5:24), Arnaldo Carvalho de Melo wrote:
quoted
Em Mon, Dec 15, 2014 at 08:20:32PM +0530, Naveen N. Rao escreveu:
quoted
Currently, perf probe considers patterns including a '.' to be a file.
However, this causes problems on powerpc ABIv1 where all functions have
a leading '.':
$ perf probe -F | grep schedule_timeout_interruptible
.schedule_timeout_interruptible
$ perf probe .schedule_timeout_interruptible
Semantic error :File always requires line number or lazy pattern.
Error: Command Parse Error.
Fix this by checking the probe pattern in more detail.
Masami, can I have your Acked-by or Reviewed-by?
As far as I can see, this is not enough for fixing that issue.
Could you fold the first half of [4/8] to this patch?
Oh please, don't reuse 'char c' for a boolean flag, you should
introduce new 'bool file_loc' etc.
quoted
quoted
+ if (!strpbrk(arg, "+@%") && (ptr = strpbrk(arg, ";:")) != NULL) {
+ /* This is a file spec if it includes a '.' before ; or : */
+ if (memchr(arg, '.', ptr-arg))
From: Naveen N. Rao <hidden> Date: 2015-04-27 05:07:29
On 2015/03/12 05:23PM, Arnaldo Carvalho de Melo wrote:
Em Mon, Dec 15, 2014 at 08:20:33PM +0530, Naveen N. Rao escreveu:
quoted
If using the symbol table, symbol addresses are not being fixed up
properly, resulting in probes being placed at wrong addresses:
# perf probe do_fork
Added new event:
probe:do_fork (on do_fork)
You can now use it in all perf tools, such as:
perf record -e probe:do_fork -aR sleep 1
# cat /sys/kernel/debug/tracing/kprobe_events
p:probe/do_fork _text+635952
# printf "%x" 635952
9b430
# grep do_fork /boot/System.map
c0000000000ab430 T .do_fork
Fix by checking for ELF type ET_DYN used by ppc64 kernels.
Sorry if this was answered already, its been a while since this was
posted/discussed... Are you completely sure this is not a problem on
!ppc?
Woudln't it be more conservative to somehow only adjust symbols for this
ET_DYN type if the arch is ppc? I.e. something like moving that
adjust_symbols logic to be arch_adjust_symbols(), provide a default and
then override it for ppc to include also ET_DYN?
I did check and I don't think any other arch kernel uses ET_DYN, but
yes, being conservative, I could just make this a arch helper. Will do.
- Naveen
From: Naveen N. Rao <hidden> Date: 2015-04-27 05:08:56
On 2015/03/12 05:30PM, Arnaldo Carvalho de Melo wrote:
Em Mon, Dec 15, 2014 at 08:20:35PM +0530, Naveen N. Rao escreveu:
quoted
Allow perf probe to work on powerpc ABIv1 without the need to specify
the leading dot '.' for functions. 'perf probe do_fork' works with this
patch.
Introduce HAVE_ARCH_SYMBOL_HANDLING to indicate need for special
handling of symbols. In this patch, we override probe_function_filter()
on powerpc to account for dot symbols.
This one looks better, does arch specific stuff in tools/perf/arch,
good, some nits below.
quoted
Signed-off-by: Naveen N. Rao <redacted>
---
Changes from the previous patchset:
Introduced arch helper to override the way probe function filter works.
tools/perf/arch/powerpc/Makefile | 1 +
tools/perf/arch/powerpc/util/sym-handling.c | 28 ++++++++++++++++++++++++++++
tools/perf/config/Makefile | 1 +
tools/perf/util/probe-event.c | 10 +++++-----
tools/perf/util/probe-event.h | 5 +++++
5 files changed, 40 insertions(+), 5 deletions(-)
create mode 100644 tools/perf/arch/powerpc/util/sym-handling.c
Can't we do something like providing a weak function and let the linked
to its work? I guess we have cases like this in tools/ already. I.e. not
using the ifndef block. Minor nit tho.
That sounds like a good idea. I will move these over to use __weak
functions.
/* kprobe-tracer and uprobe-tracer tracing point */
struct probe_trace_point {
@@ -136,6 +138,9 @@ extern int show_available_vars(struct perf_probe_event *pevs, int npevs, extern int show_available_funcs(const char *module, struct strfilter *filter, bool user);+extern int probe_function_filter(struct map *map __maybe_unused,+ struct symbol *sym);+
Please do not prefix function declarations with 'extern', even when we
have one just before, its not needed, patches removing the existing ones
would be accepted.
Sure.
- Naveen
quoted
/* Maximum index number of event-name postfix */
#define MAX_EVENT_INDEX 1024
--
2.1.3
From: Naveen N. Rao <hidden> Date: 2015-04-27 05:11:27
On 2015/03/13 08:20PM, Masami Hiramatsu wrote:
(2015/03/13 5:24), Arnaldo Carvalho de Melo wrote:
quoted
Em Mon, Dec 15, 2014 at 08:20:32PM +0530, Naveen N. Rao escreveu:
quoted
Currently, perf probe considers patterns including a '.' to be a file.
However, this causes problems on powerpc ABIv1 where all functions have
a leading '.':
$ perf probe -F | grep schedule_timeout_interruptible
.schedule_timeout_interruptible
$ perf probe .schedule_timeout_interruptible
Semantic error :File always requires line number or lazy pattern.
Error: Command Parse Error.
Fix this by checking the probe pattern in more detail.
Masami, can I have your Acked-by or Reviewed-by?
As far as I can see, this is not enough for fixing that issue.
Could you fold the first half of [4/8] to this patch?
I also have some comments on it. See below.
Masami, Arnaldo,
Thanks for the review. v3 patches forthcoming...
- Naveen