Thread (55 messages) 55 messages, 7 authors, 2025-03-18

Re: [PATCH v3 04/23] iommu/pages: Make iommu_put_pages_list() work with high order allocations

From: Baolu Lu <baolu.lu@linux.intel.com>
Date: 2025-02-26 06:33:41
Also in: asahi, linux-iommu, linux-patches, linux-riscv, linux-rockchip, linux-samsung-soc, linux-sunxi, linux-tegra

On 2/26/25 03:39, Jason Gunthorpe wrote:
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")
Signed-off-by: Jason Gunthorpe<jgg@nvidia.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help