From: Robin Murphy <robin.murphy@arm.com>
To: will@kernel.org, mark.rutland@arm.com, catalin.marinas@arm.com
Cc: ilkka@os.amperecomputing.com, bwicaksono@nvidia.com,
linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 2/4] perf/arm_cspmu: Improve APMT-based PMU naming
Date: Thu, 9 Jul 2026 16:42:29 +0100 [thread overview]
Message-ID: <1fa139a6-fa41-4c25-aaf8-b781d695f476@arm.com> (raw)
In-Reply-To: <74b46977582689be3ec7ba456809db89aad92bfe.1783605641.git.robin.murphy@arm.com>
On 09/07/2026 3:39 pm, Robin Murphy wrote:
> On ACPI systems, it has not actually been possible for userspace to
> reliably tell which PMU corresponds to which APMT entry for types
> other than "ACPI device" - the evidence trail only leads from the
> arbitrarily-numbered PMU device to its arbitrarily-numbered parent
> platform device that has no distinguishing features either.
>
> While we've now improved the platform device creation to associate the
> actual APMT unique ID, we may as well also tweak the PMU devices to
> substitute the arbitrary number with a different arbitrary number that
> might be more directly meaningful based on the APMT definitions.
>
> We don't have an equivalent for Devicetree, but in that case the
> platform devices are at least identifiable via their sysfs-visible
> of_node.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
> drivers/perf/arm_cspmu/arm_cspmu.c | 36 +++++++++++++++++-------------
> 1 file changed, 21 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
> index 80fb314d5135..0570be74d11f 100644
> --- a/drivers/perf/arm_cspmu/arm_cspmu.c
> +++ b/drivers/perf/arm_cspmu/arm_cspmu.c
> @@ -250,38 +250,44 @@ static const char *arm_cspmu_get_name(const struct arm_cspmu *cspmu)
> struct device *dev;
> struct acpi_apmt_node *apmt_node;
> u8 pmu_type;
> - char *name;
> char acpi_hid_string[ACPI_ID_LEN] = { 0 };
> - static atomic_t pmu_idx[ACPI_APMT_NODE_TYPE_COUNT] = { 0 };
> + static atomic_t pmu_idx;
> + u32 id;
>
> dev = cspmu->dev;
> apmt_node = arm_cspmu_apmt_node(dev);
> if (!apmt_node)
> return devm_kasprintf(dev, GFP_KERNEL, PMUNAME "_%u",
> - atomic_fetch_inc(&pmu_idx[0]));
> + atomic_fetch_inc(&pmu_idx));
>
> pmu_type = apmt_node->type;
> -
> - if (pmu_type >= ACPI_APMT_NODE_TYPE_COUNT) {
> + switch (pmu_type) {
> + default:
> dev_err(dev, "unsupported PMU type-%u\n", pmu_type);
> return NULL;
> - }
> -
> - if (pmu_type == ACPI_APMT_NODE_TYPE_ACPI) {
> + case ACPI_APMT_NODE_TYPE_ACPI:
> memcpy(acpi_hid_string,
> &apmt_node->inst_primary,
> sizeof(apmt_node->inst_primary));
> - name = devm_kasprintf(dev, GFP_KERNEL, "%s_%s_%s_%u", PMUNAME,
> + return devm_kasprintf(dev, GFP_KERNEL, "%s_%s_%s_%u", PMUNAME,
> arm_cspmu_type_str[pmu_type],
> acpi_hid_string,
> apmt_node->inst_secondary);
> - } else {
> - name = devm_kasprintf(dev, GFP_KERNEL, "%s_%s_%d", PMUNAME,
> - arm_cspmu_type_str[pmu_type],
> - atomic_fetch_inc(&pmu_idx[pmu_type]));
> - }
> + case ACPI_APMT_NODE_TYPE_MC:
> + id = apmt_node->id;
> + break;
> + case ACPI_APMT_NODE_TYPE_SMMU:
> + case ACPI_APMT_NODE_TYPE_PCIE_ROOT:
> + id = apmt_node->inst_primary;
> + break;
> + case ACPI_APMT_NODE_TYPE_CACHE:
> + id = apmt_node->inst_secondary;
> + break;
> + };
>
> - return name;
> + return devm_kasprintf(dev, GFP_KERNEL, "%s_%s_%u", PMUNAME,
> + arm_cspmu_type_str[pmu_type],
> + apmt_node->id);
Seems I did forget this when I realised the instance fields could be
useful and added the local "id" variable. The rest of the Sashiko noise
is mostly nonsense.
Cheers,
Robin.
> }
>
> static ssize_t arm_cspmu_cpumask_show(struct device *dev,
next prev parent reply other threads:[~2026-07-09 15:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 14:39 [PATCH 0/4] perf/arm_cspmu: Miscellaneous improvements Robin Murphy
2026-07-09 14:39 ` [PATCH 1/4] ACPI/APMT: Use stable device ID Robin Murphy
2026-07-09 14:52 ` sashiko-bot
2026-07-09 15:31 ` Robin Murphy
2026-07-09 14:39 ` [PATCH 2/4] perf/arm_cspmu: Improve APMT-based PMU naming Robin Murphy
2026-07-09 14:48 ` sashiko-bot
2026-07-09 15:42 ` Robin Murphy [this message]
2026-07-09 14:39 ` [PATCH 3/4] perf/arm_cspmu: Improve sub-module error reporting Robin Murphy
2026-07-09 14:39 ` [PATCH 4/4] perf/arm_cspmu: Make IRQ more optional Robin Murphy
2026-07-09 14:49 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1fa139a6-fa41-4c25-aaf8-b781d695f476@arm.com \
--to=robin.murphy@arm.com \
--cc=bwicaksono@nvidia.com \
--cc=catalin.marinas@arm.com \
--cc=ilkka@os.amperecomputing.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox