On Thu, 2019-09-26 at 16:56 +0000, Quinn Tran wrote: > > Are you missing a negation in this last line? > Also, what's the point of adding this loop? > > QT: good catch. The idea is to not sleep the full 10Hz, if the > vref_count already reaches zero or reaches zero under > 10Hz. Otherwise, loop/wait for 10Hz. We're trying to get NPIV tear > down to go faster. AFAIU, wait_event_timeout() returns before the timeout has elapsed, if the tested condition becomes true _and_ the wait queue is woken up. Thus the loop shouldn't be necessary. Are you missing a wake_up() call to vref_waitq somewhere? Perhaps you should replace all calls to atomic_dec(&X->vref_count); with something like if (atomic_dec_and_test(&X->vref_count)) wake_up(&X->vref_waitq); ?? Martin