From: Johannes Thumshirn <jthumshirn@suse.de>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org
Subject: Re: [PATCH 1/8] dax: add region-available-size attribute
Date: Wed, 14 Dec 2016 15:38:02 +0100 [thread overview]
Message-ID: <20161214143802.GD6279@linux-x5ow.site> (raw)
In-Reply-To: <148143771052.10950.7622110904173815243.stgit@dwillia2-desk3.amr.corp.intel.com>
Hi Dan,
On Sat, Dec 10, 2016 at 10:28:30PM -0800, Dan Williams wrote:
> In preparation for a facility that enables dax regions to be
> sub-divided, introduce a 'dax/available_size' attribute. This attribute
> appears under the parent device that registered the device-dax region,
> and it assumes that the device-dax-core owns the driver-data for that
> device.
>
> 'dax/available_size' adjusts dynamically as dax-device instances are
> registered and unregistered.
>
> As a side effect of using __request_region() to reserve capacity from
> the dax_region we now track pointers to those returned resources rather
> than duplicating the passed in resource array.
>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
[...]
> +static const struct attribute_group *dax_region_attribute_groups[] = {
> + &dax_region_attribute_group,
> + NULL,
> };
>
> static struct inode *dax_alloc_inode(struct super_block *sb)
> @@ -200,12 +251,27 @@ void dax_region_put(struct dax_region *dax_region)
> }
> EXPORT_SYMBOL_GPL(dax_region_put);
>
> +
Stray extra newline?
[...]
> struct dax_region *alloc_dax_region(struct device *parent, int region_id,
> struct resource *res, unsigned int align, void *addr,
> unsigned long pfn_flags)
> {
> struct dax_region *dax_region;
>
> + if (dev_get_drvdata(parent)) {
> + dev_WARN(parent, "dax core found drvdata already in use\n");
> + return NULL;
> + }
> +
My first thought was, it might be interesting to see who already claimed
the drvdata. Then I figured, how are multiple sub-regions of a dax-device
supposed to work? What am I missing here?
> if (!IS_ALIGNED(res->start, align)
> || !IS_ALIGNED(resource_size(res), align))
> return NULL;
> @@ -213,16 +279,26 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id,
> dax_region = kzalloc(sizeof(*dax_region), GFP_KERNEL);
> if (!dax_region)
> return NULL;
> -
> - memcpy(&dax_region->res, res, sizeof(*res));
> + dev_set_drvdata(parent, dax_region);
> + dax_region->res.name = dev_name(parent);
> + dax_region->res.start = res->start;
> + dax_region->res.end = res->end;
> dax_region->pfn_flags = pfn_flags;
> + mutex_init(&dax_region->lock);
> kref_init(&dax_region->kref);
> dax_region->id = region_id;
> ida_init(&dax_region->ida);
> dax_region->align = align;
> dax_region->dev = parent;
> dax_region->base = addr;
> + if (sysfs_create_groups(&parent->kobj, dax_region_attribute_groups)) {
> + kfree(dax_region);
> + return NULL;;
> + }
>
> + kref_get(&dax_region->kref);
> + if (devm_add_action_or_reset(parent, dax_region_unregister, dax_region))
> + return NULL;
> return dax_region;
> }
> EXPORT_SYMBOL_GPL(alloc_dax_region);
[...]
> @@ -568,28 +654,42 @@ struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region,
> struct cdev *cdev;
> dev_t dev_t;
>
> - dax_dev = kzalloc(sizeof(*dax_dev) + sizeof(*res) * count, GFP_KERNEL);
> + dax_dev = kzalloc(sizeof(*dax_dev), GFP_KERNEL);
> if (!dax_dev)
> return ERR_PTR(-ENOMEM);
>
> + dax_dev->res = kzalloc(sizeof(res) * count, GFP_KERNEL);
dax_dev->res = kcalloc(sizeof(res), count, GFP_KERNEL); ?
> + if (!dax_dev->res)
> + goto err_res;
> +
Byte,
Johannes
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
WARNING: multiple messages have this Message-ID (diff)
From: Johannes Thumshirn <jthumshirn@suse.de>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm@ml01.01.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/8] dax: add region-available-size attribute
Date: Wed, 14 Dec 2016 15:38:02 +0100 [thread overview]
Message-ID: <20161214143802.GD6279@linux-x5ow.site> (raw)
In-Reply-To: <148143771052.10950.7622110904173815243.stgit@dwillia2-desk3.amr.corp.intel.com>
Hi Dan,
On Sat, Dec 10, 2016 at 10:28:30PM -0800, Dan Williams wrote:
> In preparation for a facility that enables dax regions to be
> sub-divided, introduce a 'dax/available_size' attribute. This attribute
> appears under the parent device that registered the device-dax region,
> and it assumes that the device-dax-core owns the driver-data for that
> device.
>
> 'dax/available_size' adjusts dynamically as dax-device instances are
> registered and unregistered.
>
> As a side effect of using __request_region() to reserve capacity from
> the dax_region we now track pointers to those returned resources rather
> than duplicating the passed in resource array.
>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
[...]
> +static const struct attribute_group *dax_region_attribute_groups[] = {
> + &dax_region_attribute_group,
> + NULL,
> };
>
> static struct inode *dax_alloc_inode(struct super_block *sb)
> @@ -200,12 +251,27 @@ void dax_region_put(struct dax_region *dax_region)
> }
> EXPORT_SYMBOL_GPL(dax_region_put);
>
> +
Stray extra newline?
[...]
> struct dax_region *alloc_dax_region(struct device *parent, int region_id,
> struct resource *res, unsigned int align, void *addr,
> unsigned long pfn_flags)
> {
> struct dax_region *dax_region;
>
> + if (dev_get_drvdata(parent)) {
> + dev_WARN(parent, "dax core found drvdata already in use\n");
> + return NULL;
> + }
> +
My first thought was, it might be interesting to see who already claimed
the drvdata. Then I figured, how are multiple sub-regions of a dax-device
supposed to work? What am I missing here?
> if (!IS_ALIGNED(res->start, align)
> || !IS_ALIGNED(resource_size(res), align))
> return NULL;
> @@ -213,16 +279,26 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id,
> dax_region = kzalloc(sizeof(*dax_region), GFP_KERNEL);
> if (!dax_region)
> return NULL;
> -
> - memcpy(&dax_region->res, res, sizeof(*res));
> + dev_set_drvdata(parent, dax_region);
> + dax_region->res.name = dev_name(parent);
> + dax_region->res.start = res->start;
> + dax_region->res.end = res->end;
> dax_region->pfn_flags = pfn_flags;
> + mutex_init(&dax_region->lock);
> kref_init(&dax_region->kref);
> dax_region->id = region_id;
> ida_init(&dax_region->ida);
> dax_region->align = align;
> dax_region->dev = parent;
> dax_region->base = addr;
> + if (sysfs_create_groups(&parent->kobj, dax_region_attribute_groups)) {
> + kfree(dax_region);
> + return NULL;;
> + }
>
> + kref_get(&dax_region->kref);
> + if (devm_add_action_or_reset(parent, dax_region_unregister, dax_region))
> + return NULL;
> return dax_region;
> }
> EXPORT_SYMBOL_GPL(alloc_dax_region);
[...]
> @@ -568,28 +654,42 @@ struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region,
> struct cdev *cdev;
> dev_t dev_t;
>
> - dax_dev = kzalloc(sizeof(*dax_dev) + sizeof(*res) * count, GFP_KERNEL);
> + dax_dev = kzalloc(sizeof(*dax_dev), GFP_KERNEL);
> if (!dax_dev)
> return ERR_PTR(-ENOMEM);
>
> + dax_dev->res = kzalloc(sizeof(res) * count, GFP_KERNEL);
dax_dev->res = kcalloc(sizeof(res), count, GFP_KERNEL); ?
> + if (!dax_dev->res)
> + goto err_res;
> +
Byte,
Johannes
next prev parent reply other threads:[~2016-12-14 14:38 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-11 6:28 [PATCH 0/8] device-dax: sub-division support Dan Williams
2016-12-11 6:28 ` Dan Williams
2016-12-11 6:28 ` [PATCH 1/8] dax: add region-available-size attribute Dan Williams
2016-12-11 6:28 ` Dan Williams
2016-12-14 14:38 ` Johannes Thumshirn [this message]
2016-12-14 14:38 ` Johannes Thumshirn
2016-12-14 15:53 ` Dan Williams
2016-12-14 15:53 ` Dan Williams
2016-12-15 6:47 ` Dan Williams
2016-12-15 6:47 ` Dan Williams
2016-12-11 6:28 ` [PATCH 2/8] dax: add region 'id', 'size', and 'align' attributes Dan Williams
2016-12-11 6:28 ` Dan Williams
2016-12-11 6:28 ` [PATCH 3/8] dax: register seed device Dan Williams
2016-12-11 6:28 ` Dan Williams
2016-12-11 6:28 ` [PATCH 4/8] dax: use multi-order radix for resource lookup Dan Williams
2016-12-11 6:28 ` Dan Williams
2016-12-11 6:28 ` [PATCH 5/8] dax: refactor locking out of size calculation routines Dan Williams
2016-12-11 6:28 ` Dan Williams
2016-12-14 15:01 ` Johannes Thumshirn
2016-12-14 15:01 ` Johannes Thumshirn
2016-12-14 15:55 ` Dan Williams
2016-12-14 15:55 ` Dan Williams
2016-12-11 6:28 ` [PATCH 6/8] dax: sub-division support Dan Williams
2016-12-11 6:28 ` Dan Williams
2016-12-11 6:29 ` [PATCH 7/8] dax: add / remove dax devices after provisioning Dan Williams
2016-12-11 6:29 ` Dan Williams
2016-12-11 6:29 ` [PATCH 8/8] dax: add debug for region available_size Dan Williams
2016-12-11 6:29 ` Dan Williams
[not found] ` <148143770485.10950.13227732273892953675.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-12-12 17:15 ` [PATCH 0/8] device-dax: sub-division support Jeff Moyer
2016-12-12 17:15 ` Jeff Moyer
[not found] ` <x497f75hxwp.fsf-RRHT56Q3PSP4kTEheFKJxxDDeQx5vsVwAInAS/Ez/D0@public.gmane.org>
2016-12-12 18:46 ` Dan Williams
2016-12-12 18:46 ` Dan Williams
2016-12-13 23:46 ` Jeff Moyer
2016-12-13 23:46 ` Jeff Moyer
[not found] ` <x494m278kam.fsf-RRHT56Q3PSP4kTEheFKJxxDDeQx5vsVwAInAS/Ez/D0@public.gmane.org>
2016-12-14 1:17 ` Dan Williams
2016-12-14 1:17 ` Dan Williams
[not found] ` <CAPcyv4hzCHqF9ALYFYCpv=WyHoMOFDoeWOd38b4sKwmkkmSgLQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-15 16:50 ` Jeff Moyer
2016-12-15 16:50 ` Jeff Moyer
[not found] ` <x49shpp3zn8.fsf-RRHT56Q3PSP4kTEheFKJxxDDeQx5vsVwAInAS/Ez/D0@public.gmane.org>
2016-12-15 23:48 ` Dan Williams
2016-12-15 23:48 ` Dan Williams
[not found] ` <CAPcyv4gWW0NfiP6iGpaB5hAyiD8SMbeAfAKvezDLH1GzH_HqTA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-16 2:33 ` Dan Williams
2016-12-16 2:33 ` 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=20161214143802.GD6279@linux-x5ow.site \
--to=jthumshirn@suse.de \
--cc=dan.j.williams@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.