From patchwork Fri Jan 18 17:51:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 10771385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DFAA91E for ; Fri, 18 Jan 2019 17:54:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C58D2FF7F for ; Fri, 18 Jan 2019 17:54:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10A482FFB8; Fri, 18 Jan 2019 17:54:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8483B2FF7F for ; Fri, 18 Jan 2019 17:54:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7FB008E0020; Fri, 18 Jan 2019 12:54:42 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 781D48E0002; Fri, 18 Jan 2019 12:54:42 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 623158E0020; Fri, 18 Jan 2019 12:54:42 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 04E898E0002 for ; Fri, 18 Jan 2019 12:54:42 -0500 (EST) Received: by mail-ed1-f71.google.com with SMTP id l45so5281158edb.1 for ; Fri, 18 Jan 2019 09:54:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=zQG6rQG/frHRZQkm9OpALx7BvtKeG7jt6cS8TBK6YUc=; b=klLurSjjjSVFiaMjA+F0Ssgv/IBezp9mcgheqMW5DqKXQBPxOttVII/eTdStg117xt 9zywyBlw48iAHXempxuGCWsqgLlBvT5ZkDcImIqoQf9MuWEwBoEX8Q9WJ7My9uFNCdeC NFIyKN+4k7cANnMIQq4027/pECqEa7sDWKTElu7z4tiUhKlYgSAHnaVnFl+JcoLMBEaF Qb+yYP+UnBgFOhpp5iNaHwNeAg7HI4hcboeDVqqUzdts3P1zN1xEJJyJXOYPczggtE+X of3rLS6w9QpB+gXtJ1gmbfEiZTMQgEAG3NAsdxXbqq3iDxsjaYbmZc6+4Eku4Z4xBMvP +8Uw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 81.17.249.193 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net X-Gm-Message-State: AJcUukcePWr7YdoxS8tqydY8sQVcxhBH27q1wnwvtfw5jgkp5Khcfnbk gum2Kkx12NL6+qIwWupIDkdCunVdou+ZuRyPJZE1ViD/DuNxvfTkM4cO/n/qHW8lldoRUOUgwF8 VX91lbfivjdpARsweSUGJKwEZJiA7rJF05m1Yn3h+STXav1XoLZVDPdSQkRYWk8rjAw== X-Received: by 2002:a50:d797:: with SMTP id w23mr17389065edi.19.1547834081475; Fri, 18 Jan 2019 09:54:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN7+cSYcxi/2JBLCtBAjJEvPtqFhrSl8GBG4VCSy9rBVARjnNBWdB5Cg6q0BInZwWkN3aFSA X-Received: by 2002:a50:d797:: with SMTP id w23mr17389002edi.19.1547834080299; Fri, 18 Jan 2019 09:54:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547834080; cv=none; d=google.com; s=arc-20160816; b=pgkjL2pxTfnj4PcnJ9mLQgoi6aDz/s1mFP80kEyQp1YeckRki45u3vf1Mpp3jXu9k2 HX/8cjqSrjxgsVGti/nb3/9/x5fD+m4IU+rU/1PJYloRj1Eb+SqnR562xxyIKKHLLefL sdEbSTXm1aZxXf5BLRoyDyKX+Ihrmektwz77R2Zf9hdLQ/ZrpzroxYTqzxieNo3YhFjz PIRBZJ+/J0+eAo8vV2kixRLczoSdWVfv+2T1+v4vFj3Atfh9ivw6OT5Mbl2J2v/2eTI4 rqOzeAMMQ+kMO8t/iPMRZtJzh0aAxYgbtdmCfnoTkMLa+e9bWe/b6X/FN5nab5OSbR96 IjJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=zQG6rQG/frHRZQkm9OpALx7BvtKeG7jt6cS8TBK6YUc=; b=xGHNY+7NzNIlEIrIhCyz/cMPeKtLp7MriVDv1nZ1PBM7QEF9g7Md4WxkJzCzFMoyI9 cWMLS4ZG6oQs/OT2mbrtFy/6D4LGYG+FxgJMLNjYfUjKT3FZJIy6HqTWuzTP3tL4uvlJ kBT1xK0LBrvsvcRXJMGDUssEgXX9YhtJFCcAf90mjOyWUqcJdn7dZR5sr+L/PcXY7rvH ua6GoLicesGMCFgH1GG07Ls7ImtrrOcw+MpCCSrq+ljxpZ1BqWI1jDYhh6m2RoJoiUd5 LLXPrMnlBsLbSrdHI08ilXp4oLq7Mtm5R/LaZOIggENfaSRyAmae8yYno3i25ODdDsLp dRTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 81.17.249.193 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net Received: from outbound-smtp25.blacknight.com (outbound-smtp25.blacknight.com. [81.17.249.193]) by mx.google.com with ESMTPS id p33si9098726eda.412.2019.01.18.09.54.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jan 2019 09:54:40 -0800 (PST) Received-SPF: pass (google.com: domain of mgorman@techsingularity.net designates 81.17.249.193 as permitted sender) client-ip=81.17.249.193; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 81.17.249.193 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net Received: from mail.blacknight.com (pemlinmail03.blacknight.ie [81.17.254.16]) by outbound-smtp25.blacknight.com (Postfix) with ESMTPS id EE285B879A for ; Fri, 18 Jan 2019 17:54:39 +0000 (GMT) Received: (qmail 6988 invoked from network); 18 Jan 2019 17:54:39 -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:39 -0000 From: Mel Gorman To: Andrew Morton Cc: David Rientjes , Andrea Arcangeli , Vlastimil Babka , Linux List Kernel Mailing , Linux-MM , Mel Gorman Subject: [PATCH 17/22] mm, compaction: Do not consider a need to reschedule as contention Date: Fri, 18 Jan 2019 17:51:31 +0000 Message-Id: <20190118175136.31341-18-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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Scanning on large machines can take a considerable length of time and eventually need to be rescheduled. This is treated as an abort event but that's not appropriate as the attempt is likely to be retried after making numerous checks and taking another cycle through the page allocator. This patch will check the need to reschedule if necessary but continue the scanning. The main benefit is reduced scanning when compaction is taking a long time or the machine is over-saturated. It also avoids an unnecessary exit of compaction that ends up being retried by the page allocator in the outer loop. 5.0.0-rc1 5.0.0-rc1 synccached-v3r16 noresched-v3r17 Amean fault-both-1 0.00 ( 0.00%) 0.00 * 0.00%* Amean fault-both-3 2958.27 ( 0.00%) 2965.68 ( -0.25%) Amean fault-both-5 4091.90 ( 0.00%) 3995.90 ( 2.35%) Amean fault-both-7 5803.05 ( 0.00%) 5842.12 ( -0.67%) Amean fault-both-12 9481.06 ( 0.00%) 9550.87 ( -0.74%) Amean fault-both-18 14141.51 ( 0.00%) 13304.72 ( 5.92%) Amean fault-both-24 16438.00 ( 0.00%) 14618.59 ( 11.07%) Amean fault-both-30 17531.72 ( 0.00%) 16650.96 ( 5.02%) Amean fault-both-32 17101.96 ( 0.00%) 17145.15 ( -0.25%) Signed-off-by: Mel Gorman Acked-by: Vlastimil Babka --- mm/compaction.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 9aa71945255d..293d9a9e6f00 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -404,21 +404,6 @@ static bool compact_lock_irqsave(spinlock_t *lock, unsigned long *flags, return true; } -/* - * Aside from avoiding lock contention, compaction also periodically checks - * need_resched() and records async compaction as contended if necessary. - */ -static inline void compact_check_resched(struct compact_control *cc) -{ - /* async compaction aborts if contended */ - if (need_resched()) { - if (cc->mode == MIGRATE_ASYNC) - cc->contended = true; - - cond_resched(); - } -} - /* * Compaction requires the taking of some coarse locks that are potentially * very heavily contended. The lock should be periodically unlocked to avoid @@ -447,7 +432,7 @@ static bool compact_unlock_should_abort(spinlock_t *lock, return true; } - compact_check_resched(cc); + cond_resched(); return false; } @@ -736,7 +721,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, return 0; } - compact_check_resched(cc); + cond_resched(); if (cc->direct_compaction && (cc->mode == MIGRATE_ASYNC)) { skip_on_failure = true; @@ -1370,7 +1355,7 @@ static void isolate_freepages(struct compact_control *cc) * suitable migration targets, so periodically check resched. */ if (!(block_start_pfn % (SWAP_CLUSTER_MAX * pageblock_nr_pages))) - compact_check_resched(cc); + cond_resched(); page = pageblock_pfn_to_page(block_start_pfn, block_end_pfn, zone); @@ -1664,7 +1649,7 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone, * need to schedule. */ if (!(low_pfn % (SWAP_CLUSTER_MAX * pageblock_nr_pages))) - compact_check_resched(cc); + cond_resched(); page = pageblock_pfn_to_page(block_start_pfn, block_end_pfn, zone);