Re: [PATCH] x86/mm: don't apply va_align to hugetlb mappings on AMD F15h
From: Dave Hansen
Date: Mon Sep 21 2026 - 14:09:33 EST
On 9/19/26 01:47, Laurent Wandrebeck wrote:
> static unsigned long get_align_mask(struct file *filp)
> {
> - if (filp && is_file_hugepages(filp))
> + if (is_file_hugepages(filp))
> return huge_page_mask_align(filp);
> /* handle 32- and 64-bit case with a single conditional */
> if (va_align.flags < 0 || !(va_align.flags & (2 - mmap_is_ia32())))
I'd just leave that hunk out for now. It's harmless to leave.
> @@ -50,9 +50,13 @@ static unsigned long get_align_mask(struct file *filp)
> * value before calling vm_unmapped_area() or ORed directly to the
> * address.
> */
> -static unsigned long get_align_bits(void)
> +static unsigned long get_align_bits(struct file *filp)
> {
> - return va_align.bits & get_align_mask(NULL);
> + /* hugetlb mappings must stay on the huge page boundary. */
> + if (is_file_hugepages(filp))
> + return 0;
I don't find that comment helpful. The function is kinda misnamed a bit
too. Maybe a comment like this?
/*
* va_align.bits is smaller than the huge page size and will
* lead to misaligned huge pages. Ignore it for huge mappings.
*/
> + return va_align.bits & get_align_mask(filp);
> }
>
> static int __init control_va_addr_alignment(char *str)
> @@ -157,7 +161,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len,
> }
> if (filp) {
> info.align_mask = get_align_mask(filp);
> - info.align_offset += get_align_bits();
> + info.align_offset += get_align_bits(filp);
> }
>
> return vm_unmapped_area(&info);
> @@ -222,7 +226,7 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr0,
>
> if (filp) {
> info.align_mask = get_align_mask(filp);
> - info.align_offset += get_align_bits();
> + info.align_offset += get_align_bits(filp);
> }
That looks fine too. I would rather this whole mechanism die,
personally. But this is a fine, backportable fix.