Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2472438rdb; Wed, 15 Nov 2023 01:29:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDH5SvTPMRsxCbDhMfOACLQWTx+jtms2sfV8yofc7W24WJ91jTmf8yfRUoRyaFud2O+vCa X-Received: by 2002:a17:902:ce8f:b0:1cc:2f90:6291 with SMTP id f15-20020a170902ce8f00b001cc2f906291mr6037016plg.54.1700040560030; Wed, 15 Nov 2023 01:29:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700040560; cv=none; d=google.com; s=arc-20160816; b=H8MhtsMoDOEjouIPRj/YxP2++69VtezJ2Gv3Q3wBrp34MgOMZeaqoyiizPQO9sPwPf x79tG/zkaL0I3WlXbPZ9dER7bMKATOBSfOdYF/VutRtaSnwnk0xMkG/ctRn6XxNc8Pcn 0L5K9WY7t8tNMrLamaJWQZZsFstMgW9uTaWAsWvGyxLENlNruovcWxwrkHRqznFs3cx5 UVl3FjEvCFy1pEy9y8EfitPZGgqRFiQ484Xz5uP1V5oGVyqh3+lQVdCooQZIxR/KxV7+ ZfmT/85FK9UotU8Kr98tcy+2e8ZaUwUiV04C+XxQGFclw7FcGJZIIKvZ4vhIpYmejHo8 OW0A== 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id e14-20020a17090301ce00b001c9fe071f2bsi10331180plh.8.2023.11.15.01.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 01:29:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 517538030E7F; Wed, 15 Nov 2023 01:29:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234771AbjKOJ3F (ORCPT + 99 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 15 Nov 2023 01:29:17 -0800 (PST) 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;