On Mon, Dec 21, 2020 at 12:21 PM Yu Zhao <yuzhao@xxxxxxxxxx> wrote: > > Well, unfortunately we have places that use optimizations like > > inc_tlb_flush_pending() > lock page table > pte_wrprotect > flush_tlb_range() > dec_tlb_flush_pending() > > which complicate things. My point is, none of that matters. Because the software side that does the actual page table modifications do not depend on the TLB at all. They depend on the page table lock, and the pte in memory. So the "pending flush" simply shoudln't be an issue. It's about the actual hardware usage. But what DOES matter for the software accesses is that you can't modify protections without holding the proper lock. And userfaultfd seems to do exactly that, breaking the whole "load pte early, then check that it didn't change". (Which we do in other places too, not just COW - it's basically _the_ pattern for page table updates). Linus