* [PATCH] iommu/amd: Add NUMA node affinity for IOMMU log buffers
@ 2026-02-11 3:58 lirongqing
2026-02-16 4:19 ` Ankit Soni
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: lirongqing @ 2026-02-11 3:58 UTC (permalink / raw)
To: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy,
iommu, linux-kernel
Cc: Li RongQing
From: Li RongQing <lirongqing@baidu.com>
Currently, PPR Log and GA logs for AMD IOMMU are allocated using
iommu_alloc_pages_sz(), which does not account for NUMA affinity. This can
lead to remote memory access latencies if the memory is allocated on a
different node than the IOMMU hardware.
Switch to iommu_alloc_pages_node_sz() to ensure that these data structures
are allocated on the same NUMA node as the IOMMU device. If the node
information is unavailable, it defaults to NUMA_NO_NODE.
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
drivers/iommu/amd/init.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index 384c90b..721d9d0 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -851,10 +851,11 @@ static void __init free_command_buffer(struct amd_iommu *iommu)
void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp,
size_t size)
{
+ int nid = iommu->dev ? dev_to_node(&iommu->dev->dev) : NUMA_NO_NODE;
void *buf;
size = PAGE_ALIGN(size);
- buf = iommu_alloc_pages_sz(gfp, size);
+ buf = iommu_alloc_pages_node_sz(nid, gfp, size);
if (!buf)
return NULL;
if (check_feature(FEATURE_SNP) &&
@@ -957,14 +958,16 @@ static int iommu_ga_log_enable(struct amd_iommu *iommu)
static int iommu_init_ga_log(struct amd_iommu *iommu)
{
+ int nid = iommu->dev ? dev_to_node(&iommu->dev->dev) : NUMA_NO_NODE;
+
if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))
return 0;
- iommu->ga_log = iommu_alloc_pages_sz(GFP_KERNEL, GA_LOG_SIZE);
+ iommu->ga_log = iommu_alloc_pages_node_sz(nid, GFP_KERNEL, GA_LOG_SIZE);
if (!iommu->ga_log)
goto err_out;
- iommu->ga_log_tail = iommu_alloc_pages_sz(GFP_KERNEL, 8);
+ iommu->ga_log_tail = iommu_alloc_pages_node_sz(nid, GFP_KERNEL, 8);
if (!iommu->ga_log_tail)
goto err_out;
--
2.9.4
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] iommu/amd: Add NUMA node affinity for IOMMU log buffers
2026-02-11 3:58 [PATCH] iommu/amd: Add NUMA node affinity for IOMMU log buffers lirongqing
@ 2026-02-16 4:19 ` Ankit Soni
2026-02-23 6:19 ` Vasant Hegde
2026-03-17 12:26 ` Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Ankit Soni @ 2026-02-16 4:19 UTC (permalink / raw)
To: lirongqing
Cc: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy,
iommu, linux-kernel
On Tue, Feb 10, 2026 at 10:58:39PM -0500, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> Currently, PPR Log and GA logs for AMD IOMMU are allocated using
> iommu_alloc_pages_sz(), which does not account for NUMA affinity. This can
> lead to remote memory access latencies if the memory is allocated on a
> different node than the IOMMU hardware.
>
> Switch to iommu_alloc_pages_node_sz() to ensure that these data structures
> are allocated on the same NUMA node as the IOMMU device. If the node
> information is unavailable, it defaults to NUMA_NO_NODE.
>
Reviewed-by: Ankit Soni <Ankit.Soni@amd.com>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
> drivers/iommu/amd/init.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index 384c90b..721d9d0 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
> @@ -851,10 +851,11 @@ static void __init free_command_buffer(struct amd_iommu *iommu)
> void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp,
> size_t size)
> {
> + int nid = iommu->dev ? dev_to_node(&iommu->dev->dev) : NUMA_NO_NODE;
> void *buf;
>
> size = PAGE_ALIGN(size);
> - buf = iommu_alloc_pages_sz(gfp, size);
> + buf = iommu_alloc_pages_node_sz(nid, gfp, size);
> if (!buf)
> return NULL;
> if (check_feature(FEATURE_SNP) &&
> @@ -957,14 +958,16 @@ static int iommu_ga_log_enable(struct amd_iommu *iommu)
>
> static int iommu_init_ga_log(struct amd_iommu *iommu)
> {
> + int nid = iommu->dev ? dev_to_node(&iommu->dev->dev) : NUMA_NO_NODE;
> +
> if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))
> return 0;
>
> - iommu->ga_log = iommu_alloc_pages_sz(GFP_KERNEL, GA_LOG_SIZE);
> + iommu->ga_log = iommu_alloc_pages_node_sz(nid, GFP_KERNEL, GA_LOG_SIZE);
> if (!iommu->ga_log)
> goto err_out;
>
> - iommu->ga_log_tail = iommu_alloc_pages_sz(GFP_KERNEL, 8);
> + iommu->ga_log_tail = iommu_alloc_pages_node_sz(nid, GFP_KERNEL, 8);
> if (!iommu->ga_log_tail)
> goto err_out;
>
> --
> 2.9.4
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] iommu/amd: Add NUMA node affinity for IOMMU log buffers
2026-02-11 3:58 [PATCH] iommu/amd: Add NUMA node affinity for IOMMU log buffers lirongqing
2026-02-16 4:19 ` Ankit Soni
@ 2026-02-23 6:19 ` Vasant Hegde
2026-03-17 12:26 ` Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Vasant Hegde @ 2026-02-23 6:19 UTC (permalink / raw)
To: lirongqing, Joerg Roedel, Suravee Suthikulpanit, Will Deacon,
Robin Murphy, iommu, linux-kernel
On 2/11/2026 9:28 AM, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> Currently, PPR Log and GA logs for AMD IOMMU are allocated using
> iommu_alloc_pages_sz(), which does not account for NUMA affinity. This can
> lead to remote memory access latencies if the memory is allocated on a
> different node than the IOMMU hardware.
>
> Switch to iommu_alloc_pages_node_sz() to ensure that these data structures
> are allocated on the same NUMA node as the IOMMU device. If the node
> information is unavailable, it defaults to NUMA_NO_NODE.
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
-Vasant
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu/amd: Add NUMA node affinity for IOMMU log buffers
2026-02-11 3:58 [PATCH] iommu/amd: Add NUMA node affinity for IOMMU log buffers lirongqing
2026-02-16 4:19 ` Ankit Soni
2026-02-23 6:19 ` Vasant Hegde
@ 2026-03-17 12:26 ` Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2026-03-17 12:26 UTC (permalink / raw)
To: lirongqing
Cc: Suravee Suthikulpanit, Will Deacon, Robin Murphy, iommu, linux-kernel
On Tue, Feb 10, 2026 at 10:58:39PM -0500, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> Currently, PPR Log and GA logs for AMD IOMMU are allocated using
> iommu_alloc_pages_sz(), which does not account for NUMA affinity. This can
> lead to remote memory access latencies if the memory is allocated on a
> different node than the IOMMU hardware.
>
> Switch to iommu_alloc_pages_node_sz() to ensure that these data structures
> are allocated on the same NUMA node as the IOMMU device. If the node
> information is unavailable, it defaults to NUMA_NO_NODE.
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
> drivers/iommu/amd/init.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-17 12:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-11 3:58 [PATCH] iommu/amd: Add NUMA node affinity for IOMMU log buffers lirongqing
2026-02-16 4:19 ` Ankit Soni
2026-02-23 6:19 ` Vasant Hegde
2026-03-17 12:26 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®