Commit 037a3c4
perf/core: Detach event groups during remove_on_exec
perf_event_remove_on_exec() removes events by calling
perf_event_exit_event(). For top-level events, this removes the event from
the context with DETACH_EXIT only.
This can leave inconsistent group state when a removed event is a group
leader and the group contains siblings without remove_on_exec. If the group
was active, the surviving siblings can remain active and attached to the
removed leader's sibling list, but are no longer represented by a valid
group leader on the PMU context active lists.
A later close of the removed leader uses DETACH_GROUP and can promote the
still-active siblings from this stale group state. The next schedule-in can
then add an already-linked active_list entry again, corrupting the PMU
context active list.
With DEBUG_LIST enabled, this is caught as a list_add double-add in
merge_sched_in().
Fix this by detaching group relationships when remove_on_exec removes an
event. This preserves the existing task-exit and revoke behavior, while
ensuring surviving siblings are ungrouped before the removed event leaves
the context.
Fixes: 2e498d0 ("perf: Add support for event removal on exec")
Signed-off-by: Taeyang Lee <0wn@theori.io>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/ai65GgZcC0LAlWLG@Taeyangs-MacBook-Pro.local1 parent dc59e4f commit 037a3c4
1 file changed
Lines changed: 9 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4729 | 4729 | | |
4730 | 4730 | | |
4731 | 4731 | | |
4732 | | - | |
| 4732 | + | |
4733 | 4733 | | |
4734 | 4734 | | |
4735 | 4735 | | |
| |||
4756 | 4756 | | |
4757 | 4757 | | |
4758 | 4758 | | |
4759 | | - | |
| 4759 | + | |
4760 | 4760 | | |
4761 | 4761 | | |
4762 | 4762 | | |
| |||
12937 | 12937 | | |
12938 | 12938 | | |
12939 | 12939 | | |
12940 | | - | |
| 12940 | + | |
12941 | 12941 | | |
12942 | 12942 | | |
12943 | 12943 | | |
| |||
14525 | 14525 | | |
14526 | 14526 | | |
14527 | 14527 | | |
14528 | | - | |
| 14528 | + | |
14529 | 14529 | | |
14530 | 14530 | | |
14531 | | - | |
14532 | 14531 | | |
14533 | 14532 | | |
| 14533 | + | |
| 14534 | + | |
14534 | 14535 | | |
14535 | 14536 | | |
14536 | 14537 | | |
| |||
14553 | 14554 | | |
14554 | 14555 | | |
14555 | 14556 | | |
14556 | | - | |
14557 | | - | |
| 14557 | + | |
| 14558 | + | |
14558 | 14559 | | |
14559 | 14560 | | |
14560 | 14561 | | |
| |||
14642 | 14643 | | |
14643 | 14644 | | |
14644 | 14645 | | |
14645 | | - | |
| 14646 | + | |
14646 | 14647 | | |
14647 | 14648 | | |
14648 | 14649 | | |
| |||
0 commit comments