Re: Problem with perf hardware counters grouping

From: Peter Zijlstra
Date: Thu Sep 01 2011 - 07:53:41 EST


On Wed, 2011-08-31 at 10:57 +0200, Mike Hommey wrote:
> I'm having two different problems with perf hardware counters with a
> group leader:
> - perf_event_open()ing more than 3 makes all of them always return a
> value of 0;
> - perf_event_open()ing more than 4 fails with ENOSPC.


I'm guessing you're running on something x86, either AMD-Fam10-12 or
Intel-NHM+.

Both those have 4 generic hardware counters, but x86 defaults to
enabling the NMI watchdog which takes one, leaving you with 3 (try: echo
0 > /proc/sys/kernel/nmi_watchdog). If you had looked at your dmesg
output you'd have found lines like:

NMI watchdog enabled, takes one hw-pmu counter.

The code can only check if the group as a whole could possibly fit on a
PMU, which is where your failure on >4 comes from.

What happens with your >3 case is that while the group is valid and
could fit on the PMU, it won't fit at runtime because the NMI watchdog
is taking one and won't budge (cpu-pinned counter have precedence over
any other kind), effectively starving your group of pmu runtime.

Also, we should fix that return to say -EINVAL or so.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/