diff mbox

[RFC,1/1] memremap: devm_memremap_pages has wrong nid

Message ID 5643B043.3010103@plexistor.com (mailing list archive)
State New, archived
Headers show

Commit Message

Boaz Harrosh Nov. 11, 2015, 9:16 p.m. UTC
The pmem dev as received in devm_memremap_pages() does not have
its dev->numa_node properly initialized yet.

What I see is that all pmem devices will call arch_add_memory
with nid==0 regardless of the real nid the memory is actually
on. Needless to say that after that all the NUMA page and zone
members (at page->flags) come out wrong.

If I do the below code it will all work properly.

RFC because probably we want to fix dev->numa_node before the
call to devm_memremap_pages.

This is on top of v4.3. I will please need the final fix for Stable@

Thanks
Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
---
 kernel/memremap.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox

Patch

diff --git a/kernel/memremap.c b/kernel/memremap.c
index 9d6b555..9409e23 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -183,9 +183,7 @@  void *devm_memremap_pages(struct device *dev, struct resource *res)
 
 	memcpy(&page_map->res, res, sizeof(*res));
 
-	nid = dev_to_node(dev);
-	if (nid < 0)
-		nid = 0;
+	nid = memory_add_physaddr_to_nid(res->start);
 
 	error = arch_add_memory(nid, res->start, resource_size(res), true);
 	if (error) {