Re: [LKP] Re: [perf vendor events] 3f5f0df7bf: perf-sanity-tests.perf_all_metrics_test.fail

From: Liang, Kan
Date: Wed Apr 13 2022 - 12:37:34 EST




On 4/13/2022 12:03 PM, Ian Rogers wrote:
3) Weak group doesn't fall back to no group:

That's because the group validation code doesn't take pinned events, such as the NMI watchdog, into account.

I proposed a kernel patch to fix it, but it's rejected. It should be hard to find a generic way to fix it from the kernel side.
https://lore.kernel.org/lkml/1565977750-76693-1-git-send-email-kan.liang@xxxxxxxxxxxxxxx/

Maybe we can workaround it from the perf tool side?
For example, for each weak group with cycles event and NMI watchdog is enabled, add an extra cycles event when opening the group. If the open fails with the extra cycles event, fall back to no group. After the extra cycles event check, remove the extra cycles.

What do you think?

Thanks,
Kan
$ perf stat -e '{BR_INST_RETIRED.NEAR_CALL,BR_INST_RETIRED.NEAR_TAKEN,BR_INST_RETIRED.NOT_TAKEN,BR_INST_RETIRED.CONDITIONAL,CPU_CLK_UNHALTED.THREAD}:W'
-a sleep 1

Performance counter stats for 'system wide':

<not counted> BR_INST_RETIRED.NEAR_CALL
(0.00%)
<not counted> BR_INST_RETIRED.NEAR_TAKEN
(0.00%)
<not counted> BR_INST_RETIRED.NOT_TAKEN
(0.00%)
<not counted> BR_INST_RETIRED.CONDITIONAL
(0.00%)
<not counted> CPU_CLK_UNHALTED.THREAD
(0.00%)

1.001690318 seconds time elapsed

Some events weren't counted. Try disabling the NMI watchdog:
echo 0 > /proc/sys/kernel/nmi_watchdog
perf stat ...
echo 1 > /proc/sys/kernel/nmi_watchdog