Re: Problem with perf hardware counters grouping

From: Mike Hommey
Date: Thu Sep 01 2011 - 07:59:44 EST


On Thu, Sep 01, 2011 at 01:53:32PM +0200, Peter Zijlstra wrote:
> 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+.

Core2Duo

> 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.

Indeed, that shows up.

> 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.

That makes sense. But how exactly is not using groups different, then?
perf, for instance doesn't use groups, and can get all the hardware
counters.

Mike
--
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/