From: Christoph Hellwig <hch@lst.de>
To: Keith Busch <kbusch@kernel.org>
Cc: Sagi Grimberg <sagi@grimberg.me>, Christoph Hellwig <hch@lst.de>,
Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>
Subject: Re: [PATCH] nvme-pci: silence a lockdep complaint
Date: Thu, 23 May 2024 10:06:52 +0200 [thread overview]
Message-ID: <20240523080652.GA1086@lst.de> (raw)
In-Reply-To: <Zk5lU1IqmLAhhSCX@kbusch-mbp.dhcp.thefacebook.com>
On Wed, May 22, 2024 at 03:36:19PM -0600, Keith Busch wrote:
> + mutex_lock(&ctrl->namespaces_lock);
> + list_del_rcu(&ns->list);
> + mutex_unlock(&ctrl->namespaces_lock);
This needs a synchronize_srcu(). Maybe factor out a helper to share the
code with nvme_ns_remove?
> - down_write(&ctrl->namespaces_rwsem);
> + mutex_lock(&ctrl->namespaces_lock);
> list_for_each_entry_safe(ns, next, &ctrl->namespaces, list) {
> if (ns->head->ns_id > nsid)
> - list_move_tail(&ns->list, &rm_list);
> + list_splice_init_rcu(&ns->list, &rm_list, synchronize_rcu);
Overly long line here.
> }
> - up_write(&ctrl->namespaces_rwsem);
> + mutex_unlock(&ctrl->namespaces_lock);
>
> list_for_each_entry_safe(ns, next, &rm_list, list)
> nvme_ns_remove(ns);
>
> + synchronize_srcu(&ctrl->srcu);
The synchronize_srcu should go right after the mutex_unlock as it
synchronizes the ctrl->namespaces access.
> + mutex_lock(&ctrl->namespaces_lock);
> + list_splice_init_rcu(&ctrl->namespaces, &ns_list, synchronize_rcu);
> + mutex_unlock(&ctrl->namespaces_lock);
>
> list_for_each_entry_safe(ns, next, &ns_list, list)
> nvme_ns_remove(ns);
> +
> + synchronize_srcu(&ctrl->srcu);
Same here.
> kref_get(&ns->kref);
> - up_read(&ctrl->namespaces_rwsem);
> + srcu_read_unlock(&ctrl->srcu, srcu_idx);
The kref_get here has to become a kref_get_unless_zero (aka nvme_get_ns).
prev parent reply other threads:[~2024-05-23 9:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 9:15 [PATCH] nvme-pci: silence a lockdep complaint Sagi Grimberg
2024-05-22 12:18 ` Shinichiro Kawasaki
2024-05-22 16:12 ` Keith Busch
2024-05-22 16:28 ` Christoph Hellwig
2024-05-22 18:00 ` Sagi Grimberg
2024-05-22 21:36 ` Keith Busch
2024-05-23 6:54 ` Christoph Hellwig
2024-05-23 10:04 ` Sagi Grimberg
2024-05-23 12:39 ` Christoph Hellwig
2024-05-23 13:02 ` Sagi Grimberg
2024-05-23 13:19 ` Christoph Hellwig
2024-05-23 13:45 ` Sagi Grimberg
2024-05-23 15:02 ` Keith Busch
2024-05-23 8:06 ` Christoph Hellwig [this message]
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=20240523080652.GA1086@lst.de \
--to=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=shinichiro.kawasaki@wdc.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.