On Mon, 16 Jan 2023 20:52:45 -0800 Suren Baghdasaryan <surenb@xxxxxxxxxx> > On Mon, Jan 16, 2023 at 7:16 PM Hillf Danton <hdanton@xxxxxxxx> wrote: > > No you are not. > > I'm not wrong or the other way around? Please expand a bit. You are not wrong. > > > > If the writer lock owner is preempted by a reader while releasing lock, > > > > set count to zero > > <-- preempt > > wake up waiters > > > > then lock is owned by reader but with read waiters. > > > > That is buggy if write waiter starvation is allowed in this patchset. > > I don't quite understand your point here. Readers don't wait, so there > can't be "read waiters". Could you please expand with a race diagram > maybe? cpu3 cpu2 --- --- taskA bond to cpu3 down_write(&mm->mmap_lock); vma_write_lock L taskB fail to take L for read taskC fail to take mmap_lock for write taskD fail to take L for read vma_write_unlock_mm(mm); preempted by taskE taskE take L for read and read waiters of L, taskB and taskD, should be woken up up_write(&mm->mmap_lock);