linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Pavel Tatashin <pasha.tatashin@soleen.com>,
	Brice Goglin <Brice.Goglin@inria.fr>,
	Dave Jiang <dave.jiang@intel.com>,
	Ira Weiny <ira.weiny@intel.com>, Jia He <justin.he@arm.com>,
	Joao Martins <joao.m.martins@oracle.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Linux MM <linux-mm@kvack.org>,
	linux-nvdimm <linux-nvdimm@lists.01.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 01/17] device-dax: make pgmap optional for instance creation
Date: Thu, 1 Oct 2020 09:54:13 -0700	[thread overview]
Message-ID: <CAPcyv4io6a7qaX+oa8uL9C0nc9J9UMx0CfC5E1DYdhSPvYVeOw@mail.gmail.com> (raw)
In-Reply-To: <e3b7c947-c221-8be7-41ae-aed2f481d640@redhat.com>

On Thu, Oct 1, 2020 at 1:41 AM David Hildenbrand <david@redhat.com> wrote:
>
> On 25.09.20 21:11, Dan Williams wrote:
> > The passed in dev_pagemap is only required in the pmem case as the
> > libnvdimm core may have reserved a vmem_altmap for dev_memremap_pages() to
> > place the memmap in pmem directly.  In the hmem case there is no agent
> > reserving an altmap so it can all be handled by a core internal default.
> >
> > Pass the resource range via a new @range property of 'struct
> > dev_dax_data'.
> >
> > Link: https://lkml.kernel.org/r/159643099958.4062302.10379230791041872886.stgit@dwillia2-desk3.amr.corp.intel.com
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Vishal Verma <vishal.l.verma@intel.com>
> > Cc: Dave Hansen <dave.hansen@linux.intel.com>
> > Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
> > Cc: Brice Goglin <Brice.Goglin@inria.fr>
> > Cc: Dave Jiang <dave.jiang@intel.com>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Ira Weiny <ira.weiny@intel.com>
> > Cc: Jia He <justin.he@arm.com>
> > Cc: Joao Martins <joao.m.martins@oracle.com>
> > Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> > ---
> >  drivers/dax/bus.c              |   29 +++++++++++++++--------------
> >  drivers/dax/bus.h              |    2 ++
> >  drivers/dax/dax-private.h      |    9 ++++++++-
> >  drivers/dax/device.c           |   28 +++++++++++++++++++---------
> >  drivers/dax/hmem/hmem.c        |    8 ++++----
> >  drivers/dax/kmem.c             |   12 ++++++------
> >  drivers/dax/pmem/core.c        |    4 ++++
> >  tools/testing/nvdimm/dax-dev.c |    8 ++++----
> >  8 files changed, 62 insertions(+), 38 deletions(-)
> >
> > diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
> > index dffa4655e128..96bd64ba95a5 100644
> > --- a/drivers/dax/bus.c
> > +++ b/drivers/dax/bus.c
> > @@ -271,7 +271,7 @@ static ssize_t size_show(struct device *dev,
> >               struct device_attribute *attr, char *buf)
> >  {
> >       struct dev_dax *dev_dax = to_dev_dax(dev);
> > -     unsigned long long size = resource_size(&dev_dax->region->res);
> > +     unsigned long long size = range_len(&dev_dax->range);
> >
> >       return sprintf(buf, "%llu\n", size);
> >  }
> > @@ -293,19 +293,12 @@ static ssize_t target_node_show(struct device *dev,
> >  }
> >  static DEVICE_ATTR_RO(target_node);
> >
> > -static unsigned long long dev_dax_resource(struct dev_dax *dev_dax)
> > -{
> > -     struct dax_region *dax_region = dev_dax->region;
> > -
> > -     return dax_region->res.start;
> > -}
> > -
> >  static ssize_t resource_show(struct device *dev,
> >               struct device_attribute *attr, char *buf)
> >  {
> >       struct dev_dax *dev_dax = to_dev_dax(dev);
> >
> > -     return sprintf(buf, "%#llx\n", dev_dax_resource(dev_dax));
> > +     return sprintf(buf, "%#llx\n", dev_dax->range.start);
> >  }
> >  static DEVICE_ATTR(resource, 0400, resource_show, NULL);
> >
> > @@ -376,6 +369,7 @@ static void dev_dax_release(struct device *dev)
> >
> >       dax_region_put(dax_region);
> >       put_dax(dax_dev);
> > +     kfree(dev_dax->pgmap);
> >       kfree(dev_dax);
> >  }
> >
> > @@ -412,7 +406,12 @@ struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data)
> >       if (!dev_dax)
> >               return ERR_PTR(-ENOMEM);
> >
> > -     memcpy(&dev_dax->pgmap, data->pgmap, sizeof(struct dev_pagemap));
> > +     if (data->pgmap) {
> > +             dev_dax->pgmap = kmemdup(data->pgmap,
> > +                             sizeof(struct dev_pagemap), GFP_KERNEL);
> > +             if (!dev_dax->pgmap)
> > +                     goto err_pgmap;
> > +     }
> >
> >       /*
> >        * No 'host' or dax_operations since there is no access to this
> > @@ -421,18 +420,19 @@ struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data)
> >       dax_dev = alloc_dax(dev_dax, NULL, NULL, DAXDEV_F_SYNC);
> >       if (IS_ERR(dax_dev)) {
> >               rc = PTR_ERR(dax_dev);
> > -             goto err;
> > +             goto err_alloc_dax;
> >       }
> >
> >       /* a device_dax instance is dead while the driver is not attached */
> >       kill_dax(dax_dev);
> >
> > -     /* from here on we're committed to teardown via dax_dev_release() */
> > +     /* from here on we're committed to teardown via dev_dax_release() */
> >       dev = &dev_dax->dev;
> >       device_initialize(dev);
> >
> >       dev_dax->dax_dev = dax_dev;
> >       dev_dax->region = dax_region;
> > +     dev_dax->range = data->range;
> >       dev_dax->target_node = dax_region->target_node;
> >       kref_get(&dax_region->kref);
> >
> > @@ -458,8 +458,9 @@ struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data)
> >               return ERR_PTR(rc);
> >
> >       return dev_dax;
> > -
> > - err:
> > +err_alloc_dax:
> > +     kfree(dev_dax->pgmap);
> > +err_pgmap:
> >       kfree(dev_dax);
> >
> >       return ERR_PTR(rc);
> > diff --git a/drivers/dax/bus.h b/drivers/dax/bus.h
> > index 299c2e7fac09..4aeb36da83a4 100644
> > --- a/drivers/dax/bus.h
> > +++ b/drivers/dax/bus.h
> > @@ -3,6 +3,7 @@
> >  #ifndef __DAX_BUS_H__
> >  #define __DAX_BUS_H__
> >  #include <linux/device.h>
> > +#include <linux/range.h>
> >
> >  struct dev_dax;
> >  struct resource;
> > @@ -21,6 +22,7 @@ struct dev_dax_data {
> >       struct dax_region *dax_region;
> >       struct dev_pagemap *pgmap;
> >       enum dev_dax_subsys subsys;
> > +     struct range range;
> >       int id;
> >  };
> >
> > diff --git a/drivers/dax/dax-private.h b/drivers/dax/dax-private.h
> > index 8a4c40ccd2ef..6779f683671d 100644
> > --- a/drivers/dax/dax-private.h
> > +++ b/drivers/dax/dax-private.h
> > @@ -41,6 +41,7 @@ struct dax_region {
> >   * @target_node: effective numa node if dev_dax memory range is onlined
> >   * @dev - device core
> >   * @pgmap - pgmap for memmap setup / lifetime (driver owned)
> > + * @range: resource range for the instance
> >   * @dax_mem_res: physical address range of hotadded DAX memory
> >   * @dax_mem_name: name for hotadded DAX memory via add_memory_driver_managed()
> >   */
> > @@ -49,10 +50,16 @@ struct dev_dax {
> >       struct dax_device *dax_dev;
> >       int target_node;
> >       struct device dev;
> > -     struct dev_pagemap pgmap;
> > +     struct dev_pagemap *pgmap;
> > +     struct range range;
> >       struct resource *dax_kmem_res;
> >  };
> >
> > +static inline u64 range_len(struct range *range)
> > +{
> > +     return range->end - range->start + 1;
> > +}
>
> include/linux/range.h seems to have this function - why is this here needed?

It's there because I add it later in this series. I waited until
"mm/memremap_pages: convert to 'struct range'" to make it global as
that's the first kernel-wide visible usage of it.

  reply	other threads:[~2020-10-01 16:54 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25 19:11 [PATCH v5 00/17] device-dax: support sub-dividing soft-reserved ranges Dan Williams
2020-09-25 19:11 ` [PATCH v5 01/17] device-dax: make pgmap optional for instance creation Dan Williams
2020-10-01  8:41   ` David Hildenbrand
2020-10-01 16:54     ` Dan Williams [this message]
2020-10-01 17:39       ` David Hildenbrand
2020-10-01 19:12         ` Dan Williams
2020-09-25 19:11 ` [PATCH v5 02/17] device-dax/kmem: introduce dax_kmem_range() Dan Williams
2020-09-30 16:14   ` David Hildenbrand
2020-09-25 19:11 ` [PATCH v5 03/17] device-dax/kmem: move resource name tracking to drvdata Dan Williams
2020-09-30 16:19   ` David Hildenbrand
2020-09-25 19:12 ` [PATCH v5 04/17] device-dax/kmem: replace release_resource() with release_mem_region() Dan Williams
2020-09-30 16:23   ` David Hildenbrand
2020-09-30 17:28     ` Dan Williams
2020-09-25 19:12 ` [PATCH v5 05/17] device-dax: add an allocation interface for device-dax instances Dan Williams
2020-09-25 19:12 ` [PATCH v5 06/17] device-dax: introduce 'struct dev_dax' typed-driver operations Dan Williams
2020-09-25 19:12 ` [PATCH v5 07/17] device-dax: introduce 'seed' devices Dan Williams
2020-09-25 19:12 ` [PATCH v5 08/17] drivers/base: make device_find_child_by_name() compatible with sysfs inputs Dan Williams
2020-09-25 19:12 ` [PATCH v5 09/17] device-dax: add resize support Dan Williams
2020-09-25 19:12 ` [PATCH v5 10/17] mm/memremap_pages: convert to 'struct range' Dan Williams
2020-09-28 19:12   ` boris.ostrovsky
2020-09-25 19:12 ` [PATCH v5 11/17] mm/memremap_pages: support multiple ranges per invocation Dan Williams
2020-09-25 19:12 ` [PATCH v5 12/17] device-dax: add dis-contiguous resource support Dan Williams
2020-09-25 19:12 ` [PATCH v5 13/17] device-dax: introduce 'mapping' devices Dan Williams
2020-09-25 19:12 ` [PATCH v5 14/17] device-dax: make align a per-device property Dan Williams
2020-09-25 19:13 ` [PATCH v5 16/17] dax/hmem: introduce dax_hmem.region_idle parameter Dan Williams
2020-09-25 19:13 ` [PATCH v5 17/17] device-dax: add a range mapping allocation attribute Dan Williams
2020-09-25 20:51 ` [PATCH v5 00/17] device-dax: support sub-dividing soft-reserved ranges Joao Martins
2020-09-25 21:01   ` Dan Williams
2020-09-25 21:05     ` Joao Martins
     [not found] ` <160106118486.30709.13012322227204800596.stgit@dwillia2-desk3.amr.corp.intel.com>
2020-09-26  2:22   ` [PATCH v5 15/17] device-dax: add an 'align' attribute Andrew Morton
2020-09-26  3:31     ` Dan Williams

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=CAPcyv4io6a7qaX+oa8uL9C0nc9J9UMx0CfC5E1DYdhSPvYVeOw@mail.gmail.com \
    --to=dan.j.williams@intel.com \
    --cc=Brice.Goglin@inria.fr \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=dave.jiang@intel.com \
    --cc=david@redhat.com \
    --cc=ira.weiny@intel.com \
    --cc=joao.m.martins@oracle.com \
    --cc=justin.he@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=vishal.l.verma@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).