Re: [PATCH v10 0/5] shut down devices asynchronously
From: David Jeffery
Date: Fri Jul 04 2025 - 09:38:42 EST
On Thu, Jul 3, 2025 at 7:47 AM Christoph Hellwig <hch@xxxxxx> wrote:
>
> On Wed, Jun 25, 2025 at 03:18:48PM -0500, Stuart Hayes wrote:
> > Address resource and timing issues when spawning a unique async thread
> > for every device during shutdown:
> > * Make the asynchronous threads able to shut down multiple devices,
> > instead of spawning a unique thread for every device.
> > * Modify core kernel async code with a custom wake function so it
> > doesn't wake up threads waiting to synchronize every time the cookie
> > changes
>
> Given all these thread spawning issues, why can't we just go back
> to the approach that kicks off shutdown asynchronously and then waits
> for it without spawning all these threads?
>
The async subsystem fix is something that should be fixed regardless
of async shutdown. Async shutdown's use just exposed its thundering
herd behavior which is easily fixed.
Reducing the threads is just good optimization. Doing every callback
in its own thread adds extra overhead which isn't needed to maintain
ordering and async shutdown gains, and combining sync devices into a
thread where reasonable didn't add that much complexity to the code.
The older non-thread approaches were unpopular with how they still
added plenty of complexity to the shutdown logic while pushing either
ugly splits or their own thread creation down into the individual
shutdown routines of drivers.
David Jeffery