diff options
author | Jason Gunthorpe <jgg@nvidia.com> | 2025-04-08 13:53:52 -0300 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2025-04-17 16:22:33 +0200 |
commit | c11a1a47921515c2707d078eb7bd8f35db20f146 (patch) | |
tree | 227d7e789ae811cf27185a37cfef2e0da00c39e4 /tools/perf/scripts/python/gecko.py | |
parent | 8360c03dd9331e60fc6f5dbe512a01a14e8bc3b3 (diff) |
iommu/pages: Make iommu_put_pages_list() work with high order allocations
alloc_pages_node(, order) needs to be paired with __free_pages(, order) to
free all the allocated pages. For order != 0 the return from
alloc_pages_node() is just a page list, it hasn't been formed into a
folio.
However iommu_put_pages_list() just calls put_page() on the head page of
an allocation, which will end up leaking the tail pages if order != 0.
Fix this by using __GFP_COMP to create a high order folio and then always
use put_page() to free the full high order folio.
__iommu_free_account() can get the order of the allocation via
folio_order(), which corrects the accounting of high order allocations in
iommu_put_pages_list(). This is the same technique slub uses.
As far as I can tell, none of the places using high order allocations are
also using the free list, so this not a current bug.
Fixes: 06c375053cef ("iommu/vt-d: add wrapper functions for page allocations")
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Tested-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/4-v4-c8663abbb606+3f7-iommu_pages_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'tools/perf/scripts/python/gecko.py')
0 files changed, 0 insertions, 0 deletions