From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753275AbcBJS6r (ORCPT ); Wed, 10 Feb 2016 13:58:47 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39746 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752626AbcBJS6q (ORCPT ); Wed, 10 Feb 2016 13:58:46 -0500 Date: Wed, 10 Feb 2016 10:58:45 -0800 From: Andrew Morton To: Vlastimil Babka Cc: Joonsoo Kim , Aaron Lu , Mel Gorman , Rik van Riel , David Rientjes , LKML , Linux Memory Management List , Joonsoo Kim Subject: Re: [PATCH v2 3/3] mm/compaction: speed up pageblock_pfn_to_page() when zone is contiguous Message-Id: <20160210105845.973cecc56906ed950fbdd8ba@linux-foundation.org> In-Reply-To: <56BB3E61.50707@suse.cz> References: <1454566775-30973-1-git-send-email-iamjoonsoo.kim@lge.com> <1454566775-30973-3-git-send-email-iamjoonsoo.kim@lge.com> <20160204164929.a2f12b8a7edcdfa596abd850@linux-foundation.org> <56BA28C8.3060903@suse.cz> <20160209125301.c7e6067558c321cfb87602b5@linux-foundation.org> <56BB3E61.50707@suse.cz> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 10 Feb 2016 14:42:57 +0100 Vlastimil Babka wrote: > > --- a/mm/memory_hotplug.c > > +++ b/mm/memory_hotplug.c > > @@ -509,6 +509,8 @@ int __ref __add_pages(int nid, struct zone *zone, unsigned long phys_start_pfn, > > int start_sec, end_sec; > > struct vmem_altmap *altmap; > > > > + clear_zone_contiguous(zone); > > + > > /* during initialize mem_map, align hot-added range to section */ > > start_sec = pfn_to_section_nr(phys_start_pfn); > > end_sec = pfn_to_section_nr(phys_start_pfn + nr_pages - 1); > > @@ -540,6 +542,8 @@ int __ref __add_pages(int nid, struct zone *zone, unsigned long phys_start_pfn, > > } > > vmemmap_populate_print_last(); > > > > + set_zone_contiguous(zone); > > + > > return err; > > } > > EXPORT_SYMBOL_GPL(__add_pages); > > Between the clear and set, __add_pages() might return with -EINVAL, > leaving the flag cleared potentially forever. Not critical, probably > rare, but it should be possible to avoid this by moving the clear below > the altmap check? um, yes. return-in-the-middle-of-a-function strikes again. --- a/mm/memory_hotplug.c~mm-compaction-speed-up-pageblock_pfn_to_page-when-zone-is-contiguous-fix +++ a/mm/memory_hotplug.c @@ -526,7 +526,8 @@ int __ref __add_pages(int nid, struct zo if (altmap->base_pfn != phys_start_pfn || vmem_altmap_offset(altmap) > nr_pages) { pr_warn_once("memory add fail, invalid altmap\n"); - return -EINVAL; + err = -EINVAL; + goto out; } altmap->alloc = 0; } @@ -544,9 +545,8 @@ int __ref __add_pages(int nid, struct zo err = 0; } vmemmap_populate_print_last(); - +out: set_zone_contiguous(zone); - return err; } EXPORT_SYMBOL_GPL(__add_pages); _ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by kanga.kvack.org (Postfix) with ESMTP id 163976B0253 for ; Wed, 10 Feb 2016 13:58:47 -0500 (EST) Received: by mail-pa0-f47.google.com with SMTP id yy13so15995347pab.3 for ; Wed, 10 Feb 2016 10:58:47 -0800 (PST) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org. [140.211.169.12]) by mx.google.com with ESMTPS id m81si6696633pfi.201.2016.02.10.10.58.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Feb 2016 10:58:46 -0800 (PST) Date: Wed, 10 Feb 2016 10:58:45 -0800 From: Andrew Morton Subject: Re: [PATCH v2 3/3] mm/compaction: speed up pageblock_pfn_to_page() when zone is contiguous Message-Id: <20160210105845.973cecc56906ed950fbdd8ba@linux-foundation.org> In-Reply-To: <56BB3E61.50707@suse.cz> References: <1454566775-30973-1-git-send-email-iamjoonsoo.kim@lge.com> <1454566775-30973-3-git-send-email-iamjoonsoo.kim@lge.com> <20160204164929.a2f12b8a7edcdfa596abd850@linux-foundation.org> <56BA28C8.3060903@suse.cz> <20160209125301.c7e6067558c321cfb87602b5@linux-foundation.org> <56BB3E61.50707@suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka Cc: Joonsoo Kim , Aaron Lu , Mel Gorman , Rik van Riel , David Rientjes , LKML , Linux Memory Management List , Joonsoo Kim On Wed, 10 Feb 2016 14:42:57 +0100 Vlastimil Babka wrote: > > --- a/mm/memory_hotplug.c > > +++ b/mm/memory_hotplug.c > > @@ -509,6 +509,8 @@ int __ref __add_pages(int nid, struct zone *zone, unsigned long phys_start_pfn, > > int start_sec, end_sec; > > struct vmem_altmap *altmap; > > > > + clear_zone_contiguous(zone); > > + > > /* during initialize mem_map, align hot-added range to section */ > > start_sec = pfn_to_section_nr(phys_start_pfn); > > end_sec = pfn_to_section_nr(phys_start_pfn + nr_pages - 1); > > @@ -540,6 +542,8 @@ int __ref __add_pages(int nid, struct zone *zone, unsigned long phys_start_pfn, > > } > > vmemmap_populate_print_last(); > > > > + set_zone_contiguous(zone); > > + > > return err; > > } > > EXPORT_SYMBOL_GPL(__add_pages); > > Between the clear and set, __add_pages() might return with -EINVAL, > leaving the flag cleared potentially forever. Not critical, probably > rare, but it should be possible to avoid this by moving the clear below > the altmap check? um, yes. return-in-the-middle-of-a-function strikes again. --- a/mm/memory_hotplug.c~mm-compaction-speed-up-pageblock_pfn_to_page-when-zone-is-contiguous-fix +++ a/mm/memory_hotplug.c @@ -526,7 +526,8 @@ int __ref __add_pages(int nid, struct zo if (altmap->base_pfn != phys_start_pfn || vmem_altmap_offset(altmap) > nr_pages) { pr_warn_once("memory add fail, invalid altmap\n"); - return -EINVAL; + err = -EINVAL; + goto out; } altmap->alloc = 0; } @@ -544,9 +545,8 @@ int __ref __add_pages(int nid, struct zo err = 0; } vmemmap_populate_print_last(); - +out: set_zone_contiguous(zone); - return err; } EXPORT_SYMBOL_GPL(__add_pages); _ -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org