[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <170004053915.391.15537018323305525367.tip-bot2@tip-bot2>
Date: Wed, 15 Nov 2023 09:28:59 -0000
From: "tip-bot2 for Greg KH" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: "Greg Kroah-Hartman" <gregkh@...uxfoundation.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: perf/core] perf/core: Fix narrow startup race when creating the
perf nr_addr_filters sysfs file
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 <gregkh@...uxfoundation.org>
AuthorDate: Mon, 12 Jun 2023 15:09:09 +02:00
Committer: Peter Zijlstra <peterz@...radead.org>
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 <gregkh@...uxfoundation.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
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;
Powered by blists - more mailing lists