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. 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. Cc: Will Deacon <will@xxxxxxxxxx> Cc: Mark Rutland <mark.rutland@xxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx> --- kernel/events/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index fc18664f49b0..e28f63ae625b 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11560,6 +11560,9 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu, event->state = PERF_EVENT_STATE_INACTIVE; + if (parent_event) + event->event_caps = parent_event->event_caps; + if (event->attr.sigtrap) atomic_set(&event->event_limit, 1); -- 2.35.1.265.g69c8d7142f-goog