All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vasant Hegde" <vasant.hegde@amd.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] x86/events/amd/iommu: Fix cpumask of IOMMU events
Date: Sun, 17 May 2026 12:12:47 +0000	[thread overview]
Message-ID: <20260517121248.0E501C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260517114026.6817-1-vasant.hegde@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] PMU initialization fails for IOMMUs located on NUMA nodes without online CPUs.
--

commit ef1363d0a37870d7cf1f1095cd3ebf42cc5a8bdc
Author: Vasant Hegde <vasant.hegde@amd.com>

x86/events/amd/iommu: Fix cpumask of IOMMU events

This commit changes the IOMMU PMU cpumask from a single global mask to a
per-IOMMU mask based on the NUMA node of the IOMMU, allowing per-socket
performance counter collection.

> diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c
> --- a/arch/x86/events/amd/iommu.c
> +++ b/arch/x86/events/amd/iommu.c
[ ... ]
> @@ -440,6 +445,20 @@ static __init int init_one_iommu(unsigned int idx)
>  		return -EINVAL;
>  	}
>  
> +	dev = amd_iommu_idx_to_dev(idx);
> +	node = dev ? dev_to_node(dev) : NUMA_NO_NODE;
> +	if (node != NUMA_NO_NODE)
> +		cpu = cpumask_any_and(cpumask_of_node(node), cpu_online_mask);

If the IOMMU resides on a CPU-less NUMA node (like a PCIe expansion switch
or a memory-only CXL node), or if all CPUs on that node are currently
offline, will cpumask_any_and() return a value greater than or equal to
nr_cpu_ids?

> +	else
> +		cpu = cpumask_any(cpu_online_mask);
> +
> +	if (cpu >= nr_cpu_ids) {
> +		pr_warn("Failed to find online CPU for IOMMU %d.\n", idx);
> +		kfree(perf_iommu);
> +		return -ENODEV;
> +	}

Could this cause PMU initialization to fail for IOMMUs on CPU-less nodes?

Since AMD IOMMU performance counters are accessed via MMIO space, they can
be driven by any CPU in the system. Would it be better to fall back to
cpumask_any(cpu_online_mask) instead of returning -ENODEV when a local CPU
is not available?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260517114026.6817-1-vasant.hegde@amd.com?part=1

  reply	other threads:[~2026-05-17 12:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-17 11:40 [PATCH] x86/events/amd/iommu: Fix cpumask of IOMMU events Vasant Hegde
2026-05-17 12:12 ` sashiko-bot [this message]
2026-05-18 17:58   ` Chun-Tse Shao
2026-05-19  8:00   ` Vasant Hegde
2026-05-28  7:28 ` Jörg Rödel
2026-05-29  6:58 ` Sandipan Das

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=20260517121248.0E501C2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vasant.hegde@amd.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.