On Thu, Jan 24, 2019 at 03:07:12PM +0200, Moni Shoua wrote: > The purpose in this fix was to prevent a specific bad from happening: > num_leaf_free from being incremented too many times and causing the > flow to wait forever in > > wait_event(imr->q_leaf_free, !atomic_read(&imr->num_leaf_free)); > > This could happen because there were 2 flows that looked like > > if (umem_odp->dying) > return 0; > <<< dying could > change from 0 to 1 here > WRITE_ONCE(umem_odp->dying, 1); > atomic_inc(&imr->num_leaf_free); > > Replacing the critical section with atomic_add_unless() solves the problem IMO As I said, this coding pattern should be done with test_and_set not with atomics. test_and_set are atomic and include the required barriers to make this work right. Jason