From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boaz Harrosh Subject: [RFC 1/1] memremap: devm_memremap_pages has wrong nid Date: Wed, 11 Nov 2015 23:16:51 +0200 Message-ID: <5643B043.3010103@plexistor.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: linux-fsdevel , "linux-nvdimm@lists.01.org" To: Dan Williams Return-path: Received: from mail-wm0-f53.google.com ([74.125.82.53]:37349 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751522AbbKKVQy (ORCPT ); Wed, 11 Nov 2015 16:16:54 -0500 Received: by wmww144 with SMTP id w144so61926552wmw.0 for ; Wed, 11 Nov 2015 13:16:53 -0800 (PST) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 --- kernel/memremap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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) { -- 1.9.3