Re: [PATCH 5/5] mm: support choosing to do THP COW for anonymous pmd entry.

Luka Bai
2026-05-01T15:01:28Z

在 Fri, May 01, 2026 at 09:11:42AM +0200，David Hildenbrand (Arm) 写道：
>
> > - /*
> > - * See do_wp_page(): we can only reuse the folio exclusively if
> > - * there are no additional references. Note that we always drain
> > - * the LRU cache immediately after adding a THP.
> > - */
> > - if (folio_ref_count(folio) >
> > - 1 + folio_test_swapcache(folio) * folio_nr_pages(folio))
> > - goto unlock_fallback;
> > if (folio_test_swapcache(folio))
>
> I don't see why you would want to remove this check, really. Instead of
> "fallback", you might want to try copying the PMD.
>
> --
> Cheers,
>
> David

Sorry I didn't notice this thread earlier. That is a great suggestion! I can keep
this branch and do the folio copying instead of fallback, that actually helps
to avoid the extra checking about swapcache when the refs is definitely not
suitable for exclusive use. Thanks! :)

Best,
Luka