All of lore.kernel.org
 help / color / mirror / Atom feed
* Some minor fixes for the perf tools json event code
@ 2016-10-05 19:47 Andi Kleen
  2016-10-05 19:47 ` [PATCH 1/3] perf, tools: Handle events including .c and .o Andi Kleen
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Andi Kleen @ 2016-10-05 19:47 UTC (permalink / raw)
  To: acme; +Cc: sukadev, jolsa, linux-kernel

Fix some issues that turned up in recent testing.

-Andi

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/3] perf, tools: Handle events including .c and .o
  2016-10-05 19:47 Some minor fixes for the perf tools json event code Andi Kleen
@ 2016-10-05 19:47 ` Andi Kleen
  2016-10-05 22:47   ` Arnaldo Carvalho de Melo
  2016-10-06 20:18   ` Arnaldo Carvalho de Melo
  2016-10-05 19:47 ` [PATCH 2/3] perf, tools: Handle completion of upper case events Andi Kleen
  2016-10-05 19:47 ` [PATCH 3/3] perf, tools: Fix Intel fixed counter conversions Andi Kleen
  2 siblings, 2 replies; 15+ messages in thread
From: Andi Kleen @ 2016-10-05 19:47 UTC (permalink / raw)
  To: acme; +Cc: sukadev, jolsa, linux-kernel, Andi Kleen, wangnan0

From: Andi Kleen <ak@linux.intel.com>

This is a generic bug fix, but it helps with Sukadev's JSON event tree
where such events can happen.

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.

Fix the scanner to only match for .o or .c or .bpf at the end.
This will prevent loading multiple BPF scripts separated with comma,
but I assume this is acceptable.

Cc: wangnan0@huawei.com
Cc: sukadev@linux.vnet.ibm.com
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 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 9f43fda2570f..377147088a46 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -183,8 +183,8 @@ modifier_bp	[rwx]{1,3}
 		}
 
 {event_pmu}	|
-{bpf_object}	|
-{bpf_source}	|
+({bpf_object}$)	|
+({bpf_source}$)	|
 {event}		{
 			BEGIN(INITIAL);
 			REWIND(1);
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/3] perf, tools: Handle completion of upper case events
  2016-10-05 19:47 Some minor fixes for the perf tools json event code Andi Kleen
  2016-10-05 19:47 ` [PATCH 1/3] perf, tools: Handle events including .c and .o Andi Kleen
@ 2016-10-05 19:47 ` Andi Kleen
  2016-10-05 21:50   ` Arnaldo Carvalho de Melo
  2016-10-05 19:47 ` [PATCH 3/3] perf, tools: Fix Intel fixed counter conversions Andi Kleen
  2 siblings, 1 reply; 15+ messages in thread
From: Andi Kleen @ 2016-10-05 19:47 UTC (permalink / raw)
  To: acme; +Cc: sukadev, jolsa, linux-kernel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Vendor events are often specified in upper case. perf list outputs them
in lower case. Handle this case in perf-completion.sh so that
completion on the upper case events still works.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/perf-completion.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
index 3ba80b2359cc..48e7a01b5c91 100644
--- a/tools/perf/perf-completion.sh
+++ b/tools/perf/perf-completion.sh
@@ -161,7 +161,11 @@ __perf_main ()
 	# List possible events for -e option
 	elif [[ $prev == @("-e"|"--event") &&
 		$prev_skip_opts == @(record|stat|top) ]]; then
-		evts=$($cmd list --raw-dump)
+		# handle upper case events
+		case "$cur" in
+			[A-Z]*) evts=$($cmd list --raw-dump | tr a-z A-Z) ;;
+			*) evts=$($cmd list --raw-dump) ;;
+		esac
 		__perfcomp_colon "$evts" "$cur"
 	else
 		# List subcommands for perf commands
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/3] perf, tools: Fix Intel fixed counter conversions
  2016-10-05 19:47 Some minor fixes for the perf tools json event code Andi Kleen
  2016-10-05 19:47 ` [PATCH 1/3] perf, tools: Handle events including .c and .o Andi Kleen
  2016-10-05 19:47 ` [PATCH 2/3] perf, tools: Handle completion of upper case events Andi Kleen
@ 2016-10-05 19:47 ` Andi Kleen
  2016-10-06 22:41   ` [tip:perf/urgent] perf jevents: Fix Intel JSON " tip-bot for Andi Kleen
  2 siblings, 1 reply; 15+ messages in thread
From: Andi Kleen @ 2016-10-05 19:47 UTC (permalink / raw)
  To: acme; +Cc: sukadev, jolsa, linux-kernel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Intel fixed counters are special cases in the JSON conversion process
because their decoding differs between perf and the event files.
Add some missing entries in the conversion table.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/pmu-events/jevents.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index 79c2133bc534..41611d7f9873 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -312,6 +312,8 @@ static struct fixed {
 	const char *event;
 } fixed[] = {
 	{ "inst_retired.any", "event=0xc0" },
+	{ "inst_retired.any_p", "event=0xc0" },
+	{ "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" },
 	{ "cpu_clk_unhalted.thread", "event=0x3c" },
 	{ "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" },
 	{ NULL, NULL},
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/3] perf, tools: Handle completion of upper case events
  2016-10-05 19:47 ` [PATCH 2/3] perf, tools: Handle completion of upper case events Andi Kleen
@ 2016-10-05 21:50   ` Arnaldo Carvalho de Melo
  2016-10-05 22:18     ` Andi Kleen
  0 siblings, 1 reply; 15+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-10-05 21:50 UTC (permalink / raw)
  To: Andi Kleen; +Cc: sukadev, jolsa, linux-kernel, Andi Kleen

Em Wed, Oct 05, 2016 at 12:47:11PM -0700, Andi Kleen escreveu:
> From: Andi Kleen <ak@linux.intel.com>
> 
> Vendor events are often specified in upper case. perf list outputs them
> in lower case. Handle this case in perf-completion.sh so that
> completion on the upper case events still works.

Humm, I just tried without your patch:

[root@jouet ~]# . ~acme/git/linux/tools/perf/perf-completion.sh 
[root@jouet ~]# perf stat -e cpu_clk_<TAB>
cpu_clk_thread_unhalted.one_thread_active  cpu_clk_unhalted.ref_tsc                   cpu_clk_unhalted.thread_any
cpu_clk_thread_unhalted.ref_xclk           cpu_clk_unhalted.ref_xclk                  cpu_clk_unhalted.thread_p
cpu_clk_thread_unhalted.ref_xclk_any       cpu_clk_unhalted.ref_xclk_any              cpu_clk_unhalted.thread_p_any
cpu_clk_unhalted.one_thread_active         cpu_clk_unhalted.thread                    
[root@jouet ~]# perf stat -e cpu_clk_

And then with it:

[root@jouet ~]# perf stat -e cpu<TAB>

And I get just beeps for the common case, i.e. lowercase, then if I try with
uppercase it works:

[root@jouet ~]# perf stat -e CPU_CLK_
CPU_CLK_THREAD_UNHALTED.ONE_THREAD_ACTIVE  CPU_CLK_UNHALTED.REF_TSC                   CPU_CLK_UNHALTED.THREAD_ANY
CPU_CLK_THREAD_UNHALTED.REF_XCLK           CPU_CLK_UNHALTED.REF_XCLK                  CPU_CLK_UNHALTED.THREAD_P
CPU_CLK_THREAD_UNHALTED.REF_XCLK_ANY       CPU_CLK_UNHALTED.REF_XCLK_ANY              CPU_CLK_UNHALTED.THREAD_P_ANY
CPU_CLK_UNHALTED.ONE_THREAD_ACTIVE         CPU_CLK_UNHALTED.THREAD                    
[root@jouet ~]#

[root@jouet ~]# bash --version
GNU bash, version 4.3.42(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[root@jouet ~]# 


 
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
>  tools/perf/perf-completion.sh | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
> index 3ba80b2359cc..48e7a01b5c91 100644
> --- a/tools/perf/perf-completion.sh
> +++ b/tools/perf/perf-completion.sh
> @@ -161,7 +161,11 @@ __perf_main ()
>  	# List possible events for -e option
>  	elif [[ $prev == @("-e"|"--event") &&
>  		$prev_skip_opts == @(record|stat|top) ]]; then
> -		evts=$($cmd list --raw-dump)
> +		# handle upper case events
> +		case "$cur" in
> +			[A-Z]*) evts=$($cmd list --raw-dump | tr a-z A-Z) ;;
> +			*) evts=$($cmd list --raw-dump) ;;
> +		esac
>  		__perfcomp_colon "$evts" "$cur"
>  	else
>  		# List subcommands for perf commands
> -- 
> 2.5.5

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/3] perf, tools: Handle completion of upper case events
  2016-10-05 21:50   ` Arnaldo Carvalho de Melo
@ 2016-10-05 22:18     ` Andi Kleen
  2016-10-05 22:35       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 15+ messages in thread
From: Andi Kleen @ 2016-10-05 22:18 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Andi Kleen, sukadev, jolsa, linux-kernel, Andi Kleen

> [root@jouet ~]# bash --version
> GNU bash, version 4.3.42(1)-release (x86_64-redhat-linux-gnu)
> Copyright (C) 2013 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> 
> This is free software; you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> [root@jouet ~]# 

Probably a locale issue. Let me send a new patch.

-Andi

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/3] perf, tools: Handle completion of upper case events
  2016-10-05 22:18     ` Andi Kleen
@ 2016-10-05 22:35       ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 15+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-10-05 22:35 UTC (permalink / raw)
  To: Andi Kleen; +Cc: sukadev, jolsa, linux-kernel, Andi Kleen

Em Wed, Oct 05, 2016 at 03:18:05PM -0700, Andi Kleen escreveu:
> > [root@jouet ~]# bash --version
> > GNU bash, version 4.3.42(1)-release (x86_64-redhat-linux-gnu)
> > Copyright (C) 2013 Free Software Foundation, Inc.
> > License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> > 
> > This is free software; you are free to change and redistribute it.
> > There is NO WARRANTY, to the extent permitted by law.
> > [root@jouet ~]# 
> 
> Probably a locale issue. Let me send a new patch.

[root@jouet ~]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
[root@jouet ~]#

- Arnaldo

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/3] perf, tools: Handle events including .c and .o
  2016-10-05 19:47 ` [PATCH 1/3] perf, tools: Handle events including .c and .o Andi Kleen
@ 2016-10-05 22:47   ` Arnaldo Carvalho de Melo
  2016-10-06 16:55     ` Andi Kleen
  2016-10-06 20:18   ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 15+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-10-05 22:47 UTC (permalink / raw)
  To: Andi Kleen; +Cc: sukadev, jolsa, linux-kernel, Andi Kleen, wangnan0

Em Wed, Oct 05, 2016 at 12:47:10PM -0700, Andi Kleen escreveu:
> From: Andi Kleen <ak@linux.intel.com>
> 
> This is a generic bug fix, but it helps with Sukadev's JSON event tree
> where such events can happen.
> 
> 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.
> 
> Fix the scanner to only match for .o or .c or .bpf at the end.
> This will prevent loading multiple BPF scripts separated with comma,
> but I assume this is acceptable.

Wang, may I have your Acked-by, please?

- Arnaldo
 
> Cc: wangnan0@huawei.com
> Cc: sukadev@linux.vnet.ibm.com
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
>  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 9f43fda2570f..377147088a46 100644
> --- a/tools/perf/util/parse-events.l
> +++ b/tools/perf/util/parse-events.l
> @@ -183,8 +183,8 @@ modifier_bp	[rwx]{1,3}
>  		}
>  
>  {event_pmu}	|
> -{bpf_object}	|
> -{bpf_source}	|
> +({bpf_object}$)	|
> +({bpf_source}$)	|
>  {event}		{
>  			BEGIN(INITIAL);
>  			REWIND(1);
> -- 
> 2.5.5

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/3] perf, tools: Handle events including .c and .o
  2016-10-05 22:47   ` Arnaldo Carvalho de Melo
@ 2016-10-06 16:55     ` Andi Kleen
  2016-10-06 20:07       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 15+ messages in thread
From: Andi Kleen @ 2016-10-06 16:55 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Andi Kleen, sukadev, jolsa, linux-kernel, Andi Kleen, wangnan0

On Wed, Oct 05, 2016 at 07:47:06PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Oct 05, 2016 at 12:47:10PM -0700, Andi Kleen escreveu:
> > From: Andi Kleen <ak@linux.intel.com>
> > 
> > This is a generic bug fix, but it helps with Sukadev's JSON event tree
> > where such events can happen.
> > 
> > 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.
> > 
> > Fix the scanner to only match for .o or .c or .bpf at the end.
> > This will prevent loading multiple BPF scripts separated with comma,
> > but I assume this is acceptable.
> 
> Wang, may I have your Acked-by, please?

He acked it earlier here

https://patchwork.kernel.org/patch/9337721/

Tested-by: Wang Nan <wangnan0@huawei.com>

-Andi

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/3] perf, tools: Handle events including .c and .o
  2016-10-06 16:55     ` Andi Kleen
@ 2016-10-06 20:07       ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 15+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-10-06 20:07 UTC (permalink / raw)
  To: Andi Kleen; +Cc: sukadev, jolsa, linux-kernel, Andi Kleen, wangnan0

Em Thu, Oct 06, 2016 at 09:55:05AM -0700, Andi Kleen escreveu:
> On Wed, Oct 05, 2016 at 07:47:06PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Wed, Oct 05, 2016 at 12:47:10PM -0700, Andi Kleen escreveu:
> > > From: Andi Kleen <ak@linux.intel.com>
> > > 
> > > This is a generic bug fix, but it helps with Sukadev's JSON event tree
> > > where such events can happen.
> > > 
> > > 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.
> > > 
> > > Fix the scanner to only match for .o or .c or .bpf at the end.
> > > This will prevent loading multiple BPF scripts separated with comma,
> > > but I assume this is acceptable.
> > 
> > Wang, may I have your Acked-by, please?
> 
> He acked it earlier here
> 
> https://patchwork.kernel.org/patch/9337721/
> 
> Tested-by: Wang Nan <wangnan0@huawei.com>

Ok, will add the example where it breaks in the commit message,

Thanks,

- Arnaldo

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/3] perf, tools: Handle events including .c and .o
  2016-10-05 19:47 ` [PATCH 1/3] perf, tools: Handle events including .c and .o Andi Kleen
  2016-10-05 22:47   ` Arnaldo Carvalho de Melo
@ 2016-10-06 20:18   ` Arnaldo Carvalho de Melo
  2016-10-08  4:02     ` Wangnan (F)
  2016-10-08  4:16     ` [PATCH] " Wang Nan
  1 sibling, 2 replies; 15+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-10-06 20:18 UTC (permalink / raw)
  To: Andi Kleen; +Cc: sukadev, jolsa, linux-kernel, Andi Kleen, wangnan0

Em Wed, Oct 05, 2016 at 12:47:10PM -0700, Andi Kleen escreveu:
> From: Andi Kleen <ak@linux.intel.com>
> 
> This is a generic bug fix, but it helps with Sukadev's JSON event tree
> where such events can happen.
> 
> 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.
> 
> Fix the scanner to only match for .o or .c or .bpf at the end.
> This will prevent loading multiple BPF scripts separated with comma,
> but I assume this is acceptable.

So, I tried it with the example provided in the thread for a previous
version of this patch (IIRC) and it still fails:


[acme@jouet linux]$ perf stat -e '{unc_p_clockticks,unc_p_power_state_occupancy.cores_c0}' -a -I 1000
ERROR: problems with path {unc_p_clockticks,unc_p_power_state_occupancy.c: No such file or directory
event syntax error: '{unc_p_clockticks,unc_p_power_state_occupancy.cores_c0}'
                     \___ Failed to load {unc_p_clockticks,unc_p_power_state_occupancy.c from source: Error when compiling BPF scriptlet

(add -v to see detail)
Run 'perf list' for a list of valid events

 Usage: perf stat [<options>] [<command>]

    -e, --event <event>   event selector. use 'perf list' to list available events
[acme@jouet linux]$

And with another event that for sure is available on this machine:



[acme@jouet linux]$ perf stat -e '{uops_executed.core_cycles_ge_2}' -I 1000 usleep 10
ERROR: problems with path {uops_executed.c: No such file or directory
event syntax error: '{uops_executed.core_cycles_ge_2}'
                     \___ Failed to load {uops_executed.c from source: Error when compiling BPF scriptlet

(add -v to see detail)
Run 'perf list' for a list of valid events

 Usage: perf stat [<options>] [<command>]

    -e, --event <event>   event selector. use 'perf list' to list available events
[acme@jouet linux]$


I thought this was due to the Makefile not noticing the change in the .l files, but I made
sure I deleted the build dir and rebuilt from scratch, same problem.

- Arnaldo
 
> Cc: wangnan0@huawei.com
> Cc: sukadev@linux.vnet.ibm.com
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
>  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 9f43fda2570f..377147088a46 100644
> --- a/tools/perf/util/parse-events.l
> +++ b/tools/perf/util/parse-events.l
> @@ -183,8 +183,8 @@ modifier_bp	[rwx]{1,3}
>  		}
>  
>  {event_pmu}	|
> -{bpf_object}	|
> -{bpf_source}	|
> +({bpf_object}$)	|
> +({bpf_source}$)	|
>  {event}		{
>  			BEGIN(INITIAL);
>  			REWIND(1);
> -- 
> 2.5.5

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tip:perf/urgent] perf jevents: Fix Intel JSON fixed counter conversions
  2016-10-05 19:47 ` [PATCH 3/3] perf, tools: Fix Intel fixed counter conversions Andi Kleen
@ 2016-10-06 22:41   ` tip-bot for Andi Kleen
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Andi Kleen @ 2016-10-06 22:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, ak, sukadev, acme, linux-kernel, jolsa, hpa, mingo

Commit-ID:  72c6ff2583fba824dc38c0ce87b838631cdb8294
Gitweb:     http://git.kernel.org/tip/72c6ff2583fba824dc38c0ce87b838631cdb8294
Author:     Andi Kleen <ak@linux.intel.com>
AuthorDate: Wed, 5 Oct 2016 12:47:12 -0700
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 5 Oct 2016 18:41:06 -0300

perf jevents: Fix Intel JSON fixed counter conversions

Intel fixed counters are special cases in the JSON conversion process
because their decoding differs between perf and the event files.  Add
some missing entries in the conversion table.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1475696832-9188-4-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/pmu-events/jevents.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index 79c2133..41611d7 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -312,6 +312,8 @@ static struct fixed {
 	const char *event;
 } fixed[] = {
 	{ "inst_retired.any", "event=0xc0" },
+	{ "inst_retired.any_p", "event=0xc0" },
+	{ "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" },
 	{ "cpu_clk_unhalted.thread", "event=0x3c" },
 	{ "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" },
 	{ NULL, NULL},

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/3] perf, tools: Handle events including .c and .o
  2016-10-06 20:18   ` Arnaldo Carvalho de Melo
@ 2016-10-08  4:02     ` Wangnan (F)
  2016-10-08  4:16     ` [PATCH] " Wang Nan
  1 sibling, 0 replies; 15+ messages in thread
From: Wangnan (F) @ 2016-10-08  4:02 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Andi Kleen
  Cc: sukadev, jolsa, linux-kernel, Andi Kleen



On 2016/10/7 4:18, Arnaldo Carvalho de Melo wrote:
> Em Wed, Oct 05, 2016 at 12:47:10PM -0700, Andi Kleen escreveu:
>> From: Andi Kleen <ak@linux.intel.com>
>>
>> This is a generic bug fix, but it helps with Sukadev's JSON event tree
>> where such events can happen.
>>
>> 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.
>>
>> Fix the scanner to only match for .o or .c or .bpf at the end.
>> This will prevent loading multiple BPF scripts separated with comma,
>> but I assume this is acceptable.
> So, I tried it with the example provided in the thread for a previous
> version of this patch (IIRC) and it still fails:
>
>
> [acme@jouet linux]$ perf stat -e '{unc_p_clockticks,unc_p_power_state_occupancy.cores_c0}' -a -I 1000
> ERROR: problems with path {unc_p_clockticks,unc_p_power_state_occupancy.c: No such file or directory
> event syntax error: '{unc_p_clockticks,unc_p_power_state_occupancy.cores_c0}'
>                       \___ Failed to load {unc_p_clockticks,unc_p_power_state_occupancy.c from source: Error when compiling BPF scriptlet
>
> (add -v to see detail)
> Run 'perf list' for a list of valid events
>
>   Usage: perf stat [<options>] [<command>]
>
>      -e, --event <event>   event selector. use 'perf list' to list available events
> [acme@jouet linux]$
>
> And with another event that for sure is available on this machine:
>
>
>
> [acme@jouet linux]$ perf stat -e '{uops_executed.core_cycles_ge_2}' -I 1000 usleep 10
> ERROR: problems with path {uops_executed.c: No such file or directory
> event syntax error: '{uops_executed.core_cycles_ge_2}'
>                       \___ Failed to load {uops_executed.c from source: Error when compiling BPF scriptlet
>
> (add -v to see detail)
> Run 'perf list' for a list of valid events
>
>   Usage: perf stat [<options>] [<command>]
>
>      -e, --event <event>   event selector. use 'perf list' to list available events
> [acme@jouet linux]$
>
>
> I thought this was due to the Makefile not noticing the change in the .l files, but I made
> sure I deleted the build dir and rebuilt from scratch, same problem.
>
> - Arnaldo
>   

Tested again, and thank you for giving us another chance for fixing this :)

The key problem here is not the ending '$' but the leading '{'. Flex's
greedy maching policy makes this problem.

According to the design of parse-events.l, when it see something like
'...{...}...', it first matches a 'group' in '<event>' scope, then rewind
to INITIAL scope to match events in the group. In INITIAL scope, when
it see a '{', flex consume this char and goes back to '<event>' scope
to match next event. It works well before match BPF file path using
unlimited '.*\.c' because '.*' will match the leading '{' in INITIAL
scope without consuming it.

The simplest method for this problem is fixing the '.*' part: like
what we define for 'event', don't match ',', '{' and '}'. Doesn't
like 'event', '/' is required because this is a path.

Will post a patch for it. Please test it again.

Thank you.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH] perf, tools: Handle events including .c and .o
  2016-10-06 20:18   ` Arnaldo Carvalho de Melo
  2016-10-08  4:02     ` Wangnan (F)
@ 2016-10-08  4:16     ` Wang Nan
  2016-10-17 14:52       ` [tip:perf/urgent] perf jevents: " tip-bot for Wang Nan
  1 sibling, 1 reply; 15+ messages in thread
From: Wang Nan @ 2016-10-08  4:16 UTC (permalink / raw)
  To: acme
  Cc: lizefan, linux-kernel, pi3orama, ak, Wang Nan,
	Sukadev Bhattiprolu, Arnaldo Carvalho de Melo, Jiri Olsa

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [tip:perf/urgent] perf jevents: Handle events including .c and .o
  2016-10-08  4:16     ` [PATCH] " Wang Nan
@ 2016-10-17 14:52       ` tip-bot for Wang Nan
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Wang Nan @ 2016-10-17 14:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: lizefan, ak, hpa, linux-kernel, wangnan0, sukadev, acme, jolsa,
	tglx, mingo

Commit-ID:  2d470b62fa24f8d0024e8d392d28814c287ee1f1
Gitweb:     http://git.kernel.org/tip/2d470b62fa24f8d0024e8d392d28814c287ee1f1
Author:     Wang Nan <wangnan0@huawei.com>
AuthorDate: Sat, 8 Oct 2016 04:16:25 +0000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 17 Oct 2016 11:24:18 -0300

perf jevents: Handle events including .c and .o

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

>From Andi Kleen:
 Any event including a .c/.o/.bpf currently triggers BPF compilation or loading
 and then an error. This can happen for some Intel vendor 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 matching 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, interpreted as BPF source)

  $ perf stat -e 'aaa.ccc' -a -I 1000
  invalid or unsupported event: 'aaa.ccc'
  (as expected, interpreted 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, interpreted 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, interpreted as BPF source)

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Reported-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1475900185-37967-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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]+

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-10-17 14:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-05 19:47 Some minor fixes for the perf tools json event code Andi Kleen
2016-10-05 19:47 ` [PATCH 1/3] perf, tools: Handle events including .c and .o Andi Kleen
2016-10-05 22:47   ` Arnaldo Carvalho de Melo
2016-10-06 16:55     ` Andi Kleen
2016-10-06 20:07       ` Arnaldo Carvalho de Melo
2016-10-06 20:18   ` Arnaldo Carvalho de Melo
2016-10-08  4:02     ` Wangnan (F)
2016-10-08  4:16     ` [PATCH] " Wang Nan
2016-10-17 14:52       ` [tip:perf/urgent] perf jevents: " tip-bot for Wang Nan
2016-10-05 19:47 ` [PATCH 2/3] perf, tools: Handle completion of upper case events Andi Kleen
2016-10-05 21:50   ` Arnaldo Carvalho de Melo
2016-10-05 22:18     ` Andi Kleen
2016-10-05 22:35       ` Arnaldo Carvalho de Melo
2016-10-05 19:47 ` [PATCH 3/3] perf, tools: Fix Intel fixed counter conversions Andi Kleen
2016-10-06 22:41   ` [tip:perf/urgent] perf jevents: Fix Intel JSON " tip-bot for Andi Kleen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.