Hi,

I've noticed that the task example does not work as expected when I tried to mix PERF_COUN_SW_* with raw hardware counters.
If the group leader is a software counter, and the other software counters within the group have enable_on_exec set to 0, no other
software counter will be started. If the first counter is a predefined hardware or raw counter all other counters within the group
will be started, even if enable_on_exec is set to 0. This only happen when you mix software and hardware counters. If there
are only software counters in the group they all get enabled. Is this behavior really intended by the kernel developers?

This command line gives wrong/broken output:

task -e PERF_COUNT_SW_CPU_CLOCK,PERF_COUNT_SW_TASK_CLOCK,INSTRUCTION_RETIRED ls

           1,324,975 PERF_COUNT_SW_CPU_CLOCK (0.00% scaling, ena=1,324,781, run=1,324,781)
                   0 PERF_COUNT_SW_TASK_CLOCK (100.00% scaling, ena=0, run=0)
           2,899,451 INSTRUCTION_RETIRED (0.00% scaling, ena=1,324,781, run=1,324,781)

It work when putting hw counter first.

task -e INSTRUCTION_RETIRED,PERF_COUNT_SW_CPU_CLOCK,PERF_COUNT_SW_TASK_CLOCK ls

           3,030,246 INSTRUCTION_RETIRED (0.00% scaling, ena=1,506,606, run=1,506,606)
           1,520,635 PERF_COUNT_SW_CPU_CLOCK (0.00% scaling, ena=1,506,606, run=1,506,606)
           1,506,606 PERF_COUNT_SW_TASK_CLOCK (0.00% scaling, ena=1,506,606, run=1,506,606)

The problem can be fixed by setting enable_on_exec for all (software) counters.


Another annoying experience: Putting a raw or hardware counter in between software counters doesn't work.

task -e PERF_COUNT_SW_CPU_CLOCK,INSTRUCTION_RETIRED,PERF_COUNT_SW_TASK_CLOCK ls
task: cannot attach event2 PERF_COUNT_SW_TASK_CLOCK: Invalid argument

Best regards,
Andreas Hollmann