perf: Tighten (and fix) the grouping condition
authorPeter Zijlstra <peterz@infradead.org>
Fri, 23 Jan 2015 10:19:48 +0000 (11:19 +0100)
committerManish Tuteja <mtuteja@nvidia.com>
Tue, 18 Apr 2017 21:25:20 +0000 (14:25 -0700)
commit3363bc34d21e31994ba91187afd9d4a550f71c76
treed5e700615d16502ddc7a1e48528ecb7fa283834c
parent31181e12cc26953993314db7e493c1d545ef176e
perf: Tighten (and fix) the grouping condition

The fix from 9fc81d87420d ("perf: Fix events installation during
moving group") was incomplete in that it failed to recognise that
creating a group with events for different CPUs is semantically
broken -- they cannot be co-scheduled.

Furthermore, it leads to real breakage where, when we create an event
for CPU Y and then migrate it to form a group on CPU X, the code gets
confused where the counter is programmed -- triggered in practice
as well by me via the perf fuzzer.

Fix this by tightening the rules for creating groups. Only allow
grouping of counters that can be co-scheduled in the same context.
This means for the same task and/or the same cpu.

Bug 1899974

Change-Id: Ie4752ec048cd813b2587ce459aea8ccc6f1b5189
Fixes: 9fc81d87420d ("perf: Fix events installation during moving group")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20150123125834.090683288@infradead.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Gagan Grover <ggrover@nvidia.com>
Reviewed-on: http://git-master/r/1463511
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
include/linux/perf_event.h
kernel/events/core.c