Linux CXL
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Ira Weiny <ira.weiny@intel.com>,
	Dan Williams <dan.j.williams@intel.com>, <nvdimm@lists.linux.dev>
Cc: Yongqiang Liu <liuyongqiang13@huawei.com>,
	Paul Cassella <cassella@hpe.com>, Ira Weiny <ira.weiny@intel.com>,
	<linux-cxl@vger.kernel.org>
Subject: Re: [PATCH 3/4] dax: Introduce alloc_dev_dax_id()
Date: Thu, 15 Jun 2023 18:22:36 -0700	[thread overview]
Message-ID: <648bb95cd38e8_142af8294c6@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <647bfd7e1ef3_4c9842941c@iweiny-mobl.notmuch>

Ira Weiny wrote:
> Dan Williams wrote:
> > The reference counting of dax_region objects is needlessly complicated,
> > has lead to confusion [1], and has hidden a bug [2]. Towards cleaning up
> > that mess introduce alloc_dev_dax_id() to minimize the holding of a
> > dax_region reference to only what dev_dax_release() needs, the
> > dax_region->ida.
> > 
> > Part of the reason for the mess was the design to dereference a
> > dax_region in all cases in free_dev_dax_id() even if the id was
> > statically assigned by the upper level dax_region driver. Remove the
> > need to call "is_static(dax_region)" by tracking whether the id is
> > dynamic directly in the dev_dax instance itself.
> > 
> > With that flag the dax_region pinning and release per dev_dax instance
> > can move to alloc_dev_dax_id() and free_dev_dax_id() respectively.
> > 
> > A follow-on cleanup address the unnecessary references in the dax_region
> > setup and drivers.
> > 
> > Fixes: 0f3da14a4f05 ("device-dax: introduce 'seed' devices")
> > Link: http://lore.kernel.org/r/20221203095858.612027-1-liuyongqiang13@huawei.com [1]
> > Link: http://lore.kernel.org/r/3cf0890b-4eb0-e70e-cd9c-2ecc3d496263@hpe.com [2]
> > Reported-by: Yongqiang Liu <liuyongqiang13@huawei.com>
> > Reported-by: Paul Cassella <cassella@hpe.com>
> > Reported-by: Ira Weiny <ira.weiny@intel.com>
> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
[..]
> > @@ -1326,6 +1340,7 @@ struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data)
> >  	if (!dev_dax)
> >  		return ERR_PTR(-ENOMEM);
> >  
> > +	dev_dax->region = dax_region;
> 
> Overall I like that this reference is not needed to be carried and/or
> managed by the callers.
> 
> However, here you are referencing the dax_region from the dev_dax in an
> unrelated place to where the reference matters (in id management).
> 
> Could alloc_dev_dax_id() change to:
> 
> static int alloc_dev_dax_id(struct dev_dax *dev_dax, struct dax_region *dax_region)
> {
> ...
> }
> 
> Then make this assignment next to where the kref is taken so it is clear
> that this is the only user of the reference?
> 
> I did not pick up on the fact this reference was only needed to free the
> id at all in reviewing the code and I think this would make it even more
> clear.

I hesitate only for symmetry reasons. I.e. that there are many interfaces in
this file, in addition to free_dev_dax_id(), where @dax_region is
implicitly retrieved from the @dev_dax.

  reply	other threads:[~2023-06-16  1:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-03  6:13 [PATCH 0/4] dax: Fix use after free and other cleanups Dan Williams
2023-06-03  6:13 ` [PATCH 1/4] dax: Fix dax_mapping_release() use after free Dan Williams
2023-06-04  2:40   ` Ira Weiny
2023-06-05 20:45   ` Fan Ni
2023-06-15 17:33   ` Dave Jiang
2023-06-03  6:13 ` [PATCH 2/4] dax: Use device_unregister() in unregister_dax_mapping() Dan Williams
2023-06-04  2:41   ` Ira Weiny
2023-06-05 20:46   ` Fan Ni
2023-06-15 17:34   ` Dave Jiang
2023-06-03  6:14 ` [PATCH 3/4] dax: Introduce alloc_dev_dax_id() Dan Williams
2023-06-04  2:57   ` Ira Weiny
2023-06-16  1:22     ` Dan Williams [this message]
2023-06-16 22:11       ` Ira Weiny
2023-06-03  6:14 ` [PATCH 4/4] dax: Cleanup extra dax_region references Dan Williams
2023-06-04  2:58   ` Ira Weiny
2023-06-06 17:46   ` Fan Ni
2023-06-06 20:42     ` Ira Weiny
2023-06-15 17:45   ` Dave Jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=648bb95cd38e8_142af8294c6@dwillia2-xfh.jf.intel.com.notmuch \
    --to=dan.j.williams@intel.com \
    --cc=cassella@hpe.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=liuyongqiang13@huawei.com \
    --cc=nvdimm@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox