On Mon, Feb 06, 2023 at 04:13:44PM +0100, David Hildenbrand wrote: > > > The handling of cow pages is still very clunky. > > > folio_add_new_anon_rmap() handles anonymous large folios just fine. I > > > think David was looking at current code, not the code in mm-next. > > OK. Let's wait for further comment from David. > > As I raised, page_add_new_anon_rmap() -> folio_add_new_anon_rmap() can be > used to add a fresh (a) PMD-mapped THP or (b) order-0 folio. > > folio_add_new_anon_rmap() is not suitable for PTE-mapping a large folio. > Which is what we are intending to do here unless I am completely off. I think you are. While the infrastructure here handles large folios which are not PMDs, there's nobody who will allocate such a thing, so there is no problem. Right> > PTE-mapping a large folio requires different accounting, different mapcount > handling and different PG_anon_exclusive handling. > > Which is all not there yet. Assuming you mean "a large folio which is not PMD sized", I agree. But we haven't even started discussing how we should decide to allocate folios which are not 0 or PMD order yet, so this worry seems premature. When we have figured that out, it'll be time to look at folio_add_new_anon_rmap() to decide how to support it, but hopefully before then we'll have a better way of handling mapcount.