On Tue, Jul 04, 2023 at 09:22:07AM +0800, Yin, Fengwei wrote: > > > On 7/3/2023 9:24 PM, Zi Yan wrote: > > On 2 Jul 2023, at 21:09, Yin, Fengwei wrote: > > > >> On 7/3/2023 3:51 AM, Zi Yan wrote: > >>>> (3) Mapcount of first (or any other) subpage (compount+subpage): for > >>>> folio_estimated_sharers(). > >>> This is another estimation. I wonder if we can use a different estimation > >>> like total_mapcount() > folio_nr_pages() instead. > >> Considering the partial folio mapping, I suppose we should use > >> total_mapcount() > folio->_nr_pages_mapped > >> as folio_estimated_sharers(). > > > > What you propose is to get a precise check instead of estimate, and you assume no PMD mapping and still require per-page mapcount. > > > > What I am proposing is to get rid of per-page mapcount, which is my goal, and use a single mapcount to do a rough estimate. > O. Sorry. I didn't notice your goal. So if the rough estimate is enough, > total_mapcount() > folio_nr_pages() works. > > Do we need to check all the cases to make sure the rough estimation is > enough for all of them? That's definitely not enough for deciding whether we need to COW a page or not. We need to be able to tell the difference between an order-4 folio with page 1 mapped in two tasks and an order-4 folio with page 0 & page 1 mapped in a single task.