mszabc
Posts: 8
Joined: Sun Apr 07, 2013 9:27 pm

[rpi2] How to enable HW performance counters

Sat Mar 07, 2015 10:42 am

Hello,
I would like to use hw performance counters on RPi2. It could be DS-5 streamline of perf tool.
To do that I've followed instructions from ARM site:
http://infocenter.arm.com/help/index.js ... 00479.html

Kernel has been recompiled with all required options. Gator daemon and module build against new kernel can be started without problem. But perf can't find any hw performance event and streamline runs in limited mode (cycles only) with following warning:
ARM Processor PMU event counters have been detected, however the event counters are reading zeroes. Event counters include those counters listed in the counter configuration options dialog under the core name but exclude the cycle counter (Clock:Cycles) as it is controlled by a dedicated counter. It is possible that the PMU configuration bit DBGEN has not been enabled, and counter values subsequently will always read as zero. To remedy, please update your firmware or Linux kernel to enable DBGEN.
Maybe someone already walked through this? Is it even possible to use such stuff on rpi2?

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5551
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: [rpi2] How to enable HW performance counters

Sat Mar 07, 2015 11:27 am

With latest (rpi-update) kernel I get:

Code: Select all

pi@raspberrypi:~ $ ./perf list

List of pre-defined events (to be used in -e):
  cpu-cycles OR cycles                               [Hardware event]
  instructions                                       [Hardware event]
  cache-references                                   [Hardware event]
  cache-misses                                       [Hardware event]
  branch-instructions OR branches                    [Hardware event]
  branch-misses                                      [Hardware event]
  bus-cycles                                         [Hardware event]

  cpu-clock                                          [Software event]
  task-clock                                         [Software event]
  page-faults OR faults                              [Software event]
  context-switches OR cs                             [Software event]
  cpu-migrations OR migrations                       [Software event]
  minor-faults                                       [Software event]
  major-faults                                       [Software event]
  alignment-faults                                   [Software event]
  emulation-faults                                   [Software event]
  dummy                                              [Software event]

  L1-dcache-loads                                    [Hardware cache event]
  L1-dcache-load-misses                              [Hardware cache event]
  L1-dcache-stores                                   [Hardware cache event]
  L1-dcache-store-misses                             [Hardware cache event]
  L1-icache-loads                                    [Hardware cache event]
  L1-icache-load-misses                              [Hardware cache event]
  LLC-loads                                          [Hardware cache event]
  LLC-load-misses                                    [Hardware cache event]
  LLC-stores                                         [Hardware cache event]
  LLC-store-misses                                   [Hardware cache event]
  dTLB-load-misses                                   [Hardware cache event]
  dTLB-store-misses                                  [Hardware cache event]
  iTLB-load-misses                                   [Hardware cache event]
  branch-loads                                       [Hardware cache event]
  branch-load-misses                                 [Hardware cache event]

  rNNN                                               [Raw hardware event descriptor]
  cpu/t1=v1[,t2=v2,t3 ...]/modifier                  [Raw hardware event descriptor]
   (see 'man perf-list' on how to encode it)

  mem:<addr>[:access]                                [Hardware breakpoint]

  [ Tracepoints not available: No such file or directory ]
Are you seeing that?

mszabc
Posts: 8
Joined: Sun Apr 07, 2013 9:27 pm

Re: [rpi2] How to enable HW performance counters

Sat Mar 07, 2015 11:49 am

dom wrote:With latest (rpi-update) kernel I get:
Yes! rpi-update did the trick.
Thanks.

BTW is there any way to check which kernel options have been enabled in one installed by rpi-update?
It still would be grat to compile kernel on my own and have these features included.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5551
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: [rpi2] How to enable HW performance counters

Sat Mar 07, 2015 12:18 pm

mszabc wrote: BTW is there any way to check which kernel options have been enabled in one installed by rpi-update?
It still would be grat to compile kernel on my own and have these features included.

Code: Select all

zcat /proc/config.gz

mszabc
Posts: 8
Joined: Sun Apr 07, 2013 9:27 pm

Re: [rpi2] How to enable HW performance counters

Sat Mar 07, 2015 3:54 pm

dom wrote:

Code: Select all

zcat /proc/config.gz
Hmm, that's strange. Differences between this output and my .config are really minor. And when used .config form 'working" kernel, after recompilation these HW events are still not available.
I guess I'm still missing some point.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5551
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: [rpi2] How to enable HW performance counters

Sat Mar 07, 2015 4:40 pm

mszabc wrote:
dom wrote: Hmm, that's strange. Differences between this output and my .config are really minor. And when used .config form 'working" kernel, after recompilation these HW events are still not available.
I guess I'm still missing some point.
The device tree blob?
https://github.com/raspberrypi/linux/co ... caa0aa3c00

mszabc
Posts: 8
Joined: Sun Apr 07, 2013 9:27 pm

Re: [rpi2] How to enable HW performance counters

Sat Mar 07, 2015 5:43 pm

Nope, I have exactly the same.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5551
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: [rpi2] How to enable HW performance counters

Sat Mar 07, 2015 6:24 pm

I'd suggest you try building a completely unchanged kernel (using bcm2709_defconfig as the config), and confirm it works the same as the rpi-update version.
Assuming it does, then make your changes very carefully, testing after each change.

Return to “Raspberry Pi OS”