pmem, memremap: convert to numa aware allocations
authorDan Williams <dan.j.williams@intel.com>
Tue, 6 Oct 2015 00:35:56 +0000 (20:35 -0400)
committerDan Williams <dan.j.williams@intel.com>
Fri, 9 Oct 2015 21:00:33 +0000 (17:00 -0400)
Given that pmem ranges come with numa-locality hints, arrange for the
resulting driver objects to be obtained from node-local memory.

Reviewed-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/nvdimm/pmem.c
kernel/memremap.c

index 9805d311b1d17a07c7401de39b81372f6f7f4bc3..349f03e7ed064f20dfaf8d25bd0d62f83d829d79 100644 (file)
@@ -176,9 +176,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;
 
@@ -188,7 +189,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;
index 56fc4783879cd21537f0863e0c91bf5527dc7883..3218e8b1fc28a62474af1120b282200467c97c00 100644 (file)
@@ -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 ERR_PTR(-ENOMEM);
 
@@ -165,8 +166,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);