Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4365277imm; Mon, 14 May 2018 06:36:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoJD9pmylIWQnpFc3Ix/+fslmahwDDPkKDBS5Kk2m7V6xIYyR80cUgrkiwLCQOajr7Ofp8/ X-Received: by 2002:a63:6706:: with SMTP id b6-v6mr8586451pgc.214.1526304962525; Mon, 14 May 2018 06:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526304962; cv=none; d=google.com; s=arc-20160816; b=nyXA0bk880+qZt31nEbrAfMyiQzV3X3Pcj5T0I+JmU54fa0Knlnrea7EBpFhKghdDj Dg+etF38hf7tXSQ2TU0mMQRW8ft6KF2H+eFILFjEouNSPmaYe68kE4hZKCCZegNkEZ1e G+ivuaCQnYOs6HVprI63uhjHVwzP7KIyR83eI5CpznGsEm626vua5mLSO3V4SAw7FXjz 4Ctt7MtGdSViE1alBtrDebFZgD4nMM+P0m9mLV0Bld8d2beIGcUnK7Ln8zwfJ3kMcBG7 7qVfj+FvT232o4kALzEzqnS/Cn+wGd/OP2v3XjO1QOrNbXP5r3RjL1nds1UB20fmjXQU uBiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=kh01zEkmtrtBdi6AyHtNkR5d+mKMZZJQ0wuFE8ATI1U=; b=Did2Q1nAGSxPbco8VsSUp+Etm20ukWxUmNaRboe0ZXN8W2IiUVgaOp08DrRltzDlrz GQC/wc99Mf6rYVa3euZ7v7d3KdCWXmwBrpL/s92dNYV35+GOIbDjgsLJ3bL/f7HmwuaP Adl1he/iTUCMHmmZeTLZzt8trXB4iByuCshC0SRbj+7dzWHqowK1kSWLBtftUSxOgZSE 4HaUkfLJcUDcvQbO6fY1wrtkJ0yIaMHVsehqE28SeKBEFbUcr2xIUU/4We8CNJAtxH12 I75qZReKIXQ8y14ltgoVT/PwSiFkPeqVT+Ca8H3z9faLjbWFWWdWOZo/SmAor68Y6cp8 /I4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=NfRdDTaP; 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 u6-v6si8618332pld.74.2018.05.14.06.35.46; Mon, 14 May 2018 06:36:02 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=NfRdDTaP; 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 S1753657AbeENNeI (ORCPT + 99 others); Mon, 14 May 2018 09:34:08 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57128 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753369AbeENNeH (ORCPT ); Mon, 14 May 2018 09:34:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kh01zEkmtrtBdi6AyHtNkR5d+mKMZZJQ0wuFE8ATI1U=; b=NfRdDTaP21Qrd7iilxT/OfQNN a18OtHdw65nlTxMiJ0VzGI+vgXt0Y6lfieU+g5c1x/54h/fF79LSx/4wPu1WuQTRegni2lcYIWmxq voePtAnZHZKf+tpp2We90BAZUGGbIs88mYxMbF46t53aduFlVpuLNqswKlTh4cvLK6X6/xQOaZw/7 sgYuP+uBU81A5NnkvXQluYAZQXzOFS1KrM30k4CfhTVNzgNtnUv8s+aCdhHK5GQ54jlstDdw0nlfn d9tY5knzhRYaUgQ/2664r0u59/jz0FLQJbs11StPo9k8Ao3uAvY4wXmwhLkN5HoHmqbed9PqBRZJV L8+6Sc96w==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fIDc4-0005Qt-3i; Mon, 14 May 2018 13:34:04 +0000 Date: Mon, 14 May 2018 06:34:03 -0700 From: Christoph Hellwig To: "Paul E. McKenney" Cc: Christoph Hellwig , Johannes Thumshirn , Keith Busch , Sagi Grimberg , Linux Kernel Mailinglist , Linux NVMe Mailinglist , Hannes Reinecke , Christoph Hellwig Subject: Re: [PATCH] nvme: fix lockdep warning in nvme_mpath_clear_current_path Message-ID: <20180514133403.GA14243@infradead.org> References: <20180514121312.13624-1-jthumshirn@suse.de> <20180514124230.GA654@infradead.org> <20180514133105.GU26088@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180514133105.GU26088@linux.vnet.ibm.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 14, 2018 at 06:31:05AM -0700, Paul E. McKenney wrote: > > > + if (head && > > > + ns == rcu_dereference_protected(head->current_path, > > > + lockdep_is_held(&ns->ctrl->subsys->lock))) > > > rcu_assign_pointer(head->current_path, NULL); > > > } > > > struct nvme_ns *nvme_find_path(struct nvme_ns_head *head); > > > > We don't really dereference it at all in fact, but just check the > > pointers for equality. I wonder if there is a better way to do this, > > as my ANA patches add a caller without the lock (and withou SRU > > protection either now that I think of it) - for a pure pointer compare > > we really should not need any sort of protection. > > If you are just looking at the value of an RCU-protected pointer, then > using rcu_access_pointer() will cause RCU to just read out the value > and otherwise keeps its mouth shut. That is exactly the function I was looking for. And given that srcu and rcu use the same annotations I should have through of being able to use it of course. As you see above we only use the return value to do a comparison, so we should be perfectly fine. Johannes, can you respin the patch to use rcu_access_pointer?