Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1497656

[PATCH] perf, tools: Handle events including .c and .o

From Wang Nan <wangnan0@huawei.com>
Newsgroups linux.kernel
Subject [PATCH] perf, tools: Handle events including .c and .o
Date 2016-10-08 06:20 +0200
Message-ID <spRh7-28C-5@gated-at.bofh.it> (permalink)
References <spnj3-5PE-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


This patch helps with Sukadev's JSON event tree where such events can happen.

From Andi Kleen:
 Any event inclduing a .c/.o/.bpf currently triggers BPF compilation or loading
 and then an error. This can happen for some Intel JSON events, which cannot
 be used.

This patch fixes this problem by forbidding BPF file patch containing '{', '}'
and ',', make sure flex consumes the leading '{', instead of matcing it using
a BPF file path.

Tested result:

  $ perf stat -e '{unc_p_clockticks,unc_p_power_state_occupancy.cores_c0}' -a -I 1000
  invalid or unsupported event: '{unc_p_clockticks,unc_p_power_state_occupancy.cores_c0}'
  Run 'perf list' for a list of valid events
  (as expected, interperted as event)

  $ perf stat -e 'aaa.c' -a -I 1000
  ERROR: problems with path aaa.c: No such file or directory
  (as expected, interperted as BPF source)

  $ perf stat -e 'aaa.ccc' -a -I 1000
  invalid or unsupported event: 'aaa.ccc'
  (as expected, interperted as event)

  $ perf stat -e '{aaa.c}' -a -I 1000
  ERROR: problems with path aaa.c: No such file or directory
  event syntax error: '{aaa.c}'
  <SKIP>
  (as expected, interperted as BPF source)

  $ perf stat -e '{cycles,aaa.c}' -a -I 1000
  ERROR: problems with path aaa.c: No such file or directory
  event syntax error: '{cycles,aaa.c}'
  (as expected, interperted as BPF source)

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/parse-events.l | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 9f43fda..660fca0 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -136,8 +136,8 @@ do {							\
 group		[^,{}/]*[{][^}]*[}][^,{}/]*
 event_pmu	[^,{}/]+[/][^/]*[/][^,{}/]*
 event		[^,{}/]+
-bpf_object	.*\.(o|bpf)
-bpf_source	.*\.c
+bpf_object	[^,{}]+\.(o|bpf)
+bpf_source	[^,{}]+\.c
 
 num_dec		[0-9]+
 num_hex		0x[a-fA-F0-9]+
-- 
1.8.3.4

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] perf, tools: Handle events including .c and .o Andi Kleen <andi@firstfloor.org> - 2016-10-05 21:50 +0200
  Re: [PATCH 1/3] perf, tools: Handle events including .c and .o Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-06 00:50 +0200
    Re: [PATCH 1/3] perf, tools: Handle events including .c and .o Andi Kleen <andi@firstfloor.org> - 2016-10-06 19:00 +0200
      Re: [PATCH 1/3] perf, tools: Handle events including .c and .o Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-06 22:20 +0200
  Re: [PATCH 1/3] perf, tools: Handle events including .c and .o Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-06 22:20 +0200
    Re: [PATCH 1/3] perf, tools: Handle events including .c and .o "Wangnan (F)" <wangnan0@huawei.com> - 2016-10-08 06:10 +0200
    [PATCH] perf, tools: Handle events including .c and .o Wang Nan <wangnan0@huawei.com> - 2016-10-08 06:20 +0200

csiph-web