Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932747AbbFLJzm (ORCPT ); Fri, 12 Jun 2015 05:55:42 -0400 Received: from mail-wg0-f45.google.com ([74.125.82.45]:36115 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932707AbbFLJzd convert rfc822-to-8bit (ORCPT ); Fri, 12 Jun 2015 05:55:33 -0400 From: Michal Nazarewicz To: Vlastimil Babka , Andrew Morton , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Vlastimil Babka , Minchan Kim , Mel Gorman , Joonsoo Kim , Naoya Horiguchi , Christoph Lameter , Rik van Riel , David Rientjes Subject: Re: [PATCH 1/6] mm, compaction: more robust check for scanners meeting In-Reply-To: <1433928754-966-2-git-send-email-vbabka@suse.cz> Organization: http://mina86.com/ References: <1433928754-966-1-git-send-email-vbabka@suse.cz> <1433928754-966-2-git-send-email-vbabka@suse.cz> User-Agent: Notmuch/0.19+53~g2e63a09 (http://notmuchmail.org) Emacs/25.0.50.1 (x86_64-unknown-linux-gnu) X-Face: PbkBB1w#)bOqd`iCe"Ds{e+!C7`pkC9a|f)Qo^BMQvy\q5x3?vDQJeN(DS?|-^$uMti[3D*#^_Ts"pU$jBQLq~Ud6iNwAw_r_o_4]|JO?]}P_}Nc&"p#D(ZgUb4uCNPe7~a[DbPG0T~!&c.y$Ur,=N4RT>]dNpd;KFrfMCylc}gc??'U2j,!8%xdD Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWbfGlUPDDHgE57V0jUupKjgIObY0PLrom9mH4dFRK4gmjPs41MxjOgAAACQElEQVQ4jW3TMWvbQBQHcBk1xE6WyALX1069oZBMlq+ouUwpEQQ6uRjttkWP4CmBgGM0BQLBdPFZYPsyFUo6uEtKDQ7oy/U96XR2Ux8ehH/89Z6enqxBcS7Lg81jmSuujrfCZcLI/TYYvbGj+jbgFpHJ/bqQAUISj8iLyu4LuFHJTosxsucO4jSDNE0Hq3hwK/ceQ5sx97b8LcUDsILfk+ovHkOIsMbBfg43VuQ5Ln9YAGCkUdKJoXR9EclFBhixy3EGVz1K6eEkhxCAkeMMnqoAhAKwhoUJkDrCqvbecaYINlFKSRS1i12VKH1XpUd4qxL876EkMcDvHj3s5RBajHHMlA5iK32e0C7VgG0RlzFPvoYHZLRmAC0BmNcBruhkE0KsMsbEc62ZwUJDxWUdMsMhVqovoT96i/DnX/ASvz/6hbCabELLk/6FF/8PNpPCGqcZTGFcBhhAaZZDbQPaAB3+KrWWy2XgbYDNIinkdWAFcCpraDE/knwe5DBqGmgzESl1p2E4MWAz0VUPgYYzmfWb9yS4vCvgsxJriNTHoIBz5YteBvg+VGISQWUqhMiByPIPpygeDBE6elD973xWwKkEiHZAHKjhuPsFnBuArrzxtakRcISv+XMIPl4aGBUJm8Emk7qBYU8IlgNEIpiJhk/No24jHwkKTFHDWfPniR4iw5vJaw2nzSjfq2zffcE/GDjRC2dn0J0XwPAbDL84TvaFCJEU4Oml9pRyEUhR3Cl2t01AoEjRbs0sYugp14/4X5n4pU4EHHnMAAAAAElFTkSuQmCC X-PGP: 50751FF4 X-PGP-FP: AC1F 5F5C D418 88F8 CC84 5858 2060 4012 5075 1FF4 X-Hashcash: 1:20:150612:akpm@linux-foundation.org::kCqkcya7FK6ZGBUr:0000000000000000000000000000000000000CBc X-Hashcash: 1:20:150612:iamjoonsoo.kim@lge.com::LdYuTtek9NLb89up:0000000000000000000000000000000000000000fCM X-Hashcash: 1:20:150612:mgorman@suse.de::wcM0WKSMI8OcI9vn:0012zO X-Hashcash: 1:20:150612:vbabka@suse.cz::SvnzzzsnhAAJWTZf:0000/7w X-Hashcash: 1:20:150612:rientjes@google.com::LxMGYtmwv2zZhlpP:0000000000000000000000000000000000000000001YAp X-Hashcash: 1:20:150612:riel@redhat.com::T+9CS7G0/TNdREys:002gO5 X-Hashcash: 1:20:150612:linux-kernel@vger.kernel.org::Ue/9kXIu2v/N+aT8:0000000000000000000000000000000003Yy+ X-Hashcash: 1:20:150612:vbabka@suse.cz::5ipwZ0B6vPKZPjaL:0005Zaz X-Hashcash: 1:20:150612:minchan@kernel.org::IvalH+0h9hnpmCuU:00000000000000000000000000000000000000000003CNH X-Hashcash: 1:20:150612:linux-mm@kvack.org::RWIcy5zLIBcmrvks:000000000000000000000000000000000000000000075xd X-Hashcash: 1:20:150612:n-horiguchi@ah.jp.nec.com::1Zjwd2Rx/5OkWypy:000000000000000000000000000000000000AmoH X-Hashcash: 1:20:150612:cl@linux.com::u66ycB8oREFFUAXN:00000BFKI Date: Fri, 12 Jun 2015 11:55:29 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4449 Lines: 105 On Wed, Jun 10 2015, Vlastimil Babka wrote: > Compaction should finish when the migration and free scanner meet, i.e. they > reach the same pageblock. Currently however, the test in compact_finished() > simply just compares the exact pfns, which may yield a false negative when the > free scanner position is in the middle of a pageblock and the migration scanner > reaches the beginning of the same pageblock. > > This hasn't been a problem until commit e14c720efdd7 ("mm, compaction: remember > position within pageblock in free pages scanner") allowed the free scanner > position to be in the middle of a pageblock between invocations. The hot-fix > 1d5bfe1ffb5b ("mm, compaction: prevent infinite loop in compact_zone") > prevented the issue by adding a special check in the migration scanner to > satisfy the current detection of scanners meeting. > > However, the proper fix is to make the detection more robust. This patch > introduces the compact_scanners_met() function that returns true when the free > scanner position is in the same or lower pageblock than the migration scanner. > The special case in isolate_migratepages() introduced by 1d5bfe1ffb5b is > removed. > > Suggested-by: Joonsoo Kim > Signed-off-by: Vlastimil Babka > Cc: Minchan Kim > Cc: Mel Gorman > Cc: Joonsoo Kim > Cc: Michal Nazarewicz Acked-by: Michal Nazarewicz > Cc: Naoya Horiguchi > Cc: Christoph Lameter > Cc: Rik van Riel > Cc: David Rientjes > --- > mm/compaction.c | 22 ++++++++++++++-------- > 1 file changed, 14 insertions(+), 8 deletions(-) > > diff --git a/mm/compaction.c b/mm/compaction.c > index 16e1b57..d46aaeb 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -902,6 +902,16 @@ static bool suitable_migration_target(struct page *page) > } > > /* > + * Test whether the free scanner has reached the same or lower pageblock than > + * the migration scanner, and compaction should thus terminate. > + */ > +static inline bool compact_scanners_met(struct compact_control *cc) > +{ > + return (cc->free_pfn >> pageblock_order) > + <= (cc->migrate_pfn >> pageblock_order); > +} > + > +/* > * Based on information in the current compact_control, find blocks > * suitable for isolating free pages from and then isolate them. > */ > @@ -1131,12 +1141,8 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone, > } > > acct_isolated(zone, cc); > - /* > - * Record where migration scanner will be restarted. If we end up in > - * the same pageblock as the free scanner, make the scanners fully > - * meet so that compact_finished() terminates compaction. > - */ > - cc->migrate_pfn = (end_pfn <= cc->free_pfn) ? low_pfn : cc->free_pfn; > + /* Record where migration scanner will be restarted. */ > + cc->migrate_pfn = low_pfn; > > return cc->nr_migratepages ? ISOLATE_SUCCESS : ISOLATE_NONE; > } > @@ -1151,7 +1157,7 @@ static int __compact_finished(struct zone *zone, struct compact_control *cc, > return COMPACT_PARTIAL; > > /* Compaction run completes if the migrate and free scanner meet */ > - if (cc->free_pfn <= cc->migrate_pfn) { > + if (compact_scanners_met(cc)) { > /* Let the next compaction start anew. */ > zone->compact_cached_migrate_pfn[0] = zone->zone_start_pfn; > zone->compact_cached_migrate_pfn[1] = zone->zone_start_pfn; > @@ -1380,7 +1386,7 @@ static int compact_zone(struct zone *zone, struct compact_control *cc) > * migrate_pages() may return -ENOMEM when scanners meet > * and we want compact_finished() to detect it > */ > - if (err == -ENOMEM && cc->free_pfn > cc->migrate_pfn) { > + if (err == -ENOMEM && !compact_scanners_met(cc)) { > ret = COMPACT_PARTIAL; > goto out; > } > -- > 2.1.4 > -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +------ooO--(_)--Ooo-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/