On Wed, Jul 31, 2019 at 05:30:36PM +0300, Alexander Shishkin wrote: > diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c > index cfe256ca76df..6cf2a7ba822a 100644 > --- a/arch/x86/events/core.c > +++ b/arch/x86/events/core.c > @@ -1006,6 +1006,28 @@ static int collect_events(struct cpu_hw_events *cpuc, > struct perf_event *leader, > /* current number of events already accepted */ > n = cpuc->n_events; > > + if (!cpuc->is_fake && leader->attr.precise_ip) { > + if (!n) > + cpuc->pebs_output = 0;
I think this can go wobbly if we add a !pebs event first. That is, in that case '!n && !precise_ip' and we'll not reset the output state. > + > + /* > + * For PEBS->PT, if !aux_event, the group leader (PT) went > + * away, the group was broken down and this singleton event > + * can't schedule any more. > + */ > + if (WARN_ON_ONCE(is_pebs_pt(leader) && !leader->aux_event)) > + return -EINVAL; > + > + /* > + * pebs_output: 0: no PEBS so far, 1: PT, 2: DS > + */ > + if (cpuc->pebs_output && > + cpuc->pebs_output != is_pebs_pt(leader) + 1) > + return -EINVAL; > + > + cpuc->pebs_output = is_pebs_pt(leader) + 1; > + } > + > if (is_x86_event(leader)) { > if (n >= max_count) > return -EINVAL;