Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3182260imm; Thu, 17 May 2018 04:53:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqAy/vF+/RHPSX7Ib5x63qhplUY+VScgzGTMrl43iapt/Rv+uiwb9s2aSAJlrJV2onOdx8F X-Received: by 2002:a17:902:5481:: with SMTP id e1-v6mr4858676pli.137.1526558013807; Thu, 17 May 2018 04:53:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526558013; cv=none; d=google.com; s=arc-20160816; b=iSIku8SN2KdaThcTY8db/daBx4QpmFE9AZEl3MDhUd1mwajtdNHyNLEMBWKIEHevAk PpmvxxSzyz9gnfCzHariADRxuf/3WiQ860We86bOenPBS+pD8bT0M+aPjxWKGpxTTbmQ 0LCbp+m5SPlgqvzlfQq1fFzs98Jmovifxjdum3WCkkL5VBOka61z0tXwGhZLM5SmQZPA KMQPlpfmej+2Tl9zL5ddLvySwN2Rj9T1RRf0B6j+WWnBezQ/IZhHMtF6N+FAHenODHe8 AIUoOxXAbrH2wNm6SoZm+cRdQM6BCqLQNkJGUNSj0VMHmhQmvaJakRqg4W1BH2sTHICR 4rsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=iHI96nGWAVP6QvcEgnh93wNWVkRaNpcH8HL6+vy4M4M=; b=EiGvCVl4Xl0sK2ElCe91i+uBQual0fZPPfGrGSRCi2YLkfI2Kn48CXHBYxjPKEXgf+ hEJkBcfeOzkUr7DjlOPKEyc0vMUkfchJN6VTkxDqyFl2SnNaVzs7TOQYzMbwm7PbHY2m /YmnxRyQPyJODHTbTzQC4S+UlJlIhVURAuCnQ/d7fWkeHLZJpfqbwAfgGJjv8nwZ2rXw mUMj5a0CnnY4w3lbJgtyTyjbjS9VMSXaNRYxG3QQB2KYx1yS3Q+3hujByA9daAZRLFhn AoEVoF9zaDWoebWGDqlpynkT5eESFCQWuw4SyuVLmVfi/sOqIpAyBFc4gLBNPjbrReiM Hwdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65-v6si5081882pfo.229.2018.05.17.04.53.19; Thu, 17 May 2018 04:53:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752030AbeEQLw4 (ORCPT + 99 others); Thu, 17 May 2018 07:52:56 -0400 Received: from mx2.suse.de ([195.135.220.15]:56050 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751868AbeEQLwy (ORCPT ); Thu, 17 May 2018 07:52:54 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6893CAE26; Thu, 17 May 2018 11:52:53 +0000 (UTC) From: Johannes Thumshirn To: Keith Busch Cc: Sagi Grimberg , Christoph Hellwig , Linux NVMe Mailinglist , Linux Kernel Mailinglist , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH v3] nvme: fix lockdep warning in nvme_mpath_clear_current_path Date: Thu, 17 May 2018 13:52:50 +0200 Message-Id: <20180517115250.10027-1-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When running blktest's nvme/005 with a lockdep enabled kernel the test case fails due to the following lockdep splat in dmesg: ============================= WARNING: suspicious RCU usage 4.17.0-rc5 #881 Not tainted ----------------------------- drivers/nvme/host/nvme.h:457 suspicious rcu_dereference_check() usage! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 3 locks held by kworker/u32:5/1102: #0: (ptrval) ((wq_completion)"nvme-wq"){+.+.}, at: process_one_work+0x152/0x5c0 #1: (ptrval) ((work_completion)(&ctrl->scan_work)){+.+.}, at: process_one_work+0x152/0x5c0 #2: (ptrval) (&subsys->lock#2){+.+.}, at: nvme_ns_remove+0x43/0x1c0 [nvme_core] The only caller of nvme_mpath_clear_current_path() is nvme_ns_remove() which holds the subsys lock so it's likely a false positive, but when using rcu_access_pointer(), we're telling rcu and lockdep that we're only after the pointer falue. Fixes: 32acab3181c7 ("nvme: implement multipath access to nvme subsystems") Signed-off-by: Johannes Thumshirn Suggested-by: Paul E. McKenney Reviewed-by: Christoph Hellwig --- Changes to v2: - Added Christoph's R-b - Removed most of the lockdep splat from commit log Changes to v1: - Change rcu_dereference_protected() to rc_access_pointer() (Paul) --- drivers/nvme/host/nvme.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 17d2f7cf3fed..af2bb6bc984d 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -22,6 +22,7 @@ #include #include #include +#include extern unsigned int nvme_io_timeout; #define NVME_IO_TIMEOUT (nvme_io_timeout * HZ) @@ -454,7 +455,7 @@ static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns) { struct nvme_ns_head *head = ns->head; - if (head && ns == srcu_dereference(head->current_path, &head->srcu)) + if (head && ns == rcu_access_pointer(head->current_path)) rcu_assign_pointer(head->current_path, NULL); } struct nvme_ns *nvme_find_path(struct nvme_ns_head *head); -- 2.16.3