On Thu, Dec 16, 2021 at 11:10 PM Huang, Ying <ying.huang@xxxxxxxxx> wrote: > > Minchan Kim <minchan@xxxxxxxxxx> writes: ... > > > > A madv_free marked page could be mapped at several processes so > > it wouldn't be refcount two all the time, I think. > > Shouldn't we check it with page_mapcount with page_refcount? > > > > page_ref_count(page) - 1 > page_mapcount(page) > > > > And should we consider page_count() too in madvise_free_pte_range()? > That is, if the page has been used by GUP, we needn't to make its PTE > clean? Hey, thanks for reviewing! That might not be sufficient time-wise, I guess, because the page can be used by GUP after the madvise() call (e.g., this case), thus checking for it during the call wouldn't catch it -- this may apply to other cases too, where there's no guarantee/ordering between both operations. cheers, -- Mauricio Faria de Oliveira