Skip to contentSkip to conversation

perf pmu-events: Fix the missing "cpu_clk_unhalted.core"

PATCH Applied Jin Yao 4 participants 7 messages Jul 29, 2019 – Aug 8, 2019 perf events

lore
Share & tools
lore

Jin Yao

author
#0 lore raw

PATCH 1/1 perf pmu-events: Fix the missing "cpu_clk_unhalted.core"

The events defined in pmu-events JSON are parsed and added into perf tool. For fixed counters, we handle the encodings between JSON and perf by using a static array fixed[].

But the fixed[] has missed an important event "cpu_clk_unhalted.core".

For example, on tremont platform,

[root@localhost ~]# perf stat -e cpu_clk_unhalted.core -a event syntax error: 'cpu_clk_unhalted.core'
\___ parser error

With this patch, the event cpu_clk_unhalted.core can be parsed.

[root@localhost perf]# ./perf stat -e cpu_clk_unhalted.core -a -vvv
------------------------------------------------------------
perf_event_attr:

  type                             4
  size                             112
  config                           0x3c
  sample_type                      IDENTIFIER
  read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
  disabled                         1
  inherit                          1
  exclude_guest                    1

------------------------------------------------------------
...

---
 tools/perf/pmu-events/jevents.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/pmu-events/jevents.c +1 -0
index 1a91a197cafb..d413761621b0 100644
@@ -453,6 +453,7 @@ static struct fixed {
 	{ "inst_retired.any_p", "event=0xc0" },
 	{ "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" },
 	{ "cpu_clk_unhalted.thread", "event=0x3c" },
+	{ "cpu_clk_unhalted.core", "event=0x3c" },
 	{ "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" },
 	{ NULL, NULL},
 };
Signature · 1 line
2.17.1
#1 lore raw

tools/perf/pmu-events/jevents.c static struct fixed { · line 456

Quoted 9 lines
tools/perf/pmu-events/jevents.c +1 -0
index 1a91a197cafb..d413761621b0 100644
@@ -453,6 +453,7 @@ static struct fixed {
 	{ "inst_retired.any_p", "event=0xc0" },
 	{ "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" },
 	{ "cpu_clk_unhalted.thread", "event=0x3c" },
+	{ "cpu_clk_unhalted.core", "event=0x3c" },

Not sure this is correct for non Atom.

On Atom thread==core, but that is not true with SMT/HyperThreading.

The big cores currently don't have this event, so it would match incorrectly.

This has to be handled on the event list level, perhaps with some enhancements.

-Andi

author
#2 lore raw
Quoted 14 lines · Andi Kleen

tools/perf/pmu-events/jevents.c static struct fixed { · line 456

Quoted 9 lines
tools/perf/pmu-events/jevents.c +1 -0
index 1a91a197cafb..d413761621b0 100644
@@ -453,6 +453,7 @@ static struct fixed {
  	{ "inst_retired.any_p", "event=0xc0" },
  	{ "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" },
  	{ "cpu_clk_unhalted.thread", "event=0x3c" },
+	{ "cpu_clk_unhalted.core", "event=0x3c" },

Not sure this is correct for non Atom.

On Atom thread==core, but that is not true with SMT/HyperThreading.

Quoted 8 lines

The big cores currently don't have this event, so it would match incorrectly.

This has to be handled on the event list level, perhaps with some enhancements.

-Andi

Hi Andi,

It is used to handle the fixed counter encodings between JSON and perf. If big cores don't have this event, nothing will be generated in perf list.

In big cores pipeline.json, there is only "CPU_CLK_UNHALTED.THREAD", and there is no "CPU_CLK_UNHALTED.CORE" defined. So at least for now, CPU_CLK_UNHALTED.CORE will not be generated for big core.

Thanks
Jin Yao

author
#3 lore raw
Quoted 26 lines · Yao
Quoted 14 lines · Andi Kleen

tools/perf/pmu-events/jevents.c static struct fixed { · line 456

Quoted 9 lines
tools/perf/pmu-events/jevents.c +1 -0
index 1a91a197cafb..d413761621b0 100644
@@ -453,6 +453,7 @@ static struct fixed {
       { "inst_retired.any_p", "event=0xc0" },
       { "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" },
       { "cpu_clk_unhalted.thread", "event=0x3c" },
+    { "cpu_clk_unhalted.core", "event=0x3c" },

Not sure this is correct for non Atom.

On Atom thread==core, but that is not true with SMT/HyperThreading.

Quoted 8 lines

The big cores currently don't have this event, so it would match incorrectly.

This has to be handled on the event list level, perhaps with some enhancements.

-Andi

Quoted 8 lines

Hi Andi,

It is used to handle the fixed counter encodings between JSON and perf. If big cores don't have this event, nothing will be generated in perf list.

In big cores pipeline.json, there is only "CPU_CLK_UNHALTED.THREAD", and there is no "CPU_CLK_UNHALTED.CORE" defined. So at least for now, CPU_CLK_UNHALTED.CORE will not be generated for big core.

Thanks
Jin Yao

Hi Andi,

Does this fix and the above explanation make sense?

Thanks
Jin Yao

#4 lore raw
In reply to Jin Yao

Em Mon, Jul 29, 2019 at 03:27:55PM +0800, Jin Yao escreveu:

Quoted 25 lines

The events defined in pmu-events JSON are parsed and added into perf tool. For fixed counters, we handle the encodings between JSON and perf by using a static array fixed[].

But the fixed[] has missed an important event "cpu_clk_unhalted.core".

For example, on tremont platform,

[root@localhost ~]# perf stat -e cpu_clk_unhalted.core -a event syntax error: 'cpu_clk_unhalted.core'
\___ parser error

With this patch, the event cpu_clk_unhalted.core can be parsed.

[root@localhost perf]# ./perf stat -e cpu_clk_unhalted.core -a -vvv
------------------------------------------------------------
perf_event_attr:

  type                             4
  size                             112
  config                           0x3c
  sample_type                      IDENTIFIER
  read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
  disabled                         1
  inherit                          1
  exclude_guest                    1
Quoted 1 line

------------------------------------------------------------

Thanks, applied, next time please do not add lines starting with ---, prefix it with two spaces so that git am scripts don't get confused.

- Arnaldo

Quoted 21 lines

...

---
 tools/perf/pmu-events/jevents.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/pmu-events/jevents.c +1 -0
index 1a91a197cafb..d413761621b0 100644
@@ -453,6 +453,7 @@ static struct fixed {
 	{ "inst_retired.any_p", "event=0xc0" },
 	{ "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" },
 	{ "cpu_clk_unhalted.thread", "event=0x3c" },
+	{ "cpu_clk_unhalted.core", "event=0x3c" },
 	{ "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" },
 	{ NULL, NULL},
 };
Signature · 1 line
2.17.1
Signature · 1 line
- Arnaldo
author
#5 lore raw
Quoted 28 lines · Arnaldo Carvalho de Melo

Em Mon, Jul 29, 2019 at 03:27:55PM +0800, Jin Yao escreveu:

Quoted 25 lines

The events defined in pmu-events JSON are parsed and added into perf tool. For fixed counters, we handle the encodings between JSON and perf by using a static array fixed[].

But the fixed[] has missed an important event "cpu_clk_unhalted.core".

For example, on tremont platform,

[root@localhost ~]# perf stat -e cpu_clk_unhalted.core -a event syntax error: 'cpu_clk_unhalted.core'
\___ parser error

With this patch, the event cpu_clk_unhalted.core can be parsed.

[root@localhost perf]# ./perf stat -e cpu_clk_unhalted.core -a -vvv
------------------------------------------------------------
perf_event_attr:

   type                             4
   size                             112
   config                           0x3c
   sample_type                      IDENTIFIER
   read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
   disabled                         1
   inherit                          1
   exclude_guest                    1
Quoted 1 line

------------------------------------------------------------

Quoted 6 lines

Thanks, applied, next time please do not add lines starting with ---, prefix it with two spaces so that git am scripts don't get confused.

- Arnaldo

Got it, thanks for reminding. I will be careful next time.

Thanks
Jin Yao

Quoted 22 lines
Quoted 21 lines

...

---
  tools/perf/pmu-events/jevents.c | 1 +
  1 file changed, 1 insertion(+)
tools/perf/pmu-events/jevents.c +1 -0
index 1a91a197cafb..d413761621b0 100644
@@ -453,6 +453,7 @@ static struct fixed {
  	{ "inst_retired.any_p", "event=0xc0" },
  	{ "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" },
  	{ "cpu_clk_unhalted.thread", "event=0x3c" },
+	{ "cpu_clk_unhalted.core", "event=0x3c" },
  	{ "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" },
  	{ NULL, NULL},
  };
Signature · 1 line
2.17.1
#6 lore raw

[tip:perf/urgent] perf pmu-events: Fix missing "cpu_clk_unhalted.core" event

In reply to Jin Yao
perf pmu-events: Fix missing "cpu_clk_unhalted.core" event
Commit-ID:  8e6e5bea2e34c61291d00cb3f47560341aa84bc3
Gitweb:     https://git.kernel.org/tip/8e6e5bea2e34c61291d00cb3f47560341aa84bc3
Author:     Jin Yao <[email protected]>
AuthorDate: Mon, 29 Jul 2019 15:27:55 +0800
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 8 Aug 2019 15:41:37 -0300

perf pmu-events: Fix missing "cpu_clk_unhalted.core" event

The events defined in pmu-events JSON are parsed and added into perf tool. For fixed counters, we handle the encodings between JSON and perf by using a static array fixed[].

But the fixed[] has missed an important event "cpu_clk_unhalted.core".

For example, on the Tremont platform,

[root@localhost ~]# perf stat -e cpu_clk_unhalted.core -a event syntax error: 'cpu_clk_unhalted.core'
\___ parser error

With this patch, the event cpu_clk_unhalted.core can be parsed.

[root@localhost perf]# ./perf stat -e cpu_clk_unhalted.core -a -vvv
------------------------------------------------------------
perf_event_attr:

    type                             4
    size                             112
    config                           0x3c
    sample_type                      IDENTIFIER
    read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
    disabled                         1
    inherit                          1
    exclude_guest                    1

------------------------------------------------------------
...

---
 tools/perf/pmu-events/jevents.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/pmu-events/jevents.c +1 -0
index 1a91a197cafb..d413761621b0 100644
@@ -453,6 +453,7 @@ static struct fixed {
 	{ "inst_retired.any_p", "event=0xc0" },
 	{ "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" },
 	{ "cpu_clk_unhalted.thread", "event=0x3c" },
+	{ "cpu_clk_unhalted.core", "event=0x3c" },
 	{ "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" },
 	{ NULL, NULL},
 };