Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6725179imu; Mon, 21 Jan 2019 14:36:00 -0800 (PST) X-Google-Smtp-Source: ALg8bN6voJh79FBd6tMyXjfsg2uSFn3zS/gH1y/4Z1xI2dSCEvNNXqz2gXOCIBUcTlinkIg0drVD X-Received: by 2002:a17:902:bb05:: with SMTP id l5mr32344352pls.230.1548110160473; Mon, 21 Jan 2019 14:36:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548110160; cv=none; d=google.com; s=arc-20160816; b=D/Ec5A+AO3ns28/69ldh8Y6kDrbqpy7nr0LuRSJzjNR/a9ixmviO7SUJI7V14MJDHw DTiARnF7bwqPty9QZJVL0LXpokIpbo8jzcIlbZ9Yy8IA3BZx9efI3LcgqTvJ7+gRv0mC vcOiAsYLxoD8Np0q3KdCKNssYiVCctAe11ZHG//LbJg6oStffTzmH5xb9HHR77UcSAtF Tg2UzteZKX7JgZlXcxc/uNg2+YE2yw2qEd/P3Si+ccePSYZixO41acMKjMixmeTe6XoR VqB206lt+R8GaASgeDDYe3DI8z4Au9tCrGcnB/HRWwpXeCpVnAr4xaB24igc9zXLuS9L x8Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rL8USB9BBkpFKFp8oWAAG6gZe7QWP4SiGavMpn/OiQU=; b=uo0TKoE4IAjDz40fvvU/93uxrBHjGY1tISkJsNxfe03uqXORKO6L+3/kk65HxHBNzo rDczOzvnzJAY7tgeTbm8LD6dfIiZomYKpOP/Gdiz3cnb/+PQmf0YytFJJwIvvHZUeVk7 5auM0nBTBmQhrUo9/oIwX7dCKtb8g1Qrf1S/+rA1hb1EQZ87SQLxzUpvmenjsXfYtu46 TAQhj7G0ugqKGF6aByYDvTKguCzjtnGUN8FyKWQA49jqabUvExKA437FmDgABlS759XB k+6MlfEPj6jtLyzDRXqy0O+BzczAt6oWzCkemxT5UhmK5NsGV9fheQLMbU4jHPPJ+aic 2xvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="VSrcaV/J"; 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 33si14294763plu.169.2019.01.21.14.35.41; Mon, 21 Jan 2019 14:36:00 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="VSrcaV/J"; 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 S1727869AbfAUWeT (ORCPT + 99 others); Mon, 21 Jan 2019 17:34:19 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:36437 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726290AbfAUWeT (ORCPT ); Mon, 21 Jan 2019 17:34:19 -0500 Received: by mail-ot1-f66.google.com with SMTP id k98so21950224otk.3 for ; Mon, 21 Jan 2019 14:34:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rL8USB9BBkpFKFp8oWAAG6gZe7QWP4SiGavMpn/OiQU=; b=VSrcaV/Jon7gPbTW9jg4tRNqMSUaZT6a1ClNX1n42YvPapOBmk8TGsvlMzLKw2k0I8 2h4guMZUY4+XAlPhGAyFfJB/uhAdBiv+vNaSRFG4NJgQ4SNRhnJbhNUP8n7rtItjsX+9 kP00IQH49Gdm8MElmoCk3/5SIrsADUB/Dsv5KU1YLKgy6oPK4qPASqsO4i1UH2O4K/9g WwpIuCIkb/Ly9foHnUt3t51OPm0idJyXmrHX47FEMyYLz6oGyP4N9uSzJIqdPk7hsdiI uYcDqqAexq4yXdN7NTI0lbHORH1b/1eeAsDbXQQE3o/LNZZH6AvaBZ5ccCBdZhKAhEXU uqVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rL8USB9BBkpFKFp8oWAAG6gZe7QWP4SiGavMpn/OiQU=; b=hDmMOwDmMbOC8Jz/eS/UqxSVsnM2ymFvl/qwBzx441xpDNkO8C1mZJdT6aa8O1jr6A dah0CXaoraYPchCRqQ5SA/23kjw/nvA18x0TQFOVvChr4aks9+ERglu3+mWMvtFRWcyh e0Kt6V1mPSzbMBwiMPHNWHvWWJUOWZkLbREQoNFcfDeieeIcqhkr68HwJYU+HuHfFfLQ d2YsnaBoI+drdjHcOoNTafg+5SxZKYLv2/zOe+f+5069fm3QhvwgfMS43XDU+V03zW+V 2ZLb/by4c2LEezY8BLs9oO9yK9xgukcMrtynllaDVcy3Y2T4I5xvT1eYrPnX97tyG2da fC0w== X-Gm-Message-State: AJcUukd9prRGkQ8QikXfEjpbXdPQtDCiO/4lRKASVpm7ZPXdb1uXkDfe AaJztQgwLOpbyrohN7DNFVb6TCzmIWS9dg6dFnItWg== X-Received: by 2002:a9d:6ac2:: with SMTP id m2mr19917774otq.353.1548110058526; Mon, 21 Jan 2019 14:34:18 -0800 (PST) MIME-Version: 1.0 References: <154785884329.2202034.3295476681016958230.stgit@dwillia2-desk3.amr.corp.intel.com> <20190121075102.GA3758@richard> <20190121205713.vai2oor3saopcja7@master> In-Reply-To: <20190121205713.vai2oor3saopcja7@master> From: Dan Williams Date: Mon, 21 Jan 2019 14:34:06 -0800 Message-ID: Subject: Re: [PATCH] libnvdimm: Clarify nd_pfn_init() flow To: Wei Yang Cc: Wei Yang , linux-nvdimm , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" 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 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()