Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4317542imm; Mon, 14 May 2018 05:59:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoiwSSltyGS5OnRbjU5q/wadq+RswQC+xAOqB73XMDBD80/Q5B/uU93MvrrE25pjuL49cGs X-Received: by 2002:a62:d717:: with SMTP id b23-v6mr10356403pfh.5.1526302762104; Mon, 14 May 2018 05:59:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526302762; cv=none; d=google.com; s=arc-20160816; b=dnvfAYG65CZ2IJ4FO09C+lyAZIfE4ISpcUeoTnAYO+emWS9YVWByv5P/liJLAXrEUU L9CpUCcRqC/3nUBynCNwpy7GcIY2LYU8OjmT6gw/dsyoKiC6j2M6s44TMrgdo+k73GWA Vy0TtnYLad+kibSGPdDWLBm2mjiLiYsRIUC3cooJt73e8nJ+Rlyi67GfwdXIm511LgFp DdeqEwfygsJDfrpnqGUczaeFLCtnSDOFwb7JD90YEycGg6xfvGZ4I5GEb6k7vG7UQvIU SNQ2wiKBffIqd+PefDp3hERB+pDo+ndwXV7QqHjlFbeky6abNgA5BHljOIUhiVTBnXKR K2Lw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=xKovMKAQ7l3XzJmzMv3ePfXG/KuRnhgO5eOlp91NFf4=; b=PBZFlTCFcHnCO92rc+CD0KcgG3StLaJat1YIrKjx9FRC8MdYgppRkDJ3Fs5CkTiyU9 f6l3ZLwedVO2XP+Ns9Uct/65rClle8yWcFnLwhnM7T7xHlYk9Auv2coVh/N+LSloXp6i zeSdTkwNWz/2CVgKjIIXC9HSxS3CVQJPaOKJr9+fjLqugyQKVqIjUB+uDMKH1kV8hZtK j/+H0yjuKTBMId4knhNZYXWJVdGxoWoVh2vKqjsO8z9JJX420lS9m4gMU4qllIO97CX0 iuyonij1Tl18g6LK1TJ0mp6efRUksPeRzHG0plwmX5LFVVLssx8QqkW21+MXEiX1L7Mr iCiw== 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 e98-v6si2147478plb.279.2018.05.14.05.59.07; Mon, 14 May 2018 05:59:22 -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 S1753368AbeENM5a (ORCPT + 99 others); Mon, 14 May 2018 08:57:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:49400 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752897AbeENM53 (ORCPT ); Mon, 14 May 2018 08:57:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CAC65AC8D; Mon, 14 May 2018 12:57:27 +0000 (UTC) Date: Mon, 14 May 2018 14:57:25 +0200 From: Johannes Thumshirn To: Christoph Hellwig Cc: Keith Busch , Sagi Grimberg , Linux Kernel Mailinglist , Linux NVMe Mailinglist , Hannes Reinecke , Christoph Hellwig , paulmck@linux.vnet.ibm.com Subject: Re: [PATCH] nvme: fix lockdep warning in nvme_mpath_clear_current_path Message-ID: <20180514125725.uobtf2nf4corisea@linux-x5ow.site> References: <20180514121312.13624-1-jthumshirn@suse.de> <20180514124230.GA654@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180514124230.GA654@infradead.org> User-Agent: NeoMutt/20170912 (1.9.0) 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 05:42:30AM -0700, Christoph Hellwig wrote: > > extern unsigned int nvme_io_timeout; > > #define NVME_IO_TIMEOUT (nvme_io_timeout * HZ) > > @@ -454,7 +455,9 @@ 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_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. Uff maybe, but are you sure a comparison of two pointer is always atomic (on all architectures)? Paul, can you shed some light on us mere mortal, whether the above rcu_dereference_protected() is needed or if a simple ns == head->current_path is sufficient. Thanks, Johannes -- Johannes Thumshirn Storage jthumshirn@suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850