All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: fix the suspicious RCU usage warning in nvme_mpath_clear_current_path
@ 2018-04-18  7:32 ` Jianchao Wang
  0 siblings, 0 replies; 8+ messages in thread
From: Jianchao Wang @ 2018-04-18  7:32 UTC (permalink / raw)
  To: keith.busch, axboe, hch, sagi, linux-nvme, linux-kernel

With lockdep enabled, when trigger nvme_remove, suspicious RCU
usage warning will be printed out.
Fix it with adding srcu_read_lock/unlock in it.

Signed-off-by: Jianchao Wang <jianchao.w.wang@oracle.com>
---
 drivers/nvme/host/nvme.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 061fecf..d326c23 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -446,9 +446,14 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head);
 static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
 {
 	struct nvme_ns_head *head = ns->head;
+	int srcu_idx;
 
-	if (head && ns == srcu_dereference(head->current_path, &head->srcu))
-		rcu_assign_pointer(head->current_path, NULL);
+	if (head) {
+		srcu_idx = srcu_read_lock(&head->srcu);
+		if (ns == srcu_dereference(head->current_path, &head->srcu))
+			rcu_assign_pointer(head->current_path, NULL);
+		srcu_read_unlock(&head->srcu, srcu_idx);
+	}
 }
 struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] nvme: fix the suspicious RCU usage warning in nvme_mpath_clear_current_path
@ 2018-04-18  7:32 ` Jianchao Wang
  0 siblings, 0 replies; 8+ messages in thread
From: Jianchao Wang @ 2018-04-18  7:32 UTC (permalink / raw)


With lockdep enabled, when trigger nvme_remove, suspicious RCU
usage warning will be printed out.
Fix it with adding srcu_read_lock/unlock in it.

Signed-off-by: Jianchao Wang <jianchao.w.wang at oracle.com>
---
 drivers/nvme/host/nvme.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 061fecf..d326c23 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -446,9 +446,14 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head);
 static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
 {
 	struct nvme_ns_head *head = ns->head;
+	int srcu_idx;
 
-	if (head && ns == srcu_dereference(head->current_path, &head->srcu))
-		rcu_assign_pointer(head->current_path, NULL);
+	if (head) {
+		srcu_idx = srcu_read_lock(&head->srcu);
+		if (ns == srcu_dereference(head->current_path, &head->srcu))
+			rcu_assign_pointer(head->current_path, NULL);
+		srcu_read_unlock(&head->srcu, srcu_idx);
+	}
 }
 struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] nvme: fix the suspicious RCU usage warning in nvme_mpath_clear_current_path
  2018-04-18  7:32 ` Jianchao Wang
@ 2018-04-18 10:19   ` Christoph Hellwig
  -1 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2018-04-18 10:19 UTC (permalink / raw)
  To: Jianchao Wang; +Cc: keith.busch, axboe, hch, sagi, linux-nvme, linux-kernel

On Wed, Apr 18, 2018 at 03:32:47PM +0800, Jianchao Wang wrote:
> With lockdep enabled, when trigger nvme_remove, suspicious RCU
> usage warning will be printed out.
> Fix it with adding srcu_read_lock/unlock in it.

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] nvme: fix the suspicious RCU usage warning in nvme_mpath_clear_current_path
@ 2018-04-18 10:19   ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2018-04-18 10:19 UTC (permalink / raw)


On Wed, Apr 18, 2018@03:32:47PM +0800, Jianchao Wang wrote:
> With lockdep enabled, when trigger nvme_remove, suspicious RCU
> usage warning will be printed out.
> Fix it with adding srcu_read_lock/unlock in it.

Looks fine,

Reviewed-by: Christoph Hellwig <hch at lst.de>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] nvme: fix the suspicious RCU usage warning in nvme_mpath_clear_current_path
  2018-04-18  7:32 ` Jianchao Wang
@ 2018-04-18 14:45   ` Keith Busch
  -1 siblings, 0 replies; 8+ messages in thread
From: Keith Busch @ 2018-04-18 14:45 UTC (permalink / raw)
  To: Jianchao Wang; +Cc: axboe, hch, sagi, linux-nvme, linux-kernel

On Wed, Apr 18, 2018 at 03:32:47PM +0800, Jianchao Wang wrote:
> With lockdep enabled, when trigger nvme_remove, suspicious RCU
> usage warning will be printed out.
> Fix it with adding srcu_read_lock/unlock in it.
> 
> Signed-off-by: Jianchao Wang <jianchao.w.wang@oracle.com>
> ---
>  drivers/nvme/host/nvme.h | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index 061fecf..d326c23 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -446,9 +446,14 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head);
>  static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
>  {
>  	struct nvme_ns_head *head = ns->head;
> +	int srcu_idx;
>  
> -	if (head && ns == srcu_dereference(head->current_path, &head->srcu))
> -		rcu_assign_pointer(head->current_path, NULL);
> +	if (head) {
> +		srcu_idx = srcu_read_lock(&head->srcu);
> +		if (ns == srcu_dereference(head->current_path, &head->srcu))
> +			rcu_assign_pointer(head->current_path, NULL);
> +		srcu_read_unlock(&head->srcu, srcu_idx);
> +	}
>  }
>  struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);

Nothing against this patch. This just doesn't look correct even from
before since nvme_find_path can set head->current_path right back to
this namespace that we're trying to clear.

Christoph, am I missing something here or does this need additional
checks/synchronization?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] nvme: fix the suspicious RCU usage warning in nvme_mpath_clear_current_path
@ 2018-04-18 14:45   ` Keith Busch
  0 siblings, 0 replies; 8+ messages in thread
From: Keith Busch @ 2018-04-18 14:45 UTC (permalink / raw)


On Wed, Apr 18, 2018@03:32:47PM +0800, Jianchao Wang wrote:
> With lockdep enabled, when trigger nvme_remove, suspicious RCU
> usage warning will be printed out.
> Fix it with adding srcu_read_lock/unlock in it.
> 
> Signed-off-by: Jianchao Wang <jianchao.w.wang at oracle.com>
> ---
>  drivers/nvme/host/nvme.h | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index 061fecf..d326c23 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -446,9 +446,14 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head);
>  static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
>  {
>  	struct nvme_ns_head *head = ns->head;
> +	int srcu_idx;
>  
> -	if (head && ns == srcu_dereference(head->current_path, &head->srcu))
> -		rcu_assign_pointer(head->current_path, NULL);
> +	if (head) {
> +		srcu_idx = srcu_read_lock(&head->srcu);
> +		if (ns == srcu_dereference(head->current_path, &head->srcu))
> +			rcu_assign_pointer(head->current_path, NULL);
> +		srcu_read_unlock(&head->srcu, srcu_idx);
> +	}
>  }
>  struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);

Nothing against this patch. This just doesn't look correct even from
before since nvme_find_path can set head->current_path right back to
this namespace that we're trying to clear.

Christoph, am I missing something here or does this need additional
checks/synchronization?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] nvme: fix the suspicious RCU usage warning in nvme_mpath_clear_current_path
  2018-04-18 14:45   ` Keith Busch
@ 2018-04-18 15:07     ` Christoph Hellwig
  -1 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2018-04-18 15:07 UTC (permalink / raw)
  To: Keith Busch; +Cc: Jianchao Wang, axboe, hch, sagi, linux-nvme, linux-kernel

On Wed, Apr 18, 2018 at 08:45:25AM -0600, Keith Busch wrote:
> Nothing against this patch. This just doesn't look correct even from
> before since nvme_find_path can set head->current_path right back to
> this namespace that we're trying to clear.
> 
> Christoph, am I missing something here or does this need additional
> checks/synchronization?

Yes, we should probably call it after removing the namespace from
the ns_head list, instead of right before.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] nvme: fix the suspicious RCU usage warning in nvme_mpath_clear_current_path
@ 2018-04-18 15:07     ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2018-04-18 15:07 UTC (permalink / raw)


On Wed, Apr 18, 2018@08:45:25AM -0600, Keith Busch wrote:
> Nothing against this patch. This just doesn't look correct even from
> before since nvme_find_path can set head->current_path right back to
> this namespace that we're trying to clear.
> 
> Christoph, am I missing something here or does this need additional
> checks/synchronization?

Yes, we should probably call it after removing the namespace from
the ns_head list, instead of right before.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-04-18 15:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-18  7:32 [PATCH] nvme: fix the suspicious RCU usage warning in nvme_mpath_clear_current_path Jianchao Wang
2018-04-18  7:32 ` Jianchao Wang
2018-04-18 10:19 ` Christoph Hellwig
2018-04-18 10:19   ` Christoph Hellwig
2018-04-18 14:45 ` Keith Busch
2018-04-18 14:45   ` Keith Busch
2018-04-18 15:07   ` Christoph Hellwig
2018-04-18 15:07     ` Christoph Hellwig

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.