Re: [PATCH] driver core: shut down devices asynchronously

From: Lukas Wunner
Date: Wed Aug 16 2023 - 11:55:51 EST


On Wed, Aug 16, 2023 at 10:45:18AM -0500, Stuart Hayes wrote:
> Attempt to shut down devices asynchronously, by making a tree of devices with
> associated work and completion structs, to ensure that child devices are shut
> down before parents.
>
> This can dramatically reduce system shutdown/reboot time on systems that have
> devices that take many seconds to shut down, such as some NVMe drives. On once
> system tested, the shutdown time went from 11 minutes before the patch to 55
> seconds with the patch.
>
> The code could be simplified by adding the work and completion structs to
> struct device, but it may make more sense to not burden it with that when there
> is likely enough memory to allocate this at shutdown time, and if there isn???t,
> it just falls back to the current synchronous shutdown.

Please wrap the commit message at 72 chars.

Is there a particular reason why you're not using the infrastructure
provided by kernel/async.c and <async.h>, such as async_schedule()?
It wraps all the work_struct plumbing and also has helpers to await
completion. I imagine using that might reduce LoC in this patch.

Thanks,

Lukas