Re: [PATCH v3] mm/hugetlb: fix hugetlb vs. core-mm PT locking

From: David Hildenbrand
Date: Thu Aug 01 2024 - 03:35:37 EST


pte_alloc_one() ends up calling pte_fragment_alloc(mm, 0). But there we always
end up calling pagetable_alloc(, 0).

And fragments are supposed to be <= a single page.

Now I'm confused what's wrong here ... am I missing something obvious?

CCing some powerpc folks. Is this some pte_t oddity?

It will be because PTRS_PER_PTE is not a compile time constant :(

Oh, sneaky! Thanks a bunch!


$ git grep "define PTRS_PER_PTE" arch/powerpc/include/asm/book3s/64
arch/powerpc/include/asm/book3s/64/pgtable.h:#define PTRS_PER_PTE (1 << PTE_INDEX_SIZE)
$ git grep "define PTE_INDEX_SIZE" arch/powerpc/include/asm/book3s/64
arch/powerpc/include/asm/book3s/64/pgtable.h:#define PTE_INDEX_SIZE __pte_index_size
$ git grep __pte_index_size arch/powerpc/mm/pgtable_64.c
arch/powerpc/mm/pgtable_64.c:unsigned long __pte_index_size;

Which is because the pseries/powernv (book3s64) kernel supports either
the HPT or Radix MMU at runtime, and they have different page table
geometry.

If you change it to use MAX_PTRS_PER_PTE it should work (that's defined
for all arches).

Yes, that should fly, thanks again!

--
Cheers,

David / dhildenb