Re: [PATCH] iommu/sva: Charge IOPF allocations to the faulting mm's memcg
From: Shakeel Butt
Date: Mon Oct 12 2026 - 19:08:26 EST
On Mon, Oct 12, 2026 at 03:08:23PM -0500, 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>
This looks fine from memcg perspective.
Reviewed-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>