Skip to content

Commit

Permalink
iommufd: Use GFP_KERNEL_ACCOUNT for iommu_map()
Browse files Browse the repository at this point in the history
iommufd follows the same design as KVM and uses memory cgroups to limit
the amount of kernel memory a iommufd file descriptor can pin down. The
various internal data structures already use GFP_KERNEL_ACCOUNT.

However, one of the biggest consumers of kernel memory is the IOPTEs
stored under the iommu_domain. Many drivers will allocate these at
iommu_map() time and will trivially do the right thing if we pass in
GFP_KERNEL_ACCOUNT.

Reviewed-by: Kevin Tian <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Joerg Roedel <[email protected]>
  • Loading branch information
jgunthorpe authored and joergroedel committed Jan 25, 2023
1 parent 96d5780 commit e787a38
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/iommu/iommufd/pages.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ static int batch_iommu_map_small(struct iommu_domain *domain,

while (size) {
rc = iommu_map(domain, iova, paddr, PAGE_SIZE, prot,
GFP_KERNEL);
GFP_KERNEL_ACCOUNT);
if (rc)
goto err_unmap;
iova += PAGE_SIZE;
Expand Down Expand Up @@ -502,7 +502,7 @@ static int batch_to_domain(struct pfn_batch *batch, struct iommu_domain *domain,
rc = iommu_map(domain, iova,
PFN_PHYS(batch->pfns[cur]) + page_offset,
next_iova - iova, area->iommu_prot,
GFP_KERNEL);
GFP_KERNEL_ACCOUNT);
if (rc)
goto err_unmap;
iova = next_iova;
Expand Down

0 comments on commit e787a38

Please sign in to comment.