From patchwork Thu May 25 12:54:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13255186 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABA30C7EE31 for ; Thu, 25 May 2023 12:54:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFF9C280005; Thu, 25 May 2023 08:54:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B111B280002; Thu, 25 May 2023 08:54:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C879280005; Thu, 25 May 2023 08:54:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 75366280002 for ; Thu, 25 May 2023 08:54:25 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0A19840AE3 for ; Thu, 25 May 2023 12:54:25 +0000 (UTC) X-FDA: 80828770890.06.3DD1CF3 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf06.hostedemail.com (Postfix) with ESMTP id DE35718001B for ; Thu, 25 May 2023 12:54:22 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf06.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685019263; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mn3fhMFcaTYsz7UQ9NrJ1DjTrAq5Xs3DKzZTvyhCQfA=; b=xYdWGzIbJmlTiPa2ERWWiY6W518IAx2Au/+WYl0xJ1inLAyqr5t+g48olE8oWFFrqudDpL eq84AiPNot9Aze87SSZuHEQmUAnYmp0UL0efilThSOGQd5OF8sb6uY+ChR3mWyjrDLkcZp lFW07uaKbtl+iB2tVQwumU1lbmb7Mvo= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf06.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685019263; a=rsa-sha256; cv=none; b=clqOlLOJokGQlgw/gHYydL5cmNaqGV8U9DI7IIX5DqWCPQjuOTmtGBXmerlpaZIJZ1A7EP +ODmKHdUeRjdCMOysfSuFz7eYANGtbdVV0nFsPspWwMnKxTIWkYvZJJUHhHIZv/aacUffv ambyu94CjoN6dyuO694cf1+fXdhYvsQ= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R711e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VjSJ3iS_1685019256; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VjSJ3iS_1685019256) by smtp.aliyun-inc.com; Thu, 25 May 2023 20:54:17 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: mgorman@techsingularity.net, vbabka@suse.cz, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] mm: compaction: skip fast freepages isolation if enough freepages are isolated Date: Thu, 25 May 2023 20:54:01 +0800 Message-Id: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: DE35718001B X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: uhdo1qib7rgc4qgx58cdkhnmtpo8qwjf X-HE-Tag: 1685019262-160674 X-HE-Meta: U2FsdGVkX1+ii7sf21HvGjGYhA4PoTogKUuk/DNF2XIQRKK9nhKG2aGX9XWMhVyoZ0NhhFEIMiuf+KzIGZ/MyhTK7sGqJdl4PgvmEWhbqi3MtAMxu1Bj89ifC1LjUF60d+z5oEU4mKTl7tX0Y+t9CgDNvXKI3YJqwX+/jkpLPFIrIUvrfs+KMCoflHcdXQkCkIzMeQEAlHEOS4sDTPQY5HiRnqCCBdyHsTRyipzv8T3Ki6ok0Mg6P9Rn/GJcO9V2HHo/iy25AojnNi0xoG3a+b2g2XGmmGu7WXPi1YaET9tyAgAjcIIbrJeAWDichHh/RNiMFMxV4XNuZNhg7XjiCL8M8HF11+b5yMfdlpMMdM5zBlw6rux2XSxIeknQe7G2+8YgDgQhGzaDDewrW9dIiJeHWcAaIRb4hFr9QlXsUA9o6TZOH6CJEzz158EF/pvXpdzjoYlMjormK1RcaSUxsoqN98hLQebLuxDtXf3VSHN2IvIbILI7W/oe7moQddEdLNUMB/+O863rU8kTnp7qNtXeS0wxYuigFSvAXJxuD6ORGI6RUKNo07izPpZkoblt1vQq4WZbcNFtUQlfwp5xK7yubfHa6N8ZkWU7xGP/mVyRVDkUmnJEwxZJhIMDICHl8BBVWhMhYowZdUHPOfYpZFafJIAsW2hb02t0/YTYSa1Fkfj1KCQQh+3e1DTFR9CFEGqJFwMqHxdoG6DzW7mjwyRYZjZVXPIhwCIohIRWo7Wo6yY6ZiUa0P5d/RsVKEK5f4KIgFAc6VuwxA9eahdb4WsmxTTjulEd93k2w3h+rJwL5lBblUDyOY0zLS93RlWwINoXmXclnBtuApOgfCQ2u0uYhTzQQaLVM1vzHlcvDIL9BdkW0mGa8/WDpxARYHsferiswTdwxcOXnYq2zp/YOOtafYY5dXmwvTbzLUr/B+cSAdGDc22AUbBSEsq+skkzpoB8sP/r8hd4ciqILGq w/pmZp2C 7Oo/9kkqKI+8svy8IcFNAya2JqzSbDZtq+R06Dg8je4ztre0fFq34gtnC7u6k7TOOP0wT5GW/uY2fyLgKz3u08EnDiw== 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: I've observed that fast isolation often isolates more pages than cc->migratepages, and the excess freepages will be released back to the buddy system. So skip fast freepages isolation if enough freepages are isolated to save some CPU cycles. Signed-off-by: Baolin Wang Acked-by: Vlastimil Babka --- mm/compaction.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/compaction.c b/mm/compaction.c index eccec84dae82..3ade4c095ed2 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1550,6 +1550,10 @@ static void fast_isolate_freepages(struct compact_control *cc) spin_unlock_irqrestore(&cc->zone->lock, flags); + /* Skip fast search if enough freepages isolated */ + if (cc->nr_freepages >= cc->nr_migratepages) + break; + /* * Smaller scan on next order so the total scan is related * to freelist_scan_limit.