Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp40111pxb; Tue, 12 Apr 2022 16:11:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysQ584H3iKQQ4L6kSmloOy6Kh8pIf8VlArMs55mFmzVl8JJDFTNNvqic7SleVVHMFBLppf X-Received: by 2002:a05:6a00:cc4:b0:505:6998:69b8 with SMTP id b4-20020a056a000cc400b00505699869b8mr6900703pfv.19.1649805097924; Tue, 12 Apr 2022 16:11:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649805097; cv=none; d=google.com; s=arc-20160816; b=bjgm9SWrwt3tFlNHYMXWzjzr1n1tIO1cHaSXLDqd2F5bmAMSGhH/25REecy6rlNG14 /oVquYdTAYvefiGhDDdFP/CeaA8g7nFnP6Uoyhsi+bgLE36aAvKwlM4w4qYj44enRNth mBOe9RBuSSsnLtYY6a3LjcXtZ903UXbw8ldO8FEaXC7arvhGAsw/JemwLMCORHr0OguI IwPdqyigwXJWlu9m6CIE6kwk1z0BRcfRpVJcSomznm2MwfTvbZrzYjyuF1Ne4oXj+B20 EelFIz0wQewnQRDoQcFw6zJDV2bk3glcH3q1MyX7cFpcaSfs084QWaxyMHbpQnjJpNwo x/7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=76Xxe+YW4pTwGyKStb+Duk8UuRsTaFXgiNWxM4+ge28=; b=1B8qrNQDShRsiIfoyvXea1/JREER4/dW4SWlwtYT4QJGM8o4CSGsh90oGbaJXwy10B GV394V94zbVnhgsue2+k/qNmladghg0+DuHm00btKZQao1E6ROVLGouO5dzuEbzYUVuw 39L5nqGUfLndGKB1pz7IPRtGJEA9j313z0k3T5CQ3oloK8HH4UZ1YfbF0VOYYq/IMBLb SkOOH5ldeK2vfIqXFsJtghLW5GXEDJuChl38kJ7XcCWbvkgoHEYqteEgDsy34LgvGm24 DkMYtTCqJfDDAHSsG5BCJX2UCL947U+Ol8fw9GG65nTd0EwS2fWbWgu90tu3C4WWS1JY m9bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Fkm23S0T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 15-20020a630b0f000000b003816043ef25si3786352pgl.282.2022.04.12.16.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 16:11:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Fkm23S0T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3F07913EFA0; Tue, 12 Apr 2022 14:54:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355203AbiDLH1P (ORCPT + 99 others); Tue, 12 Apr 2022 03:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351696AbiDLHMv (ORCPT ); Tue, 12 Apr 2022 03:12:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52DAC15A30; Mon, 11 Apr 2022 23:51:47 -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 dfw.source.kernel.org (Postfix) with ESMTPS id E1EC56146F; Tue, 12 Apr 2022 06:51:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0303C385A1; Tue, 12 Apr 2022 06:51:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649746306; bh=TtMFs0H5NU5r4p+2u4nzwSmLe/Zr4CUSnystOjjsI00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fkm23S0TsXgpmCsaJHJNMsISfj8s5TcySbXcCKQ8l9uw+YVHJf2mxzYmqTil42KW5 QaZmDPpwH7knTvtLyaZeZ3n8T1cOhNGGtjd8zwJqL8v6J3fP+/9QWzcINP1L92Cg5R alOgflK1iHJGnlXb3Ep2t1O/IXxaB7YOyaudsTLA= 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.15 236/277] perf/core: Inherit event_caps Date: Tue, 12 Apr 2022 08:30:39 +0200 Message-Id: <20220412062948.874087725@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062942.022903016@linuxfoundation.org> References: <20220412062942.022903016@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 @@ -11596,6 +11596,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);