From patchwork Wed Nov 15 09:28:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 165225 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2421943vqg; Wed, 15 Nov 2023 01:29:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwe7lqWZCd3M+SCBPkDr1HLtUjDb3mjNX27XCbcTRHIZ7tiwe/QYhjtNwiQM7oph3tfQro X-Received: by 2002:a05:6808:4c4:b0:3ab:83fe:e182 with SMTP id a4-20020a05680804c400b003ab83fee182mr13199604oie.1.1700040556860; Wed, 15 Nov 2023 01:29:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700040556; cv=none; d=google.com; s=arc-20160816; b=TnklOyrgS4BjjpW9CQjjWnN61ggb/3LYVZTA8yzLnBvnpDDPD0c7uE60XbPM7Xs5cx hlNN/m/AMww1gth/eCtrr7ylZq+m5Mjmly1w8q6TR+DG4zuRzeWuVgcX7QvsCbepTxJa jEKDE7nWKKDjVtYiZ7u57b+OAU9JREft2cUMahM3D3xnsZoQgtcFkyrnrMZHGpMO1XWK cEHIBYBs4OfgtUdJRY6qmXlRRGXb2a4Rxl+b64cS2eE6/PI10eNPoqgy9F84bhiHIyt/ 4tS58jPEqxb2X2mvl+5Nuvxaorp7vmQiLJnIFUXTBIdEKWag3Qgfl8ETnQjXENsInom1 BJvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=ccZL0j9gRjBhtc4FakVMy7I3+YuzgGEEyPPs3z/zxSQ=; fh=sbmApCey6s6JCJ/4ir9lOx+f+vBn6hKsZREhBVze/Og=; b=n/liU5OlOZRS86Oynd+A7WK5TsNz214696oxHYRw6i2/x6HqfTFfHVcI0IMthIphzQ 5PGq1GcfJOh8Hb0M/hJKbm5sGLzLboQkxgPxcDwS1l5Q9KK9T4HsBsTxMKpFB6lwFn9c sVCIfCRyq0V+gwjD9bhDljQSTMTD3RCo25DERxPVsQ3RAZo9JAPsQY3LB5uxTAD5ytUx jPbRpGSP5mCC9FjxywqVichgdJoMHUkTRbkHJvqVyI0iotRVip/mjl1M5KAO2uW24gYr 6DbKpwrdtVvEgMJBscL67JELZxxXXiM1kik5CNJZYrIcQS+a5om/4hV7xW30r1KQRJnL 2tVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=SDBJhFyQ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=winUrXOu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id r187-20020a632bc4000000b00565e865d381si9532724pgr.447.2023.11.15.01.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 01:29:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=SDBJhFyQ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=winUrXOu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2F94880BE2D0; Wed, 15 Nov 2023 01:29:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234784AbjKOJ3F (ORCPT + 28 others); Wed, 15 Nov 2023 04:29:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234688AbjKOJ3E (ORCPT ); Wed, 15 Nov 2023 04:29:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5525D9B; Wed, 15 Nov 2023 01:29:01 -0800 (PST) Date: Wed, 15 Nov 2023 09:28:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1700040540; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ccZL0j9gRjBhtc4FakVMy7I3+YuzgGEEyPPs3z/zxSQ=; b=SDBJhFyQm79dD0Szf2J/AGpGnNP80al77IEYdjWAZ3Q1e+CJ0XGSsS9fX9s0DoY7TZJwZq KGqjsKr1Q5NIAnMFdwo4KTkqxZtUPHukoiF65d6AXSUwOgAiKFFrj79BuYAZ7BJmajIk5F ELA0fAJhgUcpgXi8HX6NJXg2AqvWvmQ9FImzN3ZkZpKI0SraZvNTG7G8OUQleg0xXcn6LJ yz/4JBhGA3apRM9V4zoSWnWdrgcOtJaDEwpi157GMPgd8PM+zabKoj8ZouOBIEvspCgbr0 kV99pB8u3zWX2W6sEdXSmYv7DyOPHOrEGGSJNSewKn9Io1yubfPUjmAoSI/HSg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1700040540; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ccZL0j9gRjBhtc4FakVMy7I3+YuzgGEEyPPs3z/zxSQ=; b=winUrXOua56iinRnHDOn7h3Votrwo90OaOoi18mI6Fs0CoeQKxYU2pCSP5q7ivdW7XBWz4 WjHDG/RWHADVAFDw== From: "tip-bot2 for Greg KH" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/core: Fix narrow startup race when creating the perf nr_addr_filters sysfs file Cc: "Greg Kroah-Hartman" , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <2023061204-decal-flyable-6090@gregkh> References: <2023061204-decal-flyable-6090@gregkh> MIME-Version: 1.0 Message-ID: <170004053915.391.15537018323305525367.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 15 Nov 2023 01:29:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782621726887742693 X-GMAIL-MSGID: 1782621726887742693 The following commit has been merged into the perf/core branch of tip: Commit-ID: 652ffc2104ec1f69dd4a46313888c33527145ccf Gitweb: https://git.kernel.org/tip/652ffc2104ec1f69dd4a46313888c33527145ccf Author: Greg KH AuthorDate: Mon, 12 Jun 2023 15:09:09 +02:00 Committer: Peter Zijlstra CommitterDate: Wed, 15 Nov 2023 10:15:50 +01:00 perf/core: Fix narrow startup race when creating the perf nr_addr_filters sysfs file Signed-off-by: Greg Kroah-Hartman Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/2023061204-decal-flyable-6090@gregkh --- kernel/events/core.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 0825098..4f0c45a 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11408,9 +11408,32 @@ static DEVICE_ATTR_RW(perf_event_mux_interval_ms); static struct attribute *pmu_dev_attrs[] = { &dev_attr_type.attr, &dev_attr_perf_event_mux_interval_ms.attr, + &dev_attr_nr_addr_filters.attr, + NULL, +}; + +static umode_t pmu_dev_is_visible(struct kobject *kobj, struct attribute *a, int n) +{ + struct device *dev = kobj_to_dev(kobj); + struct pmu *pmu = dev_get_drvdata(dev); + + if (!pmu->nr_addr_filters) + return 0; + + return a->mode; + + return 0; +} + +static struct attribute_group pmu_dev_attr_group = { + .is_visible = pmu_dev_is_visible, + .attrs = pmu_dev_attrs, +}; + +static const struct attribute_group *pmu_dev_groups[] = { + &pmu_dev_attr_group, NULL, }; -ATTRIBUTE_GROUPS(pmu_dev); static int pmu_bus_running; static struct bus_type pmu_bus = { @@ -11447,18 +11470,11 @@ static int pmu_dev_alloc(struct pmu *pmu) if (ret) goto free_dev; - /* For PMUs with address filters, throw in an extra attribute: */ - if (pmu->nr_addr_filters) - ret = device_create_file(pmu->dev, &dev_attr_nr_addr_filters); - - if (ret) - goto del_dev; - - if (pmu->attr_update) + if (pmu->attr_update) { ret = sysfs_update_groups(&pmu->dev->kobj, pmu->attr_update); - - if (ret) - goto del_dev; + if (ret) + goto del_dev; + } out: return ret;