[RFC PATCH 1/5] iommu: Add reclaim_list xarray to struct iommu_domain

From: Pranjal Shrivastava

Date: Thu Oct 01 2026 - 19:06:54 EST


Introduce struct xarray reclaim_list to struct iommu_domain. This will
serve as the O(1) storage where the fast path stores empty directories by
their associated IOVA. IOVA is required by the shrinker to perform a
top-down tree walk to safely locate and prune the parent pointer. While
xa_store requires a localized spinlock, this path is only triggered when
a directory reaches a completely empty state, keeping the vast majority
of mapping operations lock-free.

Signed-off-by: Pranjal Shrivastava <praan@xxxxxxxxxx>
---
drivers/iommu/iommu.c | 2 ++
include/linux/iommu.h | 3 +++
2 files changed, 5 insertions(+)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index cd1bca7ede9a..5d814854d825 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2074,6 +2074,7 @@ static void iommu_domain_init(struct iommu_domain *domain, unsigned int type,
domain->owner = ops;
if (!domain->ops)
domain->ops = ops->default_domain_ops;
+ xa_init(&domain->reclaim_list);
}

static struct iommu_domain *
@@ -2126,6 +2127,7 @@ EXPORT_SYMBOL_GPL(iommu_paging_domain_alloc_flags);

void iommu_domain_free(struct iommu_domain *domain)
{
+ xa_destroy(&domain->reclaim_list);
switch (domain->cookie_type) {
case IOMMU_COOKIE_DMA_IOVA:
iommu_put_dma_cookie(domain);
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index ac43b8b93f14..b9611631ea80 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -14,6 +14,7 @@
#include <linux/err.h>
#include <linux/of.h>
#include <linux/iova_bitmap.h>
+#include <linux/xarray.h>
#include <uapi/linux/iommufd.h>

#define IOMMU_READ (1 << 0)
@@ -249,6 +250,8 @@ struct iommu_domain {
struct list_head next;
};
};
+
+ struct xarray reclaim_list;
};

static inline bool iommu_is_dma_domain(struct iommu_domain *domain)
--
2.56.0.rc1.315.gc6ed9934b7-goog