Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3413167imu; Fri, 18 Jan 2019 09:56:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN61s1efonFDLtmwu6uRrB+hbUdZW5T/xASzZx03BEy7+1WNE0h7t/2YEBGp/OA8YJ6CSETF X-Received: by 2002:a17:902:346:: with SMTP id 64mr20568648pld.337.1547834191117; Fri, 18 Jan 2019 09:56:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547834191; cv=none; d=google.com; s=arc-20160816; b=GD1oaYBUtgKZaV7KtknXK3VAdctiOKPM6YOC1KA66duvjUS/3yv97BuUgo8oC6PaiB kGmxc9ViPA28WrQnAMvU5XjzVTst6oWEYZ0swMQ9CtuhEGhux0JV8uEXgKn2fhO+1w60 tucHnqJLAMO4ZC2weeq+ceIrY02pHeG+FuyXT0T3lW98rldBrhXaJUKru8ZR39w2udr/ uhTt1Vx9b7tv67lmu6Y3i7kHFZXvqm2UGgKn+YF/i1UUVevd8Y/YIYGYSsmtHXAvjvue LJobnEvSlzpPfI55qRSuy2Dc+aVhzvO5/XI7ZS8Y1QuaehSi01Qk7ah3vR9MjlFDO3fV 99eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=1umYCuCqPEt8hgwHsF5GWN8/VBehoTF7sexCPQhQrac=; b=kCjAHPvKuqIJbIVhunCOhw9coweR6YPejICo/4RYUHDJvs/jlh3pe9kbswKmrQIvDB z76iUVFtkT4CjDam0rrJgsmeSgSxhns2lfdUtWEoc8hnnNFCq+65xmZJGA785NNbIZxb cpJgIaTqbKswey1QuMldSWwfhlq5JYCWREq+skgPVUNLkrriyn60qEtG+SaMijmMQnuK ul5gbFpjDW7rySSw26DRcrqipNzRQyIEYr5SynyqYWryAv3Hfue+psT9FP4E3TbuBw53 tmlznDFVKQiDBKjl4fR3shdnDlKwz+7gDKeSd4M9DtpjWLgCQgBp2hvOCxjAxU2NdLA+ ruUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si605910pgo.23.2019.01.18.09.56.15; Fri, 18 Jan 2019 09:56:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728982AbfARRyV (ORCPT + 99 others); Fri, 18 Jan 2019 12:54:21 -0500 Received: from outbound-smtp25.blacknight.com ([81.17.249.193]:44223 "EHLO outbound-smtp25.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728949AbfARRyV (ORCPT ); Fri, 18 Jan 2019 12:54:21 -0500 Received: from mail.blacknight.com (pemlinmail03.blacknight.ie [81.17.254.16]) by outbound-smtp25.blacknight.com (Postfix) with ESMTPS id 9BA53B879A for ; Fri, 18 Jan 2019 17:54:19 +0000 (GMT) Received: (qmail 5918 invoked from network); 18 Jan 2019 17:54:19 -0000 Received: from unknown (HELO stampy.163woodhaven.lan) (mgorman@techsingularity.net@[37.228.229.96]) by 81.17.254.9 with ESMTPA; 18 Jan 2019 17:54:19 -0000 From: Mel Gorman To: Andrew Morton Cc: David Rientjes , Andrea Arcangeli , Vlastimil Babka , Linux List Kernel Mailing , Linux-MM , Mel Gorman Subject: [PATCH 15/22] mm, compaction: Keep cached migration PFNs synced for unusable pageblocks Date: Fri, 18 Jan 2019 17:51:29 +0000 Message-Id: <20190118175136.31341-16-mgorman@techsingularity.net> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190118175136.31341-1-mgorman@techsingularity.net> References: <20190118175136.31341-1-mgorman@techsingularity.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Migrate has separate cached PFNs for ASYNC and SYNC* migration on the basis that some migrations will fail in ASYNC mode. However, if the cached PFNs match at the start of scanning and pageblocks are skipped due to having no isolation candidates, then the sync state does not matter. This patch keeps matching cached PFNs in sync until a pageblock with isolation candidates is found. The actual benefit is marginal given that the sync scanner following the async scanner will often skip a number of pageblocks but it's useless work. Any benefit depends heavily on whether the scanners restarted recently. Signed-off-by: Mel Gorman Acked-by: Vlastimil Babka --- mm/compaction.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mm/compaction.c b/mm/compaction.c index 14bb66d48392..829540f6f3da 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1969,6 +1969,7 @@ static enum compact_result compact_zone(struct compact_control *cc) unsigned long end_pfn = zone_end_pfn(cc->zone); unsigned long last_migrated_pfn; const bool sync = cc->mode != MIGRATE_ASYNC; + bool update_cached; cc->migratetype = gfpflags_to_migratetype(cc->gfp_mask); ret = compaction_suitable(cc->zone, cc->order, cc->alloc_flags, @@ -2016,6 +2017,17 @@ static enum compact_result compact_zone(struct compact_control *cc) last_migrated_pfn = 0; + /* + * Migrate has separate cached PFNs for ASYNC and SYNC* migration on + * the basis that some migrations will fail in ASYNC mode. However, + * if the cached PFNs match and pageblocks are skipped due to having + * no isolation candidates, then the sync state does not matter. + * Until a pageblock with isolation candidates is found, keep the + * cached PFNs in sync to avoid revisiting the same blocks. + */ + update_cached = !sync && + cc->zone->compact_cached_migrate_pfn[0] == cc->zone->compact_cached_migrate_pfn[1]; + trace_mm_compaction_begin(start_pfn, cc->migrate_pfn, cc->free_pfn, end_pfn, sync); @@ -2047,6 +2059,11 @@ static enum compact_result compact_zone(struct compact_control *cc) last_migrated_pfn = 0; goto out; case ISOLATE_NONE: + if (update_cached) { + cc->zone->compact_cached_migrate_pfn[1] = + cc->zone->compact_cached_migrate_pfn[0]; + } + /* * We haven't isolated and migrated anything, but * there might still be unflushed migrations from @@ -2054,6 +2071,7 @@ static enum compact_result compact_zone(struct compact_control *cc) */ goto check_drain; case ISOLATE_SUCCESS: + update_cached = false; last_migrated_pfn = start_pfn; ; } -- 2.16.4