From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932352AbcHIM3W (ORCPT ); Tue, 9 Aug 2016 08:29:22 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:42351 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932257AbcHIM3U (ORCPT ); Tue, 9 Aug 2016 08:29:20 -0400 Message-ID: <57A9CB06.5010201@huawei.com> Date: Tue, 9 Aug 2016 20:22:30 +0800 From: zhong jiang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: CC: , , Michal Hocko , , Vlastimil Babka , Minchan Kim , Joonsoo Kim Subject: Re: [PATCH] mm: optimize find_zone_movable_pfns_for_nodes to avoid unnecessary loop. References: <1470405847-53322-1-git-send-email-zhongjiang@huawei.com> In-Reply-To: <1470405847-53322-1-git-send-email-zhongjiang@huawei.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.68] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.57A9CB10.0104,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 7651789327f3094b0f985c2df10e67f2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/8/5 22:04, zhongjiang wrote: > From: zhong jiang > > when required_kernelcore decrease to zero, we should exit the loop in time. > because It will waste time to scan the remainder node. > > Signed-off-by: zhong jiang > --- > mm/page_alloc.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index ea759b9..be7df17 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -6093,7 +6093,7 @@ static unsigned long __init early_calculate_totalpages(void) > unsigned long pages = end_pfn - start_pfn; > > totalpages += pages; > - if (pages) > + if (!node_isset(nid, node_states[N_MEMORY]) && pages) > node_set_state(nid, N_MEMORY); > } > return totalpages; > @@ -6115,6 +6115,7 @@ static void __init find_zone_movable_pfns_for_nodes(void) > unsigned long totalpages = early_calculate_totalpages(); > int usable_nodes = nodes_weight(node_states[N_MEMORY]); > struct memblock_region *r; > + bool avoid_loop = false; > > /* Need to find movable_zone earlier when movable_node is specified. */ > find_usable_zone_for_movable(); > @@ -6275,6 +6276,8 @@ restart: > required_kernelcore -= min(required_kernelcore, > size_pages); > kernelcore_remaining -= size_pages; > + if (!required_kernelcore && avoid_loop) > + goto out2; > if (!kernelcore_remaining) > break; > } > @@ -6287,9 +6290,10 @@ restart: > * satisfied > */ > usable_nodes--; > - if (usable_nodes && required_kernelcore > usable_nodes) > + if (usable_nodes && required_kernelcore > usable_nodes) { > + avoid_loop = true; > goto restart; > - > + } > out2: > /* Align start of ZONE_MOVABLE on all nids to MAX_ORDER_NR_PAGES */ > for (nid = 0; nid < MAX_NUMNODES; nid++) Any one have any objection about above patch ? please let me know.