[PATCH 0/2] iommufd: remove the last use of set_page_dirty_lock()
From: Tal Zussman
Date: Sat Oct 31 2026 - 16:33:48 EST
batch_rw() copies to and from pinned user pages one page at a time and
dirties each with set_page_dirty_lock(). The second patch walks the pfn
batch a folio at a time with memcpy_to_folio() and memcpy_from_folio()
and marks each folio dirty once. It removes the last use of
set_page_dirty_lock() in iommufd.
The issue fixed in the first patch was found while testing the second:
iommufd_fail_nth turned up a dev_iommu leak in iommu_fwspec_init() under
kmemleak. The fix is independent and could go through the iommu tree on
its own.
Tested on x86 under virtme-ng with KASAN and lockdep against the iommufd
mock driver. The selftests and iommufd_fail_nth all pass.
With ftrace timing iopt_pages_rw_slow() through the mock driver on a
non-debug kernel, slow-path writes to THP-backed pages drop from ~1310 to
~930 ns/page (now the same cost as a read), and writes to 4K folios drop
~9%.
---
Tal Zussman (2):
iommu: free dev->iommu when iommu_fwspec_init() cannot allocate the fwspec
iommufd: copy to and from folios in batch_rw()
drivers/iommu/iommu.c | 6 +++++-
drivers/iommu/iommufd/pages.c | 35 ++++++++++++++++++++---------------
2 files changed, 25 insertions(+), 16 deletions(-)
---
base-commit: 04bcf84613346b973a8cc0c59238b6b5bc902688
change-id: 20261015-iommufd-folio-dirty-8abff4281f3a
Best regards,
--
Tal Zussman <tz2294@xxxxxxxxxxxx>