Skip to content

Commit fcf9ccf

Browse files
namhyunggregkh
authored andcommitted
perf/core: Inherit event_caps
commit e3265a4 upstream. It was reported that some perf event setup can make fork failed on ARM64. It was the case of a group of mixed hw and sw events and it failed in perf_event_init_task() due to armpmu_event_init(). The ARM PMU code checks if all the events in a group belong to the same PMU except for software events. But it didn't set the event_caps of inherited events and no longer identify them as software events. Therefore the test failed in a child process. A simple reproducer is: $ perf stat -e '{cycles,cs,instructions}' perf bench sched messaging # Running 'sched/messaging' benchmark: perf: fork(): Invalid argument The perf stat was fine but the perf bench failed in fork(). Let's inherit the event caps from the parent. Signed-off-by: Namhyung Kim <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0309f05 commit fcf9ccf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/events/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11596,6 +11596,9 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
1159611596

1159711597
event->state = PERF_EVENT_STATE_INACTIVE;
1159811598

11599+
if (parent_event)
11600+
event->event_caps = parent_event->event_caps;
11601+
1159911602
if (event->attr.sigtrap)
1160011603
atomic_set(&event->event_limit, 1);
1160111604

0 commit comments

Comments
 (0)