Original mailing list thread:
http://marc.info/?l=oprofile-list&m=128508347501923&w=2
If a user starts a profile run with one set of counters, and then changes the counters they want to profile without shutting down the daemon, opreport reports on the old counters. Here is a sample session demonstrating the confusion:
[reid@muikyl profiling]$ sudo opcontrol --reset && sudo opcontrol
--start -e CPU_CLK_UNHALTED:400000 -e INST_RETIRED:400000 &&
./matrix_multiply && sudo opcontrol --stop
Signalling daemon... done
Profiler running.
Setup
Running matrix_multiply_run()...
Elapsed execution time: 11.496006 sec
Stopping profiling.
[reid@muikyl profiling]$ opreport ./matrix_multiply
Overflow stats not available
CPU: Intel Core/i7, speed 1596 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a
unit mask of 0x00 (No unit mask) count 1000000
Counted INST_RETIRED events (number of instructions retired) with a
unit mask of 0x01 (any_p instructions retired) count 1000000
CPU_CLK_UNHALT...|INST_RETIRED:1...|
samples| %| samples| %|
------------------------------------
22925 100.000 9056 100.000 matrix_multiply
[reid@muikyl profiling]$ sudo opcontrol --reset && sudo opcontrol
--start -e L1D:400000 -e MEM_INST_RETIRED:400000 && ./matrix_multiply
&& sudo opcontrol --stop
Signalling daemon... done
Profiler running.
Setup
Running matrix_multiply_run()...
Elapsed execution time: 11.494934 sec
Stopping profiling.
[reid@muikyl profiling]$ opreport ./matrix_multiplyOverflow stats not available
CPU: Intel Core/i7, speed 1596 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a
unit mask of 0x00 (No unit mask) count 1000000
Counted INST_RETIRED events (number of instructions retired) with a
unit mask of 0x01 (any_p instructions retired) count 1000000
CPU_CLK_UNHALT...|INST_RETIRED:1...|
samples| %| samples| %|
------------------------------------
22919 100.000 9056 100.000 matrix_multiply
opcontrol --status reports that the new counters are being used, even though they didn't show up in the report:
[reid@muikyl profiling]$ sudo opcontrol --status
Daemon running: pid 2341
Event 0: L1D:400000:1:1:1
Event 1: MEM_INST_RETIRED:400000:1:1:1
Separate options: none
vmlinux file: none
Image filter: none
Call-graph depth: 0
Maynard suggested that the solution might be to keep a second cache of the set of performance counters being monitored, but I am not familiar enough to explain more.
I should add that the correct way for the user to get the desired behavior is to use --shutdown instead of --stop.
Reid, I just posted a patch for this problem to the oprofile mailing list, and I asked Will Cohen to review it. Could you review the patch, too, please? I'll attach it to this bug for convenience, but if you have review comments, I'd prefer you make them on the mailing list if possible.
Patch to fix this bug
The patch I initially posted on April 20 went through a few rounds of review. The final version (4th) was posted, ack'ed, and committed on May 25.
Marking this bug as "Fixed".