* [PATCH 0/3] numa allocations for devm and pmem
@ 2015-09-26 1:17 Dan Williams
2015-09-26 1:17 ` [PATCH 1/3] devm: make allocations numa aware by default Dan Williams
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Dan Williams @ 2015-09-26 1:17 UTC (permalink / raw)
To: tj; +Cc: Ross Zwisler, linux-nvdimm, hch, linux-kernel
I noticed that pmem should be using blk_alloc_queue_node() and then I
wondered about the devm allocations... So, here is a quick conversion
of devm to use dev_to_node() for node local allocations by default and
as a result pmem to allocate all its driver infrastructure near to the
device.
---
Dan Williams (3):
devm: make allocations numa aware by default
devm_memremap_pages: use numa_mem_id
pmem, memremap: convert to numa aware allocations
drivers/base/devres.c | 19 ++++++++++---------
drivers/nvdimm/pmem.c | 5 +++--
include/linux/device.h | 16 ++++++++++++----
kernel/memremap.c | 9 +++++----
4 files changed, 30 insertions(+), 19 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] devm: make allocations numa aware by default
2015-09-26 1:17 [PATCH 0/3] numa allocations for devm and pmem Dan Williams
@ 2015-09-26 1:17 ` Dan Williams
2015-09-30 0:30 ` Dan Williams
2015-09-26 1:17 ` [PATCH 2/3] devm_memremap_pages: use numa_mem_id Dan Williams
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Dan Williams @ 2015-09-26 1:17 UTC (permalink / raw)
To: tj; +Cc: linux-nvdimm, hch, linux-kernel
Given we already have a device just use dev_to_node() to provide hint
allocations for devres. However, current devres_alloc() users will need
to explicitly opt-in with devres_alloc_node().
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/base/devres.c | 19 ++++++++++---------
include/linux/device.h | 16 ++++++++++++----
2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 875464690117..8fc654f0807b 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -82,12 +82,12 @@ static struct devres_group * node_to_group(struct devres_node *node)
}
static __always_inline struct devres * alloc_dr(dr_release_t release,
- size_t size, gfp_t gfp)
+ size_t size, gfp_t gfp, int nid)
{
size_t tot_size = sizeof(struct devres) + size;
struct devres *dr;
- dr = kmalloc_track_caller(tot_size, gfp);
+ dr = kmalloc_node_track_caller(tot_size, gfp, nid);
if (unlikely(!dr))
return NULL;
@@ -106,24 +106,25 @@ static void add_dr(struct device *dev, struct devres_node *node)
}
#ifdef CONFIG_DEBUG_DEVRES
-void * __devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
+void * __devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp, int nid,
const char *name)
{
struct devres *dr;
- dr = alloc_dr(release, size, gfp | __GFP_ZERO);
+ dr = alloc_dr(release, size, gfp | __GFP_ZERO, nid);
if (unlikely(!dr))
return NULL;
set_node_dbginfo(&dr->node, name, size);
return dr->data;
}
-EXPORT_SYMBOL_GPL(__devres_alloc);
+EXPORT_SYMBOL_GPL(__devres_alloc_node);
#else
/**
* devres_alloc - Allocate device resource data
* @release: Release function devres will be associated with
* @size: Allocation size
* @gfp: Allocation flags
+ * @nid: NUMA node
*
* Allocate devres of @size bytes. The allocated area is zeroed, then
* associated with @release. The returned pointer can be passed to
@@ -132,16 +133,16 @@ EXPORT_SYMBOL_GPL(__devres_alloc);
* RETURNS:
* Pointer to allocated devres on success, NULL on failure.
*/
-void * devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
+void * devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp, int nid)
{
struct devres *dr;
- dr = alloc_dr(release, size, gfp | __GFP_ZERO);
+ dr = alloc_dr(release, size, gfp | __GFP_ZERO, nid);
if (unlikely(!dr))
return NULL;
return dr->data;
}
-EXPORT_SYMBOL_GPL(devres_alloc);
+EXPORT_SYMBOL_GPL(devres_alloc_node);
#endif
/**
@@ -776,7 +777,7 @@ void * devm_kmalloc(struct device *dev, size_t size, gfp_t gfp)
struct devres *dr;
/* use raw alloc_dr for kmalloc caller tracing */
- dr = alloc_dr(devm_kmalloc_release, size, gfp);
+ dr = alloc_dr(devm_kmalloc_release, size, gfp, dev_to_node(dev));
if (unlikely(!dr))
return NULL;
diff --git a/include/linux/device.h b/include/linux/device.h
index 5d7bc6349930..b8f411b57dcb 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -604,13 +604,21 @@ typedef void (*dr_release_t)(struct device *dev, void *res);
typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
#ifdef CONFIG_DEBUG_DEVRES
-extern void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
- const char *name);
+extern void *__devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp,
+ int nid, const char *name);
#define devres_alloc(release, size, gfp) \
- __devres_alloc(release, size, gfp, #release)
+ __devres_alloc_node(release, size, gfp, NUMA_NO_NODE, #release)
+#define devres_alloc_node(release, size, gfp, nid) \
+ __devres_alloc_node(release, size, gfp, nid, #release)
#else
-extern void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp);
+extern void *devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp,
+ int nid);
+static inline void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
+{
+ return devres_alloc_node(release, size, gfp, NUMA_NO_NODE);
+}
#endif
+
extern void devres_for_each_res(struct device *dev, dr_release_t release,
dr_match_t match, void *match_data,
void (*fn)(struct device *, void *, void *),
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] devm_memremap_pages: use numa_mem_id
2015-09-26 1:17 [PATCH 0/3] numa allocations for devm and pmem Dan Williams
2015-09-26 1:17 ` [PATCH 1/3] devm: make allocations numa aware by default Dan Williams
@ 2015-09-26 1:17 ` Dan Williams
2015-09-26 1:17 ` [PATCH 3/3] pmem, memremap: convert to numa aware allocations Dan Williams
2015-10-04 6:40 ` [PATCH 0/3] numa allocations for devm and pmem Christoph Hellwig
3 siblings, 0 replies; 7+ messages in thread
From: Dan Williams @ 2015-09-26 1:17 UTC (permalink / raw)
To: tj; +Cc: Ross Zwisler, linux-nvdimm, hch, linux-kernel
Hint to closest numa node for the placement of newly allocated pages.
As that is where the device's other allocations will originate by
default when it does not specify a NUMA node.
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
kernel/memremap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/memremap.c b/kernel/memremap.c
index 72b0c66628b6..86a5cdeb18f2 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -175,7 +175,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res)
nid = dev_to_node(dev);
if (nid < 0)
- nid = 0;
+ nid = numa_mem_id();
error = arch_add_memory(nid, res->start, resource_size(res), true);
if (error) {
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] pmem, memremap: convert to numa aware allocations
2015-09-26 1:17 [PATCH 0/3] numa allocations for devm and pmem Dan Williams
2015-09-26 1:17 ` [PATCH 1/3] devm: make allocations numa aware by default Dan Williams
2015-09-26 1:17 ` [PATCH 2/3] devm_memremap_pages: use numa_mem_id Dan Williams
@ 2015-09-26 1:17 ` Dan Williams
2015-10-04 6:40 ` [PATCH 0/3] numa allocations for devm and pmem Christoph Hellwig
3 siblings, 0 replies; 7+ messages in thread
From: Dan Williams @ 2015-09-26 1:17 UTC (permalink / raw)
To: tj; +Cc: linux-nvdimm, hch, linux-kernel
Given that pmem ranges come with numa-locality hints, arrange for the
resulting driver objects to be obtained from node-local memory.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/nvdimm/pmem.c | 5 +++--
kernel/memremap.c | 7 ++++---
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index b9525385c0dc..570764a7599e 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -177,9 +177,10 @@ static void pmem_detach_disk(struct pmem_device *pmem)
static int pmem_attach_disk(struct device *dev,
struct nd_namespace_common *ndns, struct pmem_device *pmem)
{
+ int nid = dev_to_node(dev);
struct gendisk *disk;
- pmem->pmem_queue = blk_alloc_queue(GFP_KERNEL);
+ pmem->pmem_queue = blk_alloc_queue_node(GFP_KERNEL, nid);
if (!pmem->pmem_queue)
return -ENOMEM;
@@ -189,7 +190,7 @@ static int pmem_attach_disk(struct device *dev,
blk_queue_bounce_limit(pmem->pmem_queue, BLK_BOUNCE_ANY);
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, pmem->pmem_queue);
- disk = alloc_disk(0);
+ disk = alloc_disk_node(0, nid);
if (!disk) {
blk_cleanup_queue(pmem->pmem_queue);
return -ENOMEM;
diff --git a/kernel/memremap.c b/kernel/memremap.c
index 86a5cdeb18f2..f257c4e66e60 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -114,7 +114,8 @@ void *devm_memremap(struct device *dev, resource_size_t offset,
{
void **ptr, *addr;
- ptr = devres_alloc(devm_memremap_release, sizeof(*ptr), GFP_KERNEL);
+ ptr = devres_alloc_node(devm_memremap_release, sizeof(*ptr), GFP_KERNEL,
+ dev_to_node(dev));
if (!ptr)
return NULL;
@@ -166,8 +167,8 @@ void *devm_memremap_pages(struct device *dev, struct resource *res)
if (is_ram == REGION_INTERSECTS)
return __va(res->start);
- page_map = devres_alloc(devm_memremap_pages_release,
- sizeof(*page_map), GFP_KERNEL);
+ page_map = devres_alloc_node(devm_memremap_pages_release,
+ sizeof(*page_map), GFP_KERNEL, dev_to_node(dev));
if (!page_map)
return ERR_PTR(-ENOMEM);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] devm: make allocations numa aware by default
2015-09-26 1:17 ` [PATCH 1/3] devm: make allocations numa aware by default Dan Williams
@ 2015-09-30 0:30 ` Dan Williams
2015-09-30 21:40 ` Tejun Heo
0 siblings, 1 reply; 7+ messages in thread
From: Dan Williams @ 2015-09-30 0:30 UTC (permalink / raw)
To: Tejun Heo
Cc: linux-kernel@vger.kernel.org, Christoph Hellwig,
linux-nvdimm@lists.01.org
Hi Tejun, any thoughts on this, or concerns about globally enabling
numa hints for devm allocations?
On Fri, Sep 25, 2015 at 6:17 PM, Dan Williams <dan.j.williams@intel.com> wrote:
> Given we already have a device just use dev_to_node() to provide hint
> allocations for devres. However, current devres_alloc() users will need
> to explicitly opt-in with devres_alloc_node().
>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> drivers/base/devres.c | 19 ++++++++++---------
> include/linux/device.h | 16 ++++++++++++----
> 2 files changed, 22 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/base/devres.c b/drivers/base/devres.c
> index 875464690117..8fc654f0807b 100644
> --- a/drivers/base/devres.c
> +++ b/drivers/base/devres.c
> @@ -82,12 +82,12 @@ static struct devres_group * node_to_group(struct devres_node *node)
> }
>
> static __always_inline struct devres * alloc_dr(dr_release_t release,
> - size_t size, gfp_t gfp)
> + size_t size, gfp_t gfp, int nid)
> {
> size_t tot_size = sizeof(struct devres) + size;
> struct devres *dr;
>
> - dr = kmalloc_track_caller(tot_size, gfp);
> + dr = kmalloc_node_track_caller(tot_size, gfp, nid);
> if (unlikely(!dr))
> return NULL;
>
> @@ -106,24 +106,25 @@ static void add_dr(struct device *dev, struct devres_node *node)
> }
>
> #ifdef CONFIG_DEBUG_DEVRES
> -void * __devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
> +void * __devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp, int nid,
> const char *name)
> {
> struct devres *dr;
>
> - dr = alloc_dr(release, size, gfp | __GFP_ZERO);
> + dr = alloc_dr(release, size, gfp | __GFP_ZERO, nid);
> if (unlikely(!dr))
> return NULL;
> set_node_dbginfo(&dr->node, name, size);
> return dr->data;
> }
> -EXPORT_SYMBOL_GPL(__devres_alloc);
> +EXPORT_SYMBOL_GPL(__devres_alloc_node);
> #else
> /**
> * devres_alloc - Allocate device resource data
> * @release: Release function devres will be associated with
> * @size: Allocation size
> * @gfp: Allocation flags
> + * @nid: NUMA node
> *
> * Allocate devres of @size bytes. The allocated area is zeroed, then
> * associated with @release. The returned pointer can be passed to
> @@ -132,16 +133,16 @@ EXPORT_SYMBOL_GPL(__devres_alloc);
> * RETURNS:
> * Pointer to allocated devres on success, NULL on failure.
> */
> -void * devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
> +void * devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp, int nid)
> {
> struct devres *dr;
>
> - dr = alloc_dr(release, size, gfp | __GFP_ZERO);
> + dr = alloc_dr(release, size, gfp | __GFP_ZERO, nid);
> if (unlikely(!dr))
> return NULL;
> return dr->data;
> }
> -EXPORT_SYMBOL_GPL(devres_alloc);
> +EXPORT_SYMBOL_GPL(devres_alloc_node);
> #endif
>
> /**
> @@ -776,7 +777,7 @@ void * devm_kmalloc(struct device *dev, size_t size, gfp_t gfp)
> struct devres *dr;
>
> /* use raw alloc_dr for kmalloc caller tracing */
> - dr = alloc_dr(devm_kmalloc_release, size, gfp);
> + dr = alloc_dr(devm_kmalloc_release, size, gfp, dev_to_node(dev));
> if (unlikely(!dr))
> return NULL;
>
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 5d7bc6349930..b8f411b57dcb 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -604,13 +604,21 @@ typedef void (*dr_release_t)(struct device *dev, void *res);
> typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
>
> #ifdef CONFIG_DEBUG_DEVRES
> -extern void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
> - const char *name);
> +extern void *__devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp,
> + int nid, const char *name);
> #define devres_alloc(release, size, gfp) \
> - __devres_alloc(release, size, gfp, #release)
> + __devres_alloc_node(release, size, gfp, NUMA_NO_NODE, #release)
> +#define devres_alloc_node(release, size, gfp, nid) \
> + __devres_alloc_node(release, size, gfp, nid, #release)
> #else
> -extern void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp);
> +extern void *devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp,
> + int nid);
> +static inline void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
> +{
> + return devres_alloc_node(release, size, gfp, NUMA_NO_NODE);
> +}
> #endif
> +
> extern void devres_for_each_res(struct device *dev, dr_release_t release,
> dr_match_t match, void *match_data,
> void (*fn)(struct device *, void *, void *),
>
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] devm: make allocations numa aware by default
2015-09-30 0:30 ` Dan Williams
@ 2015-09-30 21:40 ` Tejun Heo
0 siblings, 0 replies; 7+ messages in thread
From: Tejun Heo @ 2015-09-30 21:40 UTC (permalink / raw)
To: Dan Williams
Cc: linux-kernel@vger.kernel.org, Christoph Hellwig,
linux-nvdimm@lists.01.org
On Tue, Sep 29, 2015 at 05:30:26PM -0700, Dan Williams wrote:
> Hi Tejun, any thoughts on this, or concerns about globally enabling
> numa hints for devm allocations?
Looks good to me. Please feel free to add
Reviewed-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] numa allocations for devm and pmem
2015-09-26 1:17 [PATCH 0/3] numa allocations for devm and pmem Dan Williams
` (2 preceding siblings ...)
2015-09-26 1:17 ` [PATCH 3/3] pmem, memremap: convert to numa aware allocations Dan Williams
@ 2015-10-04 6:40 ` Christoph Hellwig
3 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2015-10-04 6:40 UTC (permalink / raw)
To: Dan Williams; +Cc: tj, Ross Zwisler, linux-nvdimm, linux-kernel
The whole series looks fine to me:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-10-04 6:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-26 1:17 [PATCH 0/3] numa allocations for devm and pmem Dan Williams
2015-09-26 1:17 ` [PATCH 1/3] devm: make allocations numa aware by default Dan Williams
2015-09-30 0:30 ` Dan Williams
2015-09-30 21:40 ` Tejun Heo
2015-09-26 1:17 ` [PATCH 2/3] devm_memremap_pages: use numa_mem_id Dan Williams
2015-09-26 1:17 ` [PATCH 3/3] pmem, memremap: convert to numa aware allocations Dan Williams
2015-10-04 6:40 ` [PATCH 0/3] numa allocations for devm and pmem Christoph Hellwig
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).