Re: [PATCH] iommu/sva: Charge IOPF allocations to the faulting mm's memcg
From: Baolu Lu
Date: Fri Oct 16 2026 - 00:51:40 EST
On 10/13/2026 4:08 AM, Peizhe Liu wrote:
iommu_sva_handle_mm() runs from the IOPF workqueue and calls
handle_mm_fault() for the faulting mm, but does not set the active
memcg. File-backed faults can allocate page cache through
mem_cgroup_charge(folio, NULL, gfp), which falls back to the root memcg
when the worker has neither an active memcg nor a current->mm. Page
cache faulted in by a device is therefore charged to root and escapes
the task's memory.max.
Set the active memcg to the one associated with the faulting mm while
handling the fault, and restore the previous value afterwards.
Fixes: fc36479db74e ("iommu: Add a page fault handler")
Signed-off-by: Peizhe Liu<peizheliu@xxxxxxxxxx>
---
Tested on a Xeon Gold 5512U with Intel DSA, based on iommu/next.
Before/after testing confirmed that the block-on-fault case charges
the page cache to the task's memcg after this change and is subject
to memory.max.
drivers/iommu/iommu-sva.c | 6 ++++++
1 file changed, 6 insertions(+)
Reviewed-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>