Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6798621imu; Mon, 21 Jan 2019 16:25:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN644e0rxqQoytrPXypo7dDxxXcsTas+iqOfpS2IeTU0XbGvZ9sOX/TeCdCOdDMEL/Ed6oNK X-Received: by 2002:a63:61c1:: with SMTP id v184mr29245624pgb.54.1548116759733; Mon, 21 Jan 2019 16:25:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548116759; cv=none; d=google.com; s=arc-20160816; b=r65pTmiqhCFQh2BePcGKZi+o12+4ZmejsQxS1Z3bOEbimDi0igk3FBLrH3Otz35lUg i+DowKb26X62FyetWvaRT47v+mVmNdnhVw93qJB2S5uU644Unw/1k447B+qZbNGmk95y 2R9iB+f0vjKtfElwYxbl6TpBDyxehLSNbzO3Wc7+AN0RYks34pRNhZelLupQE/AnfuRE hXEMP5waa5EhLQ4HaVL9MDBzw8jSMFVoiUkufwFpPUf6GrIYIiAtytBa57bldxaf6k1B WtA1m8UtCFDrF8KH1hB/9CKk4R4U42w0aG7sD4EPH9w3Ztxsopo3F2hYAmC+3dLKQics D2/A== 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:reply-to:message-id :subject:cc:to:from:date; bh=3lrxTo9OkGfkjglKWReggVel4kUEMb4PYIcWEhZ/CFM=; b=DEgPK3m/V0euwX4TQbnMk3aDHGGtVFpaePoOCrzwPW6oXHYA70K17GFy66z/QAwqPG XV3boZSOXjGFqj2BfvGgteGF289FEECsQoaKy6GqX6jS3oJbS/GpaOKrqrx7uNuvNOCp jil5R7tvf/b+uF6zJK+P/HDjkWJE5ysbEkC40RQsybB2Y1/zG/mSyTuyekSvCJ5EeJle geRDi87BkDGeTEzj1mQcnX7kg8ajPZolGGnXR8x2OMTLt6uHDEjjZlmvxmQ+Gzk/cXiN 9LQ1ixJgKvcz137dxRWlWksflD2RSjuibNtZ1W6JbSru/fd6g3bghk8tqh3ha9Fl5+go UoxQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3si2150442pgo.595.2019.01.21.16.25.43; Mon, 21 Jan 2019 16:25:59 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726157AbfAVAYF (ORCPT + 99 others); Mon, 21 Jan 2019 19:24:05 -0500 Received: from mga12.intel.com ([192.55.52.136]:30337 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbfAVAYF (ORCPT ); Mon, 21 Jan 2019 19:24:05 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jan 2019 16:24:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,504,1539673200"; d="scan'208";a="120235153" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.37]) by orsmga003.jf.intel.com with ESMTP; 21 Jan 2019 16:24:03 -0800 Date: Tue, 22 Jan 2019 08:23:35 +0800 From: Wei Yang To: Dan Williams Cc: Wei Yang , Wei Yang , linux-nvdimm , Linux Kernel Mailing List Subject: Re: [PATCH] libnvdimm: Clarify nd_pfn_init() flow Message-ID: <20190122002335.GA5855@richard> Reply-To: Wei Yang References: <154785884329.2202034.3295476681016958230.stgit@dwillia2-desk3.amr.corp.intel.com> <20190121075102.GA3758@richard> <20190121205713.vai2oor3saopcja7@master> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 21, 2019 at 02:34:06PM -0800, Dan Williams wrote: >On Mon, Jan 21, 2019 at 12:57 PM Wei Yang wrote: >> >> On Mon, Jan 21, 2019 at 10:04:40AM -0800, Dan Williams wrote: >> >On Sun, Jan 20, 2019 at 11:51 PM Wei Yang wrote: >> >> On Fri, Jan 18, 2019 at 04:47:23PM -0800, Dan Williams wrote: >> >[..] >> >> Also, I have one confusion about your saying: two probes. >> >> >> >> If the two probes are: >> >> >> >> * for dax%d.%d: 1. nd_dax_probe 2. dax_pmem_probe >> >> * for pfn%d.%d: 1. nd_pfn_probe 2. nd_pmem_probe >> >> >> >> Then, if the first probe fails, the device itself would be destroyed. How the >> >> second probe do its job? >> >> >> >> > rc = nd_pfn_validate(nd_pfn, sig); >> >> > if (rc != -ENODEV) >> >> > return rc; >> > >> >Here is an example path for a device-dax instance: >> > >> > /sys/devices/platform/e820_pmem/ndbus0/region0/dax0.1/dax0.0 >> > >> >In this case the order of events is: >> > >> >1/ region0 discovers it contains a pmem namespace and registers namespace0.0 >> >2/ The pmem namespace driver calls nd_dax_probe() to check for the >> >presence of a device-dax configuration >> >3/ If present, nd_pfn_validate() returns 0 and nd_dax_probe() >> >registers the dax0.1 device (this is a libnvdimm 'personality device). >> >4/ When nd_pmem_probe() sees nd_dax_probe() return 0 it in turn fails >> >the probe of namespace0.0 with -ENXIO. All devm allocations during the >> >probe of namespace0.0 are released. >> >> I may have another opinion here. >> >> The probe return error means the device will not attach to this driver. >> But the device itself it not released. >> >> We allocate devm on one device and those memory will be released when >> the device is destroyed. If I am correct. >> >> This means at this point, pfn_sb's memory still exists in the system. >> Even finally we will release it, when namespace0.0 is destroyed. > >No, that's not the way devm works. Memory allocated by devm is >released at ->probe() failure, or after ->remove() > >See the devres_release_all() call in drivers/base/dd.c::really_probe() Ah, you are right. -- Wei Yang Help you, Help me