linux/include
Yu Zhao 9d08ec41a0 mm: allow set/clear page_type again
Some page flags (page->flags) were converted to page types
(page->page_types).  A recent example is PG_hugetlb.

From the exclusive writer's perspective, e.g., a thread doing
__folio_set_hugetlb(), there is a difference between the page flag and
type APIs: the former allows the same non-atomic operation to be repeated
whereas the latter does not.  For example, calling __folio_set_hugetlb()
twice triggers VM_BUG_ON_FOLIO(), since the second call expects the type
(PG_hugetlb) not to be set previously.

Using add_hugetlb_folio() as an example, it calls __folio_set_hugetlb() in
the following error-handling path.  And when that happens, it triggers the
aforementioned VM_BUG_ON_FOLIO().

  if (folio_test_hugetlb(folio)) {
    rc = hugetlb_vmemmap_restore_folio(h, folio);
    if (rc) {
      spin_lock_irq(&hugetlb_lock);
      add_hugetlb_folio(h, folio, false);
      ...

It is possible to make hugeTLB comply with the new requirements from the
page type API.  However, a straightforward fix would be to just allow the
same page type to be set or cleared again inside the API, to avoid any
changes to its callers.

Link: https://lkml.kernel.org/r/20241020042212.296781-1-yuzhao@google.com
Fixes: d99e3140a4 ("mm: turn folio_test_hugetlb into a PageType")
Signed-off-by: Yu Zhao <yuzhao@google.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-10-30 20:14:12 -07:00
..
acpi
asm-generic
clocksource
crypto
cxl
drm
dt-bindings
keys
kunit
kvm
linux mm: allow set/clear page_type again 2024-10-30 20:14:12 -07:00
math-emu
media
memory
misc
net Including fixes from netfiler, xfrm and bluetooth. 2024-10-24 16:43:50 -07:00
pcmcia
ras
rdma
rv
scsi
soc
sound
target
trace vfs-6.12-rc5.fixes 2024-10-21 10:48:24 -07:00
uapi sound fixes for 6.12-rc5 2024-10-25 10:35:29 -07:00
ufs
vdso
video
xen xen: Remove dependency between pciback and privcmd 2024-10-18 11:59:04 +02:00