Re: [REGRESSION] x86/hugetlb: AMD F15h VA alignment offset breaks MAP_HUGETLB alignment
From: Oscar Salvador (SUSE)
Date: Thu May 28 2026 - 01:50:44 EST
On Wed, May 27, 2026 at 02:04:10PM -0700, Dave Hansen wrote:
> On 5/27/26 11:28, Oscar Salvador (SUSE) wrote:
> > if (filp) {
> > info.align_mask = get_align_mask(filp);
> > - info.align_offset += get_align_bits();
> > + /*
> > + * Hugepages must remain hugepage-aligned, so skip adding an offset
> > + * in case we enabled 'align_va_addr'.
> > + */
> > + if (!is_file_hugepages(filp))
> > + info.align_offset += get_align_bits();
> > }
>
> That's a good hack to show the scope of the problem.
Haha, do not worry, I myself have 0 interestin spreading hugetlb-specific
code around (on the contrary), but I wanted to proof the point.
>
> But I'd really rather this be dealt with in the arch-independent code,
> not by adding hugetlb hacks to arch code. It isn't even clear to me what
> exactly goes wrong when you set a tiny ->align_offset and have a larger
> ->align_mask. Shouldn't the tiny offset just get masked off?
>
> gap += (info->align_offset - gap) & info->align_mask;
I would assume so, but something is definitely going in with the calculation,
as I could reproduce this if I artificially set align_offset to 0x1000 for
hugetlb mappings.
I will find some time today to have a deep look.
--
Oscar Salvador
SUSE Labs