From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAFABC47082 for ; Tue, 12 Apr 2022 09:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387237AbiDLJGR (ORCPT ); Tue, 12 Apr 2022 05:06:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359250AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ECDA55773; Tue, 12 Apr 2022 00:20:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 43368B81A8F; Tue, 12 Apr 2022 07:20:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A072EC385A5; Tue, 12 Apr 2022 07:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748047; bh=Rar/Pvhk3v1amjKZ3zbecoGXlsJVu+XTVZ7Y/z39xqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tau6P5AdOZWWvEsZ/8WmEeaTUyc/Ys+ndetngZheo+U0D1yf81RzPVsJ+d2fb1aKu /1G6LpVQIQMmxiWB5m2/OhnEdjZXWEbwXdkv2uCinQYpi5pM3Rf7aaIAHXoZK5VJEU c2uD+ChJEro6YM/bievk4nmulkWaRRJ7nIuO2/WI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Namhyung Kim , "Peter Zijlstra (Intel)" Subject: [PATCH 5.17 300/343] perf/core: Inherit event_caps Date: Tue, 12 Apr 2022 08:31:58 +0200 Message-Id: <20220412062959.982680382@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Namhyung Kim commit e3265a4386428d3d157d9565bb520aabff8b4bf0 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 Signed-off-by: Peter Zijlstra (Intel) Cc: Link: https://lkml.kernel.org/r/20220328200112.457740-1-namhyung@kernel.org Signed-off-by: Greg Kroah-Hartman --- kernel/events/core.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11640,6 +11640,9 @@ perf_event_alloc(struct perf_event_attr 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);