From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from g9t1613g.houston.hp.com ([15.240.0.71]:58227 "EHLO g9t1613g.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932151AbbKMQFM (ORCPT ); Fri, 13 Nov 2015 11:05:12 -0500 Received: from g4t3427.houston.hp.com (g4t3427.houston.hp.com [15.201.208.55]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by g9t1613g.houston.hp.com (Postfix) with ESMTPS id B28E26260E for ; Fri, 13 Nov 2015 16:04:44 +0000 (UTC) Message-ID: <1447430433.21443.85.camel@hpe.com> Subject: Re: [RFC 1/1] memremap: devm_memremap_pages has wrong nid From: Toshi Kani To: Dan Williams , Boaz Harrosh Cc: linux-fsdevel , "linux-nvdimm@lists.01.org" Date: Fri, 13 Nov 2015 09:00:33 -0700 In-Reply-To: References: <5643B043.3010103@plexistor.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, 2015-11-11 at 13:46 -0800, Dan Williams wrote: > On Wed, Nov 11, 2015 at 1:16 PM, Boaz Harrosh wrote: > > > > 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. > > Let's just do that instead. I.e. in the case of NFIT numa node should > already be set, and in the case of the memmap=ss!nn or e820-type-12 we > can set the numa node like this: Agreed. memory_add_physaddr_to_nid() uses the SRAT info, which does not work with the NFIT case. Thanks, -Toshi > diff --git a/drivers/nvdimm/e820.c b/drivers/nvdimm/e820.c > index 8282db2ef99e..e40df8fedf73 100644 > --- a/drivers/nvdimm/e820.c > +++ b/drivers/nvdimm/e820.c > @@ -48,7 +48,7 @@ static int e820_pmem_probe(struct platform_device *pdev) > memset(&ndr_desc, 0, sizeof(ndr_desc)); > ndr_desc.res = p; > ndr_desc.attr_groups = e820_pmem_region_attribute_groups; > - ndr_desc.numa_node = NUMA_NO_NODE; > + ndr_desc.numa_node = memory_add_physaddr_to_nid(p->start); > set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags); > if (!nvdimm_pmem_region_create(nvdimm_bus, &ndr_desc)) > goto err; > > Thanks for pointing out memory_add_physaddr_to_nid(). I did not know > that existed.