On Thu, Apr 11, 2024 at 01:23:43PM +0200, Oscar Salvador wrote: > On Thu, Apr 11, 2024 at 05:00:33PM +0800, Miaohe Lin wrote: > > But as code changes, the above page lock shift is gone. And I think below logic can't > > trigger now. As we hold extra page refcnt so page can't be coallesced into a new THP or Slab page. > > So I was wrong. > I did not check the slap part, but I did check the code that tries to > coallesce pages. > We have the following check in hpage_collapse_scan_pmd(): Even if that check succeeds, collapse_huge_page() works by allocating a new THP, copying the data into it and freeing the existing pages. It doesn't reassemble a THP in-place. I cannot find anywhere that will reassemble smaller folios into larger ones (other than the page allocator, and if you have a refcount on a folio, it can't possibly go into the page allocator).