Re: [PATCH 5/7] iommufd: account the hw_queue page array to memcg
From: Jason Gunthorpe
Date: Mon Nov 16 2026 - 14:52:24 EST
On Fri, Nov 06, 2026 at 09:18:27PM +0800, Tao Cui wrote:
> From: Tao Cui <cuitao@xxxxxxxxxx>
>
> IOMMUFD_CMD_HW_QUEUE_ALLOC pins up to max_npages pages just to check
> that a user supplied queue region is physically contiguous, and the
> page array for that check is plain GFP_KERNEL. The size comes from
> cmd->length, a u64 that is only overflow checked, and the array is
> freed again as soon as the contiguity check fails, so the allocation
> can be repeated concurrently: a 1GB region costs about 2MB of
> uncharged memory per attempt.
>
> Every other iommufd allocation that scales with user input is already
> charged, and the pinned pages charge the mapper at map time. Charge
> this array like the rest.
>
> Signed-off-by: Tao Cui <cuitao@xxxxxxxxxx>
> ---
> drivers/iommu/iommufd/viommu.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
Jason