[RFC PATCH 1/6] minimal async shutdown infrastructure
David Jeffery
djeffery at redhat.com
Wed Feb 14 12:55:36 PST 2024
On Tue, Feb 13, 2024 at 10:43 PM Saravana Kannan <saravanak at google.com> wrote:
>
> On Wed, Feb 7, 2024 at 10:40 AM David Jeffery <djeffery at redhat.com> wrote:
> >
> > + * Wait for all async shutdown operations currently active to complete
> > + */
> > +static void wait_for_active_async_shutdown(void)
> > +{
> > + struct device *dev, *parent;
> > +
> > + while (!list_empty(&async_shutdown_list)) {
> > + dev = list_entry(async_shutdown_list.next, struct device,
> > + kobj.entry);
> > +
> > + parent = dev->parent;
>
> I didn't check the code thoroughly, but so there might be other big
> issues. But you definitely need to take device links into account.
> Shutdown all your consumers first similar to how you shutdown the
> children devices first. Look at the async suspend/resume code for some
> guidance.
>
Sure, I'll work on adding that into the order rules.
> > @@ -110,6 +115,8 @@ struct device_driver {
> > void (*sync_state)(struct device *dev);
> > int (*remove) (struct device *dev);
> > void (*shutdown) (struct device *dev);
> > + void (*async_shutdown_start) (struct device *dev);
> > + void (*async_shutdown_end) (struct device *dev);
>
> Why not use the existing shutdown and call it from an async thread and
> wait for it to finish? Similar to how async probes are handled. Also,
> adding separate ops for this feels clunky and a very narrow fix. Just
> use a flag to indicate the driver can support async shutdown using the
> existing shutdown() op.
>
It is rather clunky. It was carried from older patches where I
mistakenly thought people wanted this separate interface. And adding
threads seemed like overkill. Others have been working on similar
patches on linux-nvme that I was unaware of. They add an optional
shutdown_wait call instead of this interface. I had planned on
adapting to work with their interface design.
David Jeffery
More information about the Linux-nvme
mailing list