From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:44933 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752047AbbHZVv2 (ORCPT ); Wed, 26 Aug 2015 17:51:28 -0400 Date: Wed, 26 Aug 2015 14:51:26 -0700 From: Andrew Morton To: David Rientjes Cc: Yinghai Lu , Greg Kroah-Hartman , Tony Luck , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v3] mm: Check if section present during memory block registering Message-Id: <20150826145126.a85594b385b55057ec3fccdb@linux-foundation.org> In-Reply-To: References: <1440622873-17641-1-git-send-email-yinghai@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: On Wed, 26 Aug 2015 14:38:35 -0700 (PDT) David Rientjes wrote: > > --- linux-2.6.orig/drivers/base/node.c > > +++ linux-2.6/drivers/base/node.c > > @@ -390,7 +390,18 @@ int register_mem_sect_under_node(struct > > sect_end_pfn = section_nr_to_pfn(mem_blk->end_section_nr); > > sect_end_pfn += PAGES_PER_SECTION - 1; > > for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) { > > - int page_nid; > > + int page_nid, scn_nr; > > + > > + /* > > + * memory block could have several absent sections from start. > > + * skip pfn range from absent section > > + */ > > + scn_nr = pfn_to_section_nr(pfn); > > + if (!present_section_nr(scn_nr)) { > > + pfn = round_down(pfn + PAGES_PER_SECTION, > > + PAGES_PER_SECTION) - 1; > > + continue; > > + } > > > > page_nid = get_nid_for_pfn(pfn); > > if (page_nid < 0) > > scn_nr should really be unsigned long, but it would probably be better to > simply use if (!pfn_present(pfn)) rather than store the section number. Yup. I was feeling lazy but you motivated me. --- a/drivers/base/node.c~mm-check-if-section-present-during-memory-block-registering-fix +++ a/drivers/base/node.c @@ -390,14 +390,13 @@ int register_mem_sect_under_node(struct sect_end_pfn = section_nr_to_pfn(mem_blk->end_section_nr); sect_end_pfn += PAGES_PER_SECTION - 1; for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) { - int page_nid, scn_nr; + int page_nid; /* * memory block could have several absent sections from start. * skip pfn range from absent section */ - scn_nr = pfn_to_section_nr(pfn); - if (!present_section_nr(scn_nr)) { + if (!present_section_nr(pfn_to_section_nr(pfn))) { pfn = round_down(pfn + PAGES_PER_SECTION, PAGES_PER_SECTION) - 1; continue; _