On Mon, 25 Mar 2024 08:57:52 +0100 Vlastimil Babka <vbabka@xxxxxxx> wrote: > On 3/21/24 15:24, Matthew Wilcox (Oracle) wrote: > > The current folio_test_hugetlb() can be fooled by a concurrent folio split > > into returning true for a folio which has never belonged to hugetlbfs. > > This can't happen if the caller holds a refcount on it, but we have a > > few places (memory-failure, compaction, procfs) which do not and should > > not take a speculative reference. > > In compaction and with CONFIG_DEBUG_VM enabled, the current implementation > can result in an oops, as reported by Luis. This happens since 9c5ccf2db04b > ("mm: remove HUGETLB_PAGE_DTOR") effectively added some VM_BUG_ON() checks > in the PageHuge() testing path. > > > Since hugetlb pages do not use individual page mapcounts (they are always > > fully mapped and use the entire_mapcount field to record the number > > of mappings), the PageType field is available now that page_mapcount() > > ignores the value in this field. > > Reported-by: Luis Chamberlain <mcgrof@xxxxxxxxxx> > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218227 > Fixes: 9c5ccf2db04b ("mm: remove HUGETLB_PAGE_DTOR") > Cc: <stable@xxxxxxxxxxxxxxx> Thanks. The patch doesn't work as a standalone thing. In file included from ./include/linux/mmzone.h:23, from ./include/linux/gfp.h:7, from ./include/linux/slab.h:16, from ./include/linux/crypto.h:17, from arch/x86/kernel/asm-offsets.c:9: ./include/linux/page-flags.h:1021:1: error: return type defaults to 'int' [-Werror=implicit-int] 1021 | FOLIO_TYPE_OPS(hugetlb, hugetlb) | ^~~~~~~~~~~~~~ ./include/linux/page-flags.h:1021:1: error: function declaration isn't a prototype [-Werror=strict-prototypes] ./include/linux/page-flags.h: In function 'FOLIO_TYPE_OPS': ./include/linux/page-flags.h:1035:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token <a million more> Matthew, could you please redo this patch (and its vmcore fix) and send as a standalone -stable patch? It could be that the "Various significant MM patches" will need a redo afterwards.