Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Jeremy Allison <jra@samba.org>, Jeremy Allison <jallison@ciq.com>,
	tansuresh@google.com, gregkh@linuxfoundation.org,
	rafael@kernel.org, bhelgaas@google.com,
	linux-nvme@lists.infradead.org
Subject: Re: [PATCH 1/4] driver core: Support two-pass driver shutdown
Date: Fri, 5 Jan 2024 12:15:17 -0600	[thread overview]
Message-ID: <20240105181517.GA1861750@bhelgaas> (raw)
In-Reply-To: <20240105042955.GC23630@lst.de>

On Fri, Jan 05, 2024 at 05:29:55AM +0100, Christoph Hellwig wrote:
> On Tue, Jan 02, 2024 at 10:07:30AM -0800, Jeremy Allison wrote:
> >> But I'm not a workqueue expert and I do see the scary warning at
> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/workqueue.h?id=v6.6#n619,
> >> about not flushing system-wide workqueues, so maybe this wouldn't be
> >> workable.
> >
> > This is a bigger change than I'm comfortable with
> > (or indeed understand :-) right now. Can we fix
> > the immediate problem first please and then look
> > for improvements later ?
> 
> It's also a lot less efficient.  Assuming NVMe isn't alone and other
> hardware interfaces also have a shutdown/disable busy wait (and I've seen
> quite a few that do) as their limiting factor the two-pass shutdown seems
> much nicer than spawning tons of work items.

Here's the essence of the two-pass proposal, adding .shutdown_wait():

    device_shutdown
      for_each_device
        dev->bus->shutdown()
          ...
            nvme_shutdown
              nvme_disable_prepare_reset
                nvme_dev_disable
                  nvme_disable_ctrl
  +                 case NVME_DISABLE_SHUTDOWN_ASYNC:
  +                   return;
  +                 case NVME_DISABLE_SHUTDOWN_SYNC:
                      nvme_wait_ready(...);
  +     if (dev->bus->shutdown_wait)
  +       list_add(&shutdown_wait_list)
  +
  +   for_each(&shutdown_wait_list)
  +     dev->bus->shutdown_wait()
  +       pci_device_shutdown_wait
  +         nvme_shutdown_wait
  +           nvme_wait_ready(...)

FWIW, what I imagined was something like this, where we don't add
.shutdown_wait(), but any .shutdown() method could become asynchronous
by queuing a work item to do the wait:

  + nvme_wait_ready_work
  +   nvme_wait_ready(...)

    device_shutdown
  +   async_shutdown_wq = create_workqueue("async_shutdown");
      for_each_device
        dev->bus->shutdown()
          ...
            nvme_shutdown
              nvme_disable_prepare_reset
                nvme_dev_disable
                  nvme_disable_ctrl
  +                 case NVME_DISABLE_SHUTDOWN_ASYNC:
  +                   queue_work(async_shutdown_wq, &nvme_wait_ready_work)
  +                   return;
  +                 case NVME_DISABLE_SHUTDOWN_SYNC:
                      nvme_wait_ready(...);
  +
  +   destroy_workqueue(async_shutdown_wq);

This is a bit of hand waving because I'm not a workqueue expert, but
it seems like basically the same amount of overhead without having to
add .shutdown_wait() to the bus_type and the pci_driver.

Bjorn


  reply	other threads:[~2024-01-05 18:15 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21 17:22 Make NVME shutdown two-pass - Version 3 Jeremy Allison
2023-12-21 17:22 ` [PATCH 1/4] driver core: Support two-pass driver shutdown Jeremy Allison
2023-12-21 17:29   ` Greg KH
2023-12-27 20:33   ` Bjorn Helgaas
2024-01-01  9:23     ` Sagi Grimberg
2024-01-02 23:12       ` Jeremy Allison
2024-01-05  4:28         ` Christoph Hellwig
2024-01-02 18:07     ` Jeremy Allison
2024-01-05  4:29       ` Christoph Hellwig
2024-01-05 18:15         ` Bjorn Helgaas [this message]
2024-01-08  8:28           ` Christoph Hellwig
2023-12-21 17:22 ` [PATCH 2/4] PCI: Support two-pass shutdown Jeremy Allison
2023-12-21 17:22 ` [PATCH 3/4] Change 'bool shutdown' into an enum shutdown_type { NVME_DISABLE_RESET = 0, NVME_DISABLE_SHUTDOWN_SYNC = 1 } Jeremy Allison
2023-12-27 19:33   ` Bjorn Helgaas
2024-01-02 18:06     ` Jeremy Allison
2023-12-21 17:22 ` [PATCH 4/4] nvme: Add two-pass shutdown support Jeremy Allison
2023-12-25  9:58   ` Sagi Grimberg
2023-12-27  0:53     ` Jeremy Allison
2024-01-01  9:21       ` Sagi Grimberg
2024-01-02 18:03         ` Jeremy Allison
2024-01-03  8:36           ` Sagi Grimberg
2024-01-03 17:41             ` Jeremy Allison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240105181517.GA1861750@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=jallison@ciq.com \
    --cc=jra@samba.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=rafael@kernel.org \
    --cc=tansuresh@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox