From nobody Thu Apr 2 15:44:04 2026 Received: from outbound.baidu.com (mx22.baidu.com [220.181.50.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17536350287 for ; Wed, 11 Feb 2026 03:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.181.50.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770782380; cv=none; b=nWm7XgoY6vVgLH79BadqnmcRAlTbTqjjcy2ROdJizlAcoEitep2+rX3jbx1+jspLv6qJzI55xfvOJPSfP579CvaExfOengFW7IbQpl4dMrUJ9dWZ9STv76Yopp2pzY1UNkMFeizVeLyZ3UHDHQkGBeL0T5G8m8TkaJBmUbIVcTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770782380; c=relaxed/simple; bh=T3EHwisaN29K6tSBJMpUEWqvevQc4pDn691tjJXoyEU=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=eCznUj/JtzHBF1gUtnAUE30yTtcDOSlbyS+aHBrQph9AhI1v/PIcyapmbW7EQjeZdXXpbMFXN8o7ODOfS1B1ILipD1JGYlxA9ONkz6YxDrsyiImS7rvQtZMDwMVObH0524vZuPWTh9LkCX2ngsxVTJYAoeIG7XyOOow5jeKYDKg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com; spf=pass smtp.mailfrom=baidu.com; arc=none smtp.client-ip=220.181.50.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baidu.com From: lirongqing To: Joerg Roedel , Suravee Suthikulpanit , Will Deacon , Robin Murphy , , CC: Li RongQing Subject: [PATCH] iommu/amd: Add NUMA node affinity for IOMMU log buffers Date: Tue, 10 Feb 2026 22:58:39 -0500 Message-ID: <20260211035839.1970-1-lirongqing@baidu.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: bjhj-exc6.internal.baidu.com (172.31.3.16) To bjkjy-exc3.internal.baidu.com (172.31.50.47) X-FEAS-Client-IP: 172.31.50.47 X-FE-Policy-ID: 52:10:53:SYSTEM Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Li RongQing 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 Reviewed-by: Vasant Hegde --- 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_iom= mu *iommu) void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp, size_t size) { + int nid =3D iommu->dev ? dev_to_node(&iommu->dev->dev) : NUMA_NO_NODE; void *buf; =20 size =3D PAGE_ALIGN(size); - buf =3D iommu_alloc_pages_sz(gfp, size); + buf =3D 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 *iomm= u) =20 static int iommu_init_ga_log(struct amd_iommu *iommu) { + int nid =3D iommu->dev ? dev_to_node(&iommu->dev->dev) : NUMA_NO_NODE; + if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)) return 0; =20 - iommu->ga_log =3D iommu_alloc_pages_sz(GFP_KERNEL, GA_LOG_SIZE); + iommu->ga_log =3D iommu_alloc_pages_node_sz(nid, GFP_KERNEL, GA_LOG_SIZE); if (!iommu->ga_log) goto err_out; =20 - iommu->ga_log_tail =3D iommu_alloc_pages_sz(GFP_KERNEL, 8); + iommu->ga_log_tail =3D iommu_alloc_pages_node_sz(nid, GFP_KERNEL, 8); if (!iommu->ga_log_tail) goto err_out; =20 --=20 2.9.4