Re: [PATCH] Pass mode to wait_on_atomic_t() action funcs and provide default actions

From: David Howells
Date: Thu Nov 02 2017 - 12:45:59 EST


Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:

> > The moment atomic_dec_and_test() is called, *net is at liberty to disappear,
> > so there's no way to find a waitqueue - unless that waitqueue is guaranteed
> > not to be deallocated, eg. by being global.
>
> But any possible wait side will still need to dereference *net at an
> indeterminate point in the future to ascertain the value does now indeed
> read 0.

Yeah, the assumption is that the *wait* side is where the deallocation is
happening. So I have something like:

net->live = false; // Tell the cell managers to delete the cells
...
foreach (cell)
queue_work(cell);
...
wait_on_atomic_t(&net->cells_outstanding, atomic_t_wait,
TASK_UNINTERRUPTIBLE);
...
destroy(net);

> ... We can certainly start with your patch, as that does clean things up.

Can I put that down as a Grudgingly-acked-by?

David