calling flush_scheduled_work()

From: Tim Hockin
Date: Fri Mar 12 2004 - 16:08:13 EST

We've recently bumped into an issue, and I'm not sure which is the real bug.

In short we have a case where mntput() is called from the kevetd workqueue.
When that mntput() hit an NFS mount, we got a deadlock. It turns out that
deep in the RPC code, someone calls flush_scheduled_work(). Deadlock.

So what is the real bug?

Is it verboten to call mntput() from keventd? What other things might lead
to a flush_scheduled_work() and must therefore be avoided?

Should callers of flush_scheduled_work() be changed to use private
workqueues? There are 31 calls that I got from grep. 25 are in drivers/, 1
in ncpfs, 3 in nfs4, 2 in sunrpc. The drivers/ are *probably* ok. Should
those other 6 be changed?

Either way, it seems like there should maybe be a check and a badness
warning if flush_workqueue is called from that workqueue.

Which avenue should we follow? Our own problem can be fixed differently,
but I didn't want to just ignore this unstated assumption that it is safe to
call flush_scheduled_work() anywhere.


Tim Hockin
Sun Microsystems, Linux Software Engineering
All opinions are my own, not Sun's
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at