Skip to content

Commit 1e0c8d6

Browse files
lrq-maxjoergroedel
authored andcommitted
iommu/amd: Add NUMA node affinity for IOMMU log buffers
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> Reviewed-by: Ankit Soni <Ankit.Soni@amd.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent f338e77 commit 1e0c8d6

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

drivers/iommu/amd/init.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,10 +848,11 @@ static void __init free_command_buffer(struct amd_iommu *iommu)
848848
void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp,
849849
size_t size)
850850
{
851+
int nid = iommu->dev ? dev_to_node(&iommu->dev->dev) : NUMA_NO_NODE;
851852
void *buf;
852853

853854
size = PAGE_ALIGN(size);
854-
buf = iommu_alloc_pages_sz(gfp, size);
855+
buf = iommu_alloc_pages_node_sz(nid, gfp, size);
855856
if (!buf)
856857
return NULL;
857858
if (check_feature(FEATURE_SNP) &&
@@ -954,14 +955,16 @@ static int iommu_ga_log_enable(struct amd_iommu *iommu)
954955

955956
static int iommu_init_ga_log(struct amd_iommu *iommu)
956957
{
958+
int nid = iommu->dev ? dev_to_node(&iommu->dev->dev) : NUMA_NO_NODE;
959+
957960
if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))
958961
return 0;
959962

960-
iommu->ga_log = iommu_alloc_pages_sz(GFP_KERNEL, GA_LOG_SIZE);
963+
iommu->ga_log = iommu_alloc_pages_node_sz(nid, GFP_KERNEL, GA_LOG_SIZE);
961964
if (!iommu->ga_log)
962965
goto err_out;
963966

964-
iommu->ga_log_tail = iommu_alloc_pages_sz(GFP_KERNEL, 8);
967+
iommu->ga_log_tail = iommu_alloc_pages_node_sz(nid, GFP_KERNEL, 8);
965968
if (!iommu->ga_log_tail)
966969
goto err_out;
967970

0 commit comments

Comments
 (0)