[PATCH slab/for-next v2 09/14] iommu: specify SLAB_MAY_ACCOUNT for slab-backed page table caches

Niklas Schnelle schnelle at linux.ibm.com
Fri Nov 27 13:35:15 UTC 2026


On Wed, 2026-11-25 at 21:37 +0000, Harry Yoo (Meta) wrote:
> vfio, iommufd and vhost-vdpa call iommu_map() with GFP_KERNEL_ACCOUNT
> and the gfp is passed down to the drivers' page table allocations.
> Specify SLAB_MAY_ACCOUNT when the object may be charged to a memcg.
> __GFP_ACCOUNT without SLAB_MAY_ACCOUNT will not be allowed.
> 
> Paths:
>   VFIO_IOMMU_MAP_DMA -> iommu_map(GFP_KERNEL_ACCOUNT)
>     -> s390_iommu_map_pages() -> dma_walk_cpu_trans()
>     -> kmem_cache_alloc(dma_{region,page}_table_cache)
>   iommu_map(GFP_KERNEL_ACCOUNT) -> arm_v7s_map_pages()
>     -> __arm_v7s_alloc_table() -> kmem_cache_zalloc(data->l2_tables)
>   iommu_map(GFP_KERNEL_ACCOUNT) -> sun50i_iommu_map()
>     -> sun50i_dte_get_page_table() -> kmem_cache_zalloc(iommu->pt_pool)
> 
> Cc: Will Deacon <will at kernel.org>
> Cc: Robin Murphy <robin.murphy at arm.com>
> Cc: "Joerg Roedel (AMD)" <joro at 8bytes.org>
> Cc: Niklas Schnelle <schnelle at linux.ibm.com>
> Cc: Matthew Rosato <mjrosato at linux.ibm.com>
> Cc: Gerald Schaefer <gerald.schaefer at linux.ibm.com>
> Cc: Chen-Yu Tsai <wens at kernel.org>
> Cc: Jernej Skrabec <jernej.skrabec at gmail.com>
> Cc: Samuel Holland <samuel at sholland.org>
> Cc: linux-arm-kernel at lists.infradead.org
> Cc: iommu at lists.linux.dev
> Cc: linux-s390 at vger.kernel.org
> Cc: linux-sunxi at lists.linux.dev
> Signed-off-by: Harry Yoo (Meta) <harry at kernel.org>
> ---
>  drivers/iommu/io-pgtable-arm-v7s.c | 2 +-
>  drivers/iommu/s390-iommu.c         | 4 ++--
>  drivers/iommu/sun50i-iommu.c       | 3 ++-
>  3 files changed, 5 insertions(+), 4 deletions(-)
--- snip ---
> index a280ad4f63b7..467b97ec18dc 100644
> --- a/drivers/iommu/s390-iommu.c
> +++ b/drivers/iommu/s390-iommu.c
> @@ -198,14 +198,14 @@ static int __init dma_alloc_cpu_table_caches(void)
>  	dma_region_table_cache = kmem_cache_create("PCI_DMA_region_tables",
>  						   ZPCI_TABLE_SIZE,
>  						   ZPCI_TABLE_ALIGN,
> -						   0, NULL);
> +						   SLAB_MAY_ACCOUNT, NULL);
>  	if (!dma_region_table_cache)
>  		return -ENOMEM;
>  
>  	dma_page_table_cache = kmem_cache_create("PCI_DMA_page_tables",
>  						 ZPCI_PT_SIZE,
>  						 ZPCI_PT_ALIGN,
> -						 0, NULL);
> +						 SLAB_MAY_ACCOUNT, NULL);
>  	if (!dma_page_table_cache) {
>  		kmem_cache_destroy(dma_region_table_cache);
>  		return -ENOMEM;

Looks good and the explanation makes sense to me. Thanks.

Reviewed-by: Niklas Schnelle <schnelle at linux.ibm.com> # s390-iommu



More information about the Linux-security-module-archive mailing list