Hugh Dickins wrote: > On Sun, 28 Aug 2005, Nick Piggin wrote: > >>This is the condition I ended up with. Any good? >> >>if (!(vma->vm_flags & (VM_HUGETLB|VM_NONLINEAR|VM_RESERVED))) { >>if (vma->vm_flags & VM_MAYSHARE) >> return 0; >>if (vma->vm_file && !vma->anon_vma) >> return 0; >>} > > > It's not bad, and practical timings are unlikely to differ, but your > VM_MAYSHARE test is redundant (VM_MAYSHARE areas don't have anon_vmas *), > and your vm_file test is unnecessary, excluding pure anonymous areas > which haven't yet taken a fault. > Haven't taken a _write_ fault? Hmm, OK that would seem to be a good optimisation as well: we don't need to copy anon memory with only ZERO_PAGE mappings... well, good as in "nice and logical" if not so much "will make a difference"! > Please do send Andrew the patch for -mm, Nick: you were one of the > creators of this (don't omit credit to Ray, Parag, Andi, Rik, Linus), > much better that it go in your name (heh, heh, heh, can you trust me?) > Well Andi and I seemed to have the idea independently, Linus thought private would be a good idea (I agree), you came up with the complete patch with others contributing bits and pieces, and most importantly Ray brought our attention to the possible deficiency in our mm. > Hugh > > * That's ignoring, as we do everywhere else, the case which came up > a couple of weeks back in discussions with Linus, ptrace writing to > an area the process does not have write access to, creating an anon > page within a shared vma: that's an awkward case currently mishandled, > but the patch below does it no harm. > And in that case maybe your patch works better anyway, because the child will inherit that page from parent. How does the following look? (I changed the comment a bit). Andrew, please apply if nobody objects. -- SUSE Labs, Novell Inc.