Re: [PATCH] perf/core: fix group {cpu,task} validation

From: Peter Zijlstra
Date: Mon Aug 21 2017 - 12:09:11 EST


On Mon, Aug 21, 2017 at 05:01:38PM +0100, Mark Rutland wrote:
> On Mon, Aug 21, 2017 at 05:53:26PM +0200, Peter Zijlstra wrote:
> > On Thu, Jun 22, 2017 at 03:41:38PM +0100, Mark Rutland wrote:
> > > Regardless of which events form a group, it does not make sense for the
> > > events to target different tasks and/or CPUs, as this leaves the group
> > > inconsistent and impossible to schedule. The core perf code assumes that
> > > these are consistent across (successfully intialised) groups.
> > >
> > > Core perf code only verifies this when moving SW events into a HW
> > > context. Thus, we can violate this requirement for pure SW groups and
> > > pure HW groups, unless the relevant PMU driver happens to perform this
> > > verification itself. These mismatched groups subsequently wreak havoc
> > > elsewhere.
> > >
> > > For example, we handle watchpoints as SW events, and reserve watchpoint
> > > HW on a per-cpu basis at pmu::event_init() time to ensure that any event
> > > that is initialised is guaranteed to have a slot at pmu::add() time.
> > > However, the core code only checks the group leader's cpu filter (via
> > > event_filter_match()), and can thus install follower events onto CPUs
> > > violating thier (mismatched) CPU filters, potentially installing them
> > > into a CPU without sufficient reserved slots.
> >
> > > Fix this by validating this requirement regardless of whether we're
> > > moving events.
> >
> > Yes, and this also appears to cure your other problem:
> >
> > https://lkml.kernel.org/r/20170810173551.GD12812@leverpostej
>
> Ah; sorry for the duplicate report! I should have realised.
>
> I guess this will get queued soon?

Done :-) I'll try and hand to Ingo before end of week.