From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751391AbbAaHuB (ORCPT ); Sat, 31 Jan 2015 02:50:01 -0500 Received: from blu004-omc2s20.hotmail.com ([65.55.111.95]:53250 "EHLO BLU004-OMC2S20.hotmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751055AbbAaHt7 (ORCPT ); Sat, 31 Jan 2015 02:49:59 -0500 X-TMN: [f7YxflQZat6M0iu6LKN/vdmLGaW2/2B5] X-Originating-Email: [zhangyanfei.ok@hotmail.com] Message-ID: Date: Sat, 31 Jan 2015 15:49:38 +0800 From: Zhang Yanfei User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Joonsoo Kim , Andrew Morton CC: Vlastimil Babka , Mel Gorman , David Rientjes , Rik van Riel , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Joonsoo Kim Subject: Re: [PATCH v2 2/4] mm/compaction: stop the isolation when we isolate enough freepage References: <1422621252-29859-1-git-send-email-iamjoonsoo.kim@lge.com> <1422621252-29859-3-git-send-email-iamjoonsoo.kim@lge.com> In-Reply-To: <1422621252-29859-3-git-send-email-iamjoonsoo.kim@lge.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 31 Jan 2015 07:49:58.0163 (UTC) FILETIME=[82883630:01D03D2A] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, At 2015/1/30 20:34, Joonsoo Kim wrote: > From: Joonsoo > > Currently, freepage isolation in one pageblock doesn't consider how many > freepages we isolate. When I traced flow of compaction, compaction > sometimes isolates more than 256 freepages to migrate just 32 pages. > > In this patch, freepage isolation is stopped at the point that we > have more isolated freepage than isolated page for migration. This > results in slowing down free page scanner and make compaction success > rate higher. > > stress-highalloc test in mmtests with non movable order 7 allocation shows > increase of compaction success rate. > > Compaction success rate (Compaction success * 100 / Compaction stalls, %) > 27.13 : 31.82 > > pfn where both scanners meets on compaction complete > (separate test due to enormous tracepoint buffer) > (zone_start=4096, zone_end=1048576) > 586034 : 654378 > > In fact, I didn't fully understand why this patch results in such good > result. There was a guess that not used freepages are released to pcp list > and on next compaction trial we won't isolate them again so compaction > success rate would decrease. To prevent this effect, I tested with adding > pcp drain code on release_freepages(), but, it has no good effect. > > Anyway, this patch reduces waste time to isolate unneeded freepages so > seems reasonable. Reviewed-by: Zhang Yanfei IMHO, the patch making the free scanner move slower makes both scanners meet further. Before this patch, if we isolate too many free pages and even after we release the unneeded free pages later the free scanner still already be there and will be moved forward again next time -- the free scanner just cannot be moved back to grab the free pages we released before no matter where the free pages in, pcp or buddy. > > Signed-off-by: Joonsoo Kim > --- > mm/compaction.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/mm/compaction.c b/mm/compaction.c > index 4954e19..782772d 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -490,6 +490,13 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, > > /* If a page was split, advance to the end of it */ > if (isolated) { > + cc->nr_freepages += isolated; > + if (!strict && > + cc->nr_migratepages <= cc->nr_freepages) { > + blockpfn += isolated; > + break; > + } > + > blockpfn += isolated - 1; > cursor += isolated - 1; > continue; > @@ -899,7 +906,6 @@ static void isolate_freepages(struct compact_control *cc) > unsigned long isolate_start_pfn; /* exact pfn we start at */ > unsigned long block_end_pfn; /* end of current pageblock */ > unsigned long low_pfn; /* lowest pfn scanner is able to scan */ > - int nr_freepages = cc->nr_freepages; > struct list_head *freelist = &cc->freepages; > > /* > @@ -924,11 +930,11 @@ static void isolate_freepages(struct compact_control *cc) > * pages on cc->migratepages. We stop searching if the migrate > * and free page scanners meet or enough free pages are isolated. > */ > - for (; block_start_pfn >= low_pfn && cc->nr_migratepages > nr_freepages; > + for (; block_start_pfn >= low_pfn && > + cc->nr_migratepages > cc->nr_freepages; > block_end_pfn = block_start_pfn, > block_start_pfn -= pageblock_nr_pages, > isolate_start_pfn = block_start_pfn) { > - unsigned long isolated; > > /* > * This can iterate a massively long zone without finding any > @@ -953,9 +959,8 @@ static void isolate_freepages(struct compact_control *cc) > continue; > > /* Found a block suitable for isolating free pages from. */ > - isolated = isolate_freepages_block(cc, &isolate_start_pfn, > + isolate_freepages_block(cc, &isolate_start_pfn, > block_end_pfn, freelist, false); > - nr_freepages += isolated; > > /* > * Remember where the free scanner should restart next time, > @@ -987,8 +992,6 @@ static void isolate_freepages(struct compact_control *cc) > */ > if (block_start_pfn < low_pfn) > cc->free_pfn = cc->migrate_pfn; > - > - cc->nr_freepages = nr_freepages; > } > > /* >