From patchwork Mon Aug 26 04:01:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13777060 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 3F1D5C5321E for ; Mon, 26 Aug 2024 04:01:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CCD156B0359; Mon, 26 Aug 2024 00:01:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9647E6B035A; Mon, 26 Aug 2024 00:01:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 603F16B0359; Mon, 26 Aug 2024 00:01:42 -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 33FA86B035B for ; Mon, 26 Aug 2024 00:01:42 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9B9ED160B2F for ; Mon, 26 Aug 2024 04:01:41 +0000 (UTC) X-FDA: 82493047602.11.FC79C61 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf05.hostedemail.com (Postfix) with ESMTP id A44B710000A for ; Mon, 26 Aug 2024 04:01:38 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724644805; 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:in-reply-to:references:references; bh=5q8+qACHJBaqY5ESz9bVG/3j80TMZe/EJH+sGR4xddM=; b=Oreymt2l7/qvzfXtwm+1C/ndpJZv2LQSvkN5WtFeUMvB4MsV5yTBVKtUMpNRyczj3V1Z5R sT3JKq+8Kh3zSBe9xJdRRzl0Ye/EONIsl5SObtuSkCiF7kB155U05Se8JhZbmxDyVeseft O4lRJEYNT5KqR75HQ9e+BKJB8dnslmQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724644805; a=rsa-sha256; cv=none; b=ZnHXCXoui8vnGO+C91fwvUHwRA4pc1grCVXgoLU4HWMCDyjwOP+y7KAbY0YZJqd1CHfz3T owSzNehQBxn1h9jXuSe1VCFJq4d/xnRPwb1OLMAByjW57M9LldiIdrKu876tpEz11RXHe2 nqRhYiWpW2qAfDaoiw1QTyhww81xR7M= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4WscNB0nJ2z1HHMr; Mon, 26 Aug 2024 11:58:18 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 5BDD014022F; Mon, 26 Aug 2024 12:01:35 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 26 Aug 2024 12:01:34 +0800 From: Kefeng Wang To: Andrew Morton CC: David Hildenbrand , Matthew Wilcox , Baolin Wang , Zi Yan , , Kefeng Wang Subject: [PATCH 2/4] mm: compaction: convert to folio_isolate_movable() Date: Mon, 26 Aug 2024 12:01:30 +0800 Message-ID: <20240826040132.1202297-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240826040132.1202297-1-wangkefeng.wang@huawei.com> References: <20240826040132.1202297-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A44B710000A X-Stat-Signature: gmnc1ijg1gj7k7h6re1cnzz3jn7sudor X-Rspam-User: X-HE-Tag: 1724644898-183026 X-HE-Meta: U2FsdGVkX1+Q9XRXD7mJxx6LMM20z5thhRsmlq7hUPJf0X1dLXOj9rSrS+w0tHJE/0uTo5MykS0H4nrj8Bh0jfyosl2Q8apeO6iIrdhEzvlIKU38Yodd70MV4GyZnpg1y2mtwRM+onNXSnJx3B9f4Rs0EGgPfLDBUvKRO8yh6BMb3IGOFAqj+wEpDZHZUWY+TNfK6nJUKDMeHZbNgo8NNW1XKimNl1NwxR153chZoiySHnsEohFBPzFwFMOzbkAb9OTQrPzy7u4ozZiRin1a0Ho8+0TE4bSIzmRK83PADlxxmp4ZlEjjbOjuLkTSjW3K6Bn/59OG9ncPnBvnxG+Mv/pdw2QUB3KwtmALqPYDFGTdqGeoQEnKlh5177OmEzFekc031lX5htSQzenKRmg37l6ORppIJLt7f7eP6ZUn9o78EicGNoAUMlhBbX1j1BlGI05vkxJs/htgfvOCuZ2Ar4lO1p7e/p0gdWuF+JyKlkV7k5kNuUAoMS2ZrtqsYYCq22Dp0SQGh4EVaIyf1+G6XNKb1uVyj9X68IJgLm2OJRUIq/Y+PaMY1CgiEYn5MAWPAn20foQXn9jEq1078IeIOkmieMlgyeH7s0aH2G0uAjSc7noWc8Ury8E8E5fOwJDJRIx8jxiIVLohnT4ROQToi12uNWg6WYpQWWWAep2PVU20IF849oflcudaFMrSYGAo0o41StIRm1TdRg1ijdGGiALsBc0GeTuNHhVTKCfWqPctmSoewVFb1uTjV20UPkVipX84sJckGTIgHqINQob1LEuP3EmuN+l6HmzMGRne1kleW13tV2o6IcpTNda74J8IvkDFrl49hkjCWfrR/L1cmpjbAa/aepMWOoVJAoxQ3zLm4nVD9EdmBlt9JV3ykDgOrlZRZeIsCiB1EwEOeD2J6FzMkfV/ENzpS0wcFSJLhADRrRFNjUpRoHUdH7NYcJXaNYeBfNBytgIBRTgPdSd D2wDjqlG MkdT49EtWJhDnhGFQ3BAMAY2prvZuo5QXnQks01u1dPAhuw9Byss0QN6zKKXlr8oig/HjVzs6Zfk1VNyyk7JRai2b6HCYeEHPcGSXkcs2qPTLTn19qy7SU/dFkCMgFjp//9Zvo55sLUx1+JKR1Vp5WzKH5L/Kx23g4X80hqx7f8nAUxUy4tKkyTelQyPiursryObs 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: List-Subscribe: List-Unsubscribe: The tail page will always fail to isolate for non-lru-movable and LRU page in isolate_migratepages_block(), so move PageTail check ahead, then convert to use folio_isolate_movable() helper and more folios. Signed-off-by: Kefeng Wang --- mm/compaction.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index a2b16b08cbbf..aa2e8bb9fa58 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1074,39 +1074,41 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, } } + if (PageTail(page)) + goto isolate_fail; + + folio = page_folio(page); + /* * Check may be lockless but that's ok as we recheck later. - * It's possible to migrate LRU and non-lru movable pages. - * Skip any other type of page + * It's possible to migrate LRU and non-lru movable folioss. + * Skip any other type of folios. */ - if (!PageLRU(page)) { + if (!folio_test_lru(folio)) { /* - * __PageMovable can return false positive so we need - * to verify it under page_lock. + * __folio_test_movable can return false positive so + * we need to verify it under page_lock. */ - if (unlikely(__PageMovable(page)) && - !PageIsolated(page)) { + if (unlikely(__folio_test_movable(folio)) && + !folio_test_isolated(folio)) { if (locked) { unlock_page_lruvec_irqrestore(locked, flags); locked = NULL; } - if (isolate_movable_page(page, mode)) { - folio = page_folio(page); + if (folio_isolate_movable(folio, mode)) goto isolate_success; - } } goto isolate_fail; } /* - * Be careful not to clear PageLRU until after we're - * sure the page is not being freed elsewhere -- the - * page release code relies on it. + * Be careful not to clear lru flag until after we're + * sure the folio is not being freed elsewhere -- the + * folio release code relies on it. */ - folio = folio_get_nontail_page(page); - if (unlikely(!folio)) + if (unlikely(folio_try_get(folio))) goto isolate_fail; /*