I want to attach perf to a process and measure the package energy. As you can see below, the example shows that power/energy-pkg/
works fine.
$ perf stat -a -e power/energy-pkg/ -- sleep 1
Performance counter stats for 'system wide':
1,71 Joules power/energy-pkg/
1,019749321 seconds time elapsed
The C code gets the PID at the beginning and stops until a SIGCONT is received. With the following commands, I launch the program in background and grab the PID. Then I continue the execution and run perf with the PID.
$ ./app &
$ PID=`pidof app`
$ kill -SIGCONT $PID
$ perf stat -a -e power/energy-pkg -p $PID
Performance counter stats for process id '2590':
<not supported> Joules power/energy-pkg/
34,002655205 seconds time elapsed
As you can see the energy number is invalid. Any idea about this behavior?