Re: [PATCH v3 2/7] mm/page_ext: fix client data alignment

From: Mike Rapoport

Date: Thu Nov 19 2026 - 03:00:33 EST


On Thu, Nov 19, 2026 at 02:58:07PM +0800, Muchun Song wrote:
> page_ext lays out client payloads consecutively without aligning their
> offsets or the final entry size. This happened to work while the active
> payload sizes kept the stride naturally aligned, but IOMMU debug page
> allocation added a four-byte payload after data requiring eight-byte
> alignment.
>
> When page owner and IOMMU debug page allocation are both enabled on
> x86-64, struct page_ext, struct page_owner, and the IOMMU payload use
> 8, 64, and 4 bytes respectively. This produces a 76-byte entry stride,
> leaving struct page_ext and page_owner data in every other entry only
> four-byte aligned instead of eight-byte aligned.
>
> Align each client offset and round the final entry size to the largest
> active alignment so every page_ext entry preserves the alignment
> required by all active clients.
>
> Fixes: 466ae6978a5b ("iommu: Add page_ext for IOMMU_DEBUG_PAGEALLOC")
> Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
> Reviewed-by: Chris Down <chris@xxxxxxxxxxxxxx>
> Tested-by: Chris Down <chris@xxxxxxxxxxxxxx>

Reviewed-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>

> ---
> v3:
> - Cap client alignment at u64 alignment to preserve 64-bit alignment on
> 32-bit architectures (reported by Sashiko)
> - Open-code the lowest power-of-two factor for readability (suggested by
> Andrew Morton)
> - Use a local for the u64 alignment (suggested by Mike Rapoport)
> - Simplify the commit message to focus on the alignment guarantee
> - Collect Reviewed-by and Tested-by from Chris Down
>
> v2:
> - New patch to fix the existing page_ext client alignment bug
> ---
> mm/page_ext.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)

--
Sincerely yours,
Mike.