Re: [PATCH] Export current_is_keventd() for libphy

Maciej W. Rozycki
2006-12-06T15:25:32Z

On Tue, 5 Dec 2006, Andrew Morton wrote:

> But running flush_scheduled_work() from within dev_close() is a very
> sensible thing to do, and dev_close is called under rtnl_lock().
> davem is -> thattaway ;)

And when within dev_close() there is quite a chance there is
linkwatch_event() somewhere in the event queue already. ;-)

> Ah. The point is that the phy code doesn't want to flush _all_ pending
> callbacks. It only wants to flush its own one. And its own one doesn't
> take rtnl_lock().
>
> IOW, the phy code has no interest in running some random other subsystem's
> callback - it just wants to run its own. Hence no deadlock.

Both are true. It's linkwatch_event() that's somewhere in the queue
already that makes the trouble here.

> Maybe the lesson here is that flush_scheduled_work() is a bad function.
> It should really be flush_this_work(struct work_struct *w). That is in
> fact what approximately 100% of the flush_scheduled_work() callers actually
> want to do.

There may be cases where flush_scheduled_work() is indeed needed, but
likely outside drivers, and I agree such a specific call would be useful
and work here.

Maciej