Skip to content

Commit 3bda69c

Browse files
virtuosoIngo Molnar
authored andcommitted
perf/core: Fix scheduling regression of pinned groups
Vince Weaver reported: > I was tracking down some regressions in my perf_event_test testsuite. > Some of the tests broke in the 4.11-rc1 timeframe. > > I've bisected one of them, this report is about > tests/overflow/simul_oneshot_group_overflow > This test creates an event group containing two sampling events, set > to overflow to a signal handler (which disables and then refreshes the > event). > > On a good kernel you get the following: > Event perf::instructions with period 1000000 > Event perf::instructions with period 2000000 > fd 3 overflows: 946 (perf::instructions/1000000) > fd 4 overflows: 473 (perf::instructions/2000000) > Ending counts: > Count 0: 946379875 > Count 1: 946365218 > > With the broken kernels you get: > Event perf::instructions with period 1000000 > Event perf::instructions with period 2000000 > fd 3 overflows: 938 (perf::instructions/1000000) > fd 4 overflows: 318 (perf::instructions/2000000) > Ending counts: > Count 0: 946373080 > Count 1: 653373058 The root cause of the bug is that the following commit: 487f05e ("perf/core: Optimize event rescheduling on active contexts") erronously assumed that event's 'pinned' setting determines whether the event belongs to a pinned group or not, but in fact, it's the group leader's pinned state that matters. This was discovered by Vince in the test case described above, where two instruction counters are grouped, the group leader is pinned, but the other event is not; in the regressed case the counters were off by 33% (the difference between events' periods), but should be the same within the error margin. Fix the problem by looking at the group leader's pinning. Reported-by: Vince Weaver <[email protected]> Tested-by: Vince Weaver <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Fixes: 487f05e ("perf/core: Optimize event rescheduling on active contexts") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent dc853e2 commit 3bda69c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kernel/events/core.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,13 @@ static enum event_type_t get_event_type(struct perf_event *event)
14521452

14531453
lockdep_assert_held(&ctx->lock);
14541454

1455+
/*
1456+
* It's 'group type', really, because if our group leader is
1457+
* pinned, so are we.
1458+
*/
1459+
if (event->group_leader != event)
1460+
event = event->group_leader;
1461+
14551462
event_type = event->attr.pinned ? EVENT_PINNED : EVENT_FLEXIBLE;
14561463
if (!ctx->task)
14571464
event_type |= EVENT_CPU;

0 commit comments

Comments
 (0)