On Thu, Dec 2, 2021 at 11:59 AM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote: > > Oh absolutely, it's semantically nonsense. The only reason it fixes the > problem is that VM_DENYWRITE VMAs are the only ones considered for the > RO_THP merging, so they're the only ones which we've seen causing a > problem. That would be a semantically meaningful argument, but I think the reverse isn't true: regular pages in VM_DENYWRITE vmas - that aren't using the RO_THP thing - are open to the same old "COW wrong way" issue. So it's not like VM_DENYWRITE is really meaningful for the conditional, even if it's perhaps a prerequisite for it being a problem. > > I suspect a real fix would be bigger and more invasive. > > Darn. I was hoping you were going to say something like "The real > problem is follow_trans_huge_pmd() is complete garbage and it should > just do X, Y and Z". Or "When we force on FOLL_WRITE, we should also > force on FOLL_SPLIT_PMD". Well, maybe that "FOLL_SPLIT_PMD" thing would indeed be a valid thing? But I _think_ that it shouldn't be too painful to do the should_force_cow_break() call later, when you actually have the exact page details, so while not exactly a one-liner, I hope that approach would end up working out. I only gave it a quick look, though, I might be missing something. Linus