On Wed, Dec 11, 2024 at 07:01:16PM -0800, Suren Baghdasaryan wrote: > > > > I think your proposal should work. Let me try to code it and see if > > > > something breaks. > > Ok, I tried it out and things are a bit more complex: > 1. We should allow write-locking a detached VMA, IOW vma_start_write() > can be called when vm_refcnt is 0. This sounds dodgy, refcnt being zero basically means the object is dead and you shouldn't be touching it no more. Where does this happen and why? Notably, it being 0 means it is no longer in the mas tree and can't be found anymore. > 2. Adding 0x80000000 saturates refcnt, so I have to use a lower bit > 0x40000000 to denote writers. I'm confused, what? We're talking about atomic_t, right? > 3. Currently vma_mark_attached() can be called on an already attached > VMA. With vma->detached being a separate attribute that works fine but > when we combine it with the vm_lock things break (extra attach would > leak into lock count). I'll see if I can catch all the cases when we > do this and clean them up (not call vma_mark_attached() when not > necessary). Right, I hadn't looked at that thing in detail, that sounds like it needs a wee cleanup like you suggest.