From patchwork Tue Aug 1 12:37:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13336648 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 06E3CC001DF for ; Tue, 1 Aug 2023 12:37:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 815E394000E; Tue, 1 Aug 2023 08:37:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C4428E0002; Tue, 1 Aug 2023 08:37:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B31294000E; Tue, 1 Aug 2023 08:37:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5A4978E0002 for ; Tue, 1 Aug 2023 08:37:46 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 22F3D120CBD for ; Tue, 1 Aug 2023 12:37:46 +0000 (UTC) X-FDA: 81075487332.18.6271D19 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf11.hostedemail.com (Postfix) with ESMTP id 26EA740025 for ; Tue, 1 Aug 2023 12:37:42 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690893464; a=rsa-sha256; cv=none; b=C39snJCqPN69WnrEKwSnqT/JWia+P3TI8eYReUO8g9XWP7z1j5QyLBZTz/b+QWjN94dFq7 AjDJ50UG+FE7P7QyK7YcGz7zRuQgtOyqVQezpJBI/5ChAgFvDBRCXOmRxonauTf60WIP9V hcn9CBWReQbHUzWvqa6TmXs60YCxE+4= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690893464; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=0O44SbHfMGw8JO6Nbs0MGiONaAsZsQXe4El4DYWLHwA=; b=kzKxzVsdIHNiFxN4XckWOWv27hIZkDBM9nHyBnE7xrSLc4FqzzmulXXiZzdKMS/pscl13z UwDReB/KuQo46otmPn7AClr3QOtO9M0oRo/mGErkpv+ykHTVUSJPIn+/KSm4ZS/Jqgy+Zu CK9al0izNanYsuUYLn8k1JXprqD3pJM= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RFZLk2jjKzLnyG; Tue, 1 Aug 2023 20:34:54 +0800 (CST) Received: from huawei.com (10.174.151.185) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 1 Aug 2023 20:37:35 +0800 From: Miaohe Lin To: CC: , , Subject: [PATCH] mm/page_alloc: avoid unneeded alike_pages calculation Date: Tue, 1 Aug 2023 20:37:23 +0800 Message-ID: <20230801123723.2225543-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 26EA740025 X-Stat-Signature: dph4db8eh161emmxyi5kdgeo5fgc5n6j X-Rspam-User: X-HE-Tag: 1690893462-2207 X-HE-Meta: U2FsdGVkX18ZDg9WEsno2v40wI0TzRujKu5hFxsVaiK/jS4JnWSG0mXdZcm41ITGGlNYm7dLSKKaJ/q4BG5n9cMsTUMyEEzNeD2z6EsnKK9QS3kPfNY2sssGUx9i5w98AXqOTlD6/xMj3/qndAUJzQlTYgHypwz0gVfM0rldIV0Gdf6phULZk0Z33nxuxz45u6I2QzbBN0931yH4JhaRFfWi6nWmF6kw599Rq0x6xSo5XHXFke6tCAUY4lYcMrCIeaAKVTUrn9qggV8XDmmtZWc8Mg0Y5xTNCaRjwa2//ppGNtOwZgRNQfwI0oDTTZ0I4XFJl9KGXLprdhu3576Q6Mfd7CGDNHrHxnsGt32ENpom5NOPunhQYIS3hXmhfLk6v4Ll2Q0zs4eKlPZhRSZEuwHOIXucXfqiOXp/WhWghxX5IVm1p2OpPnP83EpoocAZECy1lDRwboMacxknZXz/qU28ZtVvNSchaUtaqdRCmszPmMgau7C/gTqmMbjSVXIoZz5PhLYLKusiY3VV4cal3uc1KlOP8owHMD3rPYecEupiAqbU1lVZpNKG8MNnG50NuJc4ka4enJmufU/HaDm/Ub73RFA5OG9a04OtZFzUqfKUkaoINOGBmW7utFWRvj7FSW80e2itE5YzW2VxOM2jVr2Y/kdmM4FUU/fQMuAZLLLazfuXnAcPxCvqe9PvG1+7dBAL7yYh91caJSRziK2IXTWFZ7a7TaGlz3Ac9p2AzZLeUWOLIPuDX6Zr8nhZBrHtY7uximWmMWqblqP3tgdq/EZvTTmHStKW/7AoLaxb3HvUfEn8Pdsv7ma4jY8eUrr/Jg8ipG9tAaSWshEsK0hw9G03xX4Qy6Q1AIWKah5/LpFDtwaG9Dh4yuJfKegSF+GHMtzpcL27yOnTgXQpiaxOZcpl7bTg3Hq9aq/o9XOROIqnax3L0qG73CrltXqrYay1DRS+oslK/GvOVUZP5ZP F71EPfoj 0pma8Ce9yeGvbtepmGIa6L19qmI2a8NdOivZTZjddr8T1ZWrYYS8oN9C7CyhxXJf8CmIJhzebURPkmbinyOVEJxQoCe6ILxqbryaWh0ZqnNd6556kc8oQj529etT4OlZN5pVaZdsL2Wify5xWj03EejSIq/RiIESFtZ3OTvaUtEsZMG1AY8XO44DMHnL2HSG7T20m 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: When free_pages is 0, alike_pages is not used. So alike_pages calculation can be avoided by checking free_pages early to save cpu cycles. Also fix typo 'comparable'. It should be 'compatible' here. Signed-off-by: Miaohe Lin --- mm/page_alloc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8fe9ff917850..d7a357cb21ee 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1833,6 +1833,10 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page, free_pages = move_freepages_block(zone, page, start_type, &movable_pages); + /* moving whole block can fail due to zone boundary conditions */ + if (!free_pages) + goto single_page; + /* * Determine how many pages are compatible with our allocation. * For movable allocation, it's the number of movable pages which @@ -1854,14 +1858,9 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page, else alike_pages = 0; } - - /* moving whole block can fail due to zone boundary conditions */ - if (!free_pages) - goto single_page; - /* * If a sufficient number of pages in the block are either free or of - * comparable migratability as our allocation, claim the whole block. + * compatible migratability as our allocation, claim the whole block. */ if (free_pages + alike_pages >= (1 << (pageblock_order-1)) || page_group_by_mobility_disabled)