Re: [PATCH] iommu/sva: Charge IOPF allocations to the faulting mm's memcg

From: Muchun Song

Date: Mon Oct 12 2026 - 22:25:28 EST




> On Oct 13, 2026, at 04:08, Peizhe Liu <peizheliu@xxxxxxxxxx> 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>

Acked-by: Muchun Song <muchun.song@xxxxxxxxx>

Thanks.