[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fXwprvLc3ubPmAuyUaTL2aD1frqL+RHJzkp8oe5z85oRw@mail.gmail.com>
Date: Mon, 3 Feb 2025 11:44:13 -0800
From: Ian Rogers <irogers@...gle.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>, "Liang, Kan" <kan.liang@...ux.intel.com>
Subject: Re: [PATCH] perf/core: move all of the pmu devices into their own location
On Mon, Feb 3, 2025 at 11:25 AM Greg Kroah-Hartman
<gregkh@...uxfoundation.org> wrote:
>
> In sysfs, for some reason, all pmu devices seem to show up in the "root"
> of /sys/devices/ making for a confusing mess as these devices are not
> really at the root of the system at all.
>
> Create a fake root devices, "pmu_bus" and place them all under there if
> they do not already have a parent device set, cleaning up sysfs to look
> more sane.
>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Cc: Ingo Molnar <mingo@...hat.com>
> Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
> Cc: Namhyung Kim <namhyung@...nel.org>
> Cc: Mark Rutland <mark.rutland@....com>
> Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
> Cc: Jiri Olsa <jolsa@...nel.org>
> Cc: Ian Rogers <irogers@...gle.com>
> Cc: Adrian Hunter <adrian.hunter@...el.com>
> Cc: "Liang, Kan" <kan.liang@...ux.intel.com>
> Cc: linux-perf-users@...r.kernel.org
> Cc: linux-kernel@...r.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> ---
>
> Note, if you all don't like "pmu_bus" for the name, that's fine, please
> let me know and I can rename it to something else, but it should be
> something to get these objects out of the root sysfs directory.
Excuse my ignorance, does the event_source bus already provide a
similar solution?
```
$ ls /sys/bus/event_source/devices
breakpoint i915 msr uncore_arb uncore_cbox_3
uncore_cbox_7 uprobe
cpu intel_bts power uncore_cbox_0 uncore_cbox_4 uncore_clock
cstate_core intel_pt software uncore_cbox_1 uncore_cbox_5
uncore_imc_free_running_0
cstate_pkg kprobe tracepoint uncore_cbox_2 uncore_cbox_6
uncore_imc_free_running_1
$ ls /sys/devices
breakpoint intel_pt platform uncore_arb uncore_cbox_5
uprobe
cpu isa pnp0 uncore_cbox_0 uncore_cbox_6
virtual
cstate_core kprobe power uncore_cbox_1 uncore_cbox_7
cstate_pkg LNXSYSTM:00 software uncore_cbox_2 uncore_clock
i915 msr system uncore_cbox_3 uncore_imc_free_running_0
intel_bts pci0000:00 tracepoint uncore_cbox_4 uncore_imc_free_running_1
```
Thanks,
Ian
> kernel/events/core.c | 22 +++++++++++++++++++---
> 1 file changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index bcb09e011e9e..786537faed2c 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -11767,6 +11767,11 @@ static const struct attribute_group *pmu_dev_groups[] = {
> };
>
> static int pmu_bus_running;
> +
> +static struct device pmu_bus_root = {
> + .init_name = "pmu_bus",
> +};
> +
> static struct bus_type pmu_bus = {
> .name = "event_source",
> .dev_groups = pmu_dev_groups,
> @@ -11790,7 +11795,10 @@ static int pmu_dev_alloc(struct pmu *pmu)
>
> dev_set_drvdata(pmu->dev, pmu);
> pmu->dev->bus = &pmu_bus;
> - pmu->dev->parent = pmu->parent;
> + if (pmu->parent)
> + pmu->dev->parent = pmu->parent;
> + else
> + pmu->dev->parent = &pmu_bus_root;
> pmu->dev->release = pmu_dev_release;
>
> ret = dev_set_name(pmu->dev, "%s", pmu->name);
> @@ -14232,9 +14240,17 @@ static int __init perf_event_sysfs_init(void)
>
> mutex_lock(&pmus_lock);
>
> - ret = bus_register(&pmu_bus);
> - if (ret)
> + ret = device_register(&pmu_bus_root);
> + if (ret) {
> + put_device(&pmu_bus_root);
> goto unlock;
> + }
> +
> + ret = bus_register(&pmu_bus);
> + if (ret) {
> + device_unregister(&pmu_bus_root);
> + goto unlock;
> + }
>
> list_for_each_entry(pmu, &pmus, entry) {
> if (pmu->dev)
> --
> 2.48.1
>
Powered by blists - more mailing lists