Skip to content

Commit 160912f

Browse files
soleenAlex Williamson
authored andcommitted
vfio/type1: account iommu allocations
iommu allocations should be accounted in order to allow admins to monitor and limit the amount of iommu memory. Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/20231130200900.2320829-1-pasha.tatashin@soleen.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent 33cc938 commit 160912f

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/vfio/vfio_iommu_type1.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ static int vfio_iommu_map(struct vfio_iommu *iommu, dma_addr_t iova,
14361436
list_for_each_entry(d, &iommu->domain_list, next) {
14371437
ret = iommu_map(d->domain, iova, (phys_addr_t)pfn << PAGE_SHIFT,
14381438
npage << PAGE_SHIFT, prot | IOMMU_CACHE,
1439-
GFP_KERNEL);
1439+
GFP_KERNEL_ACCOUNT);
14401440
if (ret)
14411441
goto unwind;
14421442

@@ -1750,7 +1750,8 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu,
17501750
}
17511751

17521752
ret = iommu_map(domain->domain, iova, phys, size,
1753-
dma->prot | IOMMU_CACHE, GFP_KERNEL);
1753+
dma->prot | IOMMU_CACHE,
1754+
GFP_KERNEL_ACCOUNT);
17541755
if (ret) {
17551756
if (!dma->iommu_mapped) {
17561757
vfio_unpin_pages_remote(dma, iova,
@@ -1845,7 +1846,8 @@ static void vfio_test_domain_fgsp(struct vfio_domain *domain, struct list_head *
18451846
continue;
18461847

18471848
ret = iommu_map(domain->domain, start, page_to_phys(pages), PAGE_SIZE * 2,
1848-
IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE, GFP_KERNEL);
1849+
IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE,
1850+
GFP_KERNEL_ACCOUNT);
18491851
if (!ret) {
18501852
size_t unmapped = iommu_unmap(domain->domain, start, PAGE_SIZE);
18511853

0 commit comments

Comments
 (0)