Hi Matthew, On Mon, Feb 6, 2023 at 12:34 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote: > I now think the mapcount has to be defined as "How many VMAs have > one-or-more pages of this folio mapped". > > That means that our future folio_add_file_rmap_range() looks a bit > like this: > > { > bool add_mapcount = true; > > if (nr < folio_nr_pages(folio)) > add_mapcount = !folio_has_ptes(folio, vma); Can you elaborate on how folio_has_ptes() might be implemented? It seems like for a naturally aligned THP, we can see if the PMD is pmd_present(), otherwise, do we need to check (potentially) all the PTEs? Does this introduce an ordering requirement, where we have to update the page table always before/after we call folio_add_file_rmap_range()? Thanks! - James