From patchwork Wed Sep 13 09:51:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13382700 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 49AE5CA5535 for ; Wed, 13 Sep 2023 09:52:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A598D6B015F; Wed, 13 Sep 2023 05:52:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A09366B0170; Wed, 13 Sep 2023 05:52:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F87A6B0173; Wed, 13 Sep 2023 05:52:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7DBB86B015F for ; Wed, 13 Sep 2023 05:52:07 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4E8BB1A0367 for ; Wed, 13 Sep 2023 09:52:07 +0000 (UTC) X-FDA: 81231108294.23.94EF529 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf30.hostedemail.com (Postfix) with ESMTP id 95DCF80011 for ; Wed, 13 Sep 2023 09:52:04 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694598725; a=rsa-sha256; cv=none; b=Puv9IplLyaybmaXMMv2q7kxz0vpwEP54z4/AAG8SRJJx840+wvBCt4W8dSFO58cqHbdycn PNJv3FTsdw9yslL1lEDARRhoIdTtapliOcBpFj1cMSKBxy5KeT+jbzDsFawxmG9jHMD2H+ Pfz9gXc4ya77wOX+2lFokjtXmFzgMyY= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694598725; 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=eGLAyF1TWl//bjKqzzehCYbHflfiv7bBK6GV2K9YRXA=; b=fF4MHb3mxYsZl2nXmSXqqqZE0xeOxCZVSpm3wQmJmP85hJoNfIwGnzOHHAOJGfaCGio6jx LOkAWK0c28twrOurgu3rwa61TVSEd7SqjXLH25sJXp7EPGPNGOFg5iFTZbYmYA07nrkUtY 0po2+QoOSXia5tEvBBG2mnMbbWP7DfA= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rlwcb4nlyzNnRl; Wed, 13 Sep 2023 17:48:15 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:51:58 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 1/8] mm: migrate: remove PageTransHuge check in numamigrate_isolate_page() Date: Wed, 13 Sep 2023 17:51:24 +0800 Message-ID: <20230913095131.2426871-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 95DCF80011 X-Stat-Signature: gai374no8oxdd7z4yfjkyzgo97oqb7er X-HE-Tag: 1694598724-837741 X-HE-Meta: U2FsdGVkX18cVJHLAZ29NlmWKEDwQbSgFzmB6tlWB6wltrJ6OLPGoJGuzYuxjqbQjphdR/2M6QCEn2bL2o01MlyEF4ebfRWeSrpAx29vZfkF+qc39svtgNLDGbjWpfy/hD+jYFyyezKQVkEpOvhBZcUoIJWGKk9hu3Oqf+vh4284ln9o+9dj9dDjyPDVBrRf8xT9wsZFK33dlNqTMxDnNyLqtRe5DdzKeyvAW0YvQq1S07AZ56T4xeOrdoSFkFLZJrhnFs0YO8vp4c0dy2ePiSrRr4fUmsLiUAChfGGk7/v/F/0i1A1dOS2PhjyD7T87oZChWTEN/VBqpzPcullo1lXei7mKL1Y5XTHBiyyCNdecbH+ndsX3qJTdSFyZlp+lT28hO6UoP+sndtz30DoPyks3bhGf3WZ2vSrUEusY3qUjVM94PNOitsY19ENxe/NyU5KDcgWrB6uYC7uWtQPUXf2fUA+T2GqTVuxIlkHrA53Vy924fA13q7eN03JMwzZ6SltuXYDuuYhG87q73pYxsXEe93riB7xUn759G1BKpX36d7+lWW7xPADjsOT+lO8rHjnoGpTYICBFIJaoVixwBK6uVcqG1Zz94h+Tvo0Lwedc+1o7IS3LGFNVCg/AXGzU2LzrcuXj5MQpKbsIXTFhl3o2JDPJtnfUbo6E1v2S7gg8eKtSQcKYTaeR6w3lRNuTVMElJrshlyTN+v7jKU/PK59XLDmQeUdJBxAPSMjijX5LjARBMfjNgSrLw0mz6OCorCDFfYEMRxYUI8Ss7VZp77a2yPXJR8wTGxx2QYcUsvP+Z6jNer8641xlmEJhDARpW/El6s8zma6YbZNL9B8aV7lWDLsVO3sFdB06jxodgD4GZxQ3QvHS3EljeR5gDbhWMXbu0HAYTP21ydRHxoiSI3K66u+EQYCK5LwCoQDV2657DpXZnVYax/2m2pcOC+O1tQsQpjYWQUawefp5wvt KDLvuppx j+fd2kgYI3VhswKRKtMaVHA5Cl+06hfTon4sJjh+JM7lU+5SJRxlW37bqwHUxPlAC0GElVXmt2nIrt8/15k8A1BdhoJE02YOBYUcNnTHa4cqNBcLsNbHJcgCmJl77IIoa08DXnKWchZwCm2y7geKYkNv1RexLX3czJ66XfJsKouMDdTcajag08JcYbtFPRgQHY+rR58SmGWdLaijvL+UKT+i7AdaWIw3gVd8CjDdxjk4qMk8FHhNKXbzIVr/WL/c7Gv31 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: The assert VM_BUG_ON_PAGE(order && !PageTransHuge(page), page) is not very useful, 1) for a tail/base page, order = 0, for a head page, the order > 0 && PageTransHuge() is true 2) there is a PageCompound() check and only base page is handled in do_numa_page(), and do_huge_pmd_numa_page() only handle PMD-mapped THP 3) even though the page is a tail page, isolate_lru_page() will post a warning, and fail to isolate the page 4) if large folio/pte-mapped THP migration supported in the future, we could migrate the entire folio if numa fault on a tail page so just remove the check. Suggested-by: Matthew Wilcox (Oracle) Signed-off-by: Kefeng Wang --- mm/migrate.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index b7fa020003f3..646d8ee7f102 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2483,8 +2483,6 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) int nr_pages = thp_nr_pages(page); int order = compound_order(page); - VM_BUG_ON_PAGE(order && !PageTransHuge(page), page); - /* Do not migrate THP mapped by multiple processes */ if (PageTransHuge(page) && total_mapcount(page) > 1) return 0; From patchwork Wed Sep 13 09:51:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13382701 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 84196CA5536 for ; Wed, 13 Sep 2023 09:52:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F6D56B0176; Wed, 13 Sep 2023 05:52:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 17EF86B0175; Wed, 13 Sep 2023 05:52:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F38FD6B0174; Wed, 13 Sep 2023 05:52:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E543F6B0170 for ; Wed, 13 Sep 2023 05:52:07 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C2B8480293 for ; Wed, 13 Sep 2023 09:52:07 +0000 (UTC) X-FDA: 81231108294.18.0ED1139 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf15.hostedemail.com (Postfix) with ESMTP id 8D3F6A0035 for ; Wed, 13 Sep 2023 09:52:05 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694598726; a=rsa-sha256; cv=none; b=DcG99iLGgKG7R+pFl5toywaieVvRTvu5Arc62mI1Qz2cendvia0BKefQfyFfP+nmy7y6WO wmf7sj+UXXWpt0fT6X054xc6uqkjrEVKj4EFMAnKc1Fuh7JKfg/23XkbGnO35GakK6Rdq1 1xNc6JMZAE6wgvHDRvZgpwMRekqjTRE= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1694598726; 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=CWyPKwL02nbvAgHk+hv8KgCviWU/Da8QA7ydynsElH8=; b=j/BeCVBBxDehE+OzaDTtyAh8v+C61uIMSuzjiT6/ZJ3jmW6/p8Mj9ljLceZtv6MCNW+ZAL ICZ3VjOzCiLjEJZGxmXu1jIuYEPYJuzW3kD9E4FiF32L10Yq2G82qp48C70BTkCD44AkWa RZ12+3XkvuPpFMdIB114WWstX8hOKzE= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Rlwcw06PkzMlGs; Wed, 13 Sep 2023 17:48:32 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:51:59 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 2/8] mm: migrate: remove THP mapcount check in numamigrate_isolate_page() Date: Wed, 13 Sep 2023 17:51:25 +0800 Message-ID: <20230913095131.2426871-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 8D3F6A0035 X-Stat-Signature: zmaws7mqckpiadip9un3qwuy8b5mcoz8 X-Rspam-User: X-HE-Tag: 1694598725-80872 X-HE-Meta: U2FsdGVkX1/49XRCfkYTiLLQ/6ir7ynAZFEitkIIMu7w3kPYr/tDZMiqVbgKVYD+K7qL896dH0XdjiKGzK61LneaK3zbhHVcnkVqlm1lVd8ENb5akSD7tVIMHCfglckSqh1q24Nh8C4M5OidQXcSvldReHJtGZj5O91tJ6Lo4hTuU4ojZzUMDrgnp4QpSNzB6W6g2y3w/YMaDuQC7CSZHFDauXefysNTCHltyQ7E87LexEJZwgUAtBz4CIffZZesocXE9go+14E0T7/i/cmPWftmM+EQ57YBxQclu4hMJ9dE7DjWA1IfYFAxlmz41xe7xOqjxH2pMVjvjYsciGzr6pLE0Elvd6918FNciDpWpvHid8bjrRd8U5r4zjysf7enA/yZn0KkdgL5fiMGIWHe5CQzqZ33I9pNl4l76Z/LVZcpuyiHazsMU2ySqOnmbtinvMkuHLmxWbqyz8IglFbRTmBpbxX00L4Y4rbozI/0WW35wZDZAhzW6Owb0zGmZ9VU1egyLo04n7N9i0H4yBjvnRy5TB5g5Uc7iXeu408eqK8AEjwDvY71KPjuVHU+9CuHPHxup3t9qvPM927YK9XQw29Z4SAS0WNYM3zo7lVgaEAaTfaf3gvfzLCbPHkbv8CiKYiCwrYu9arNQiGnJqgBvZsMNcSbxkMSJgA5YQ8bNdzcCdbrOqND642jaSpSm8iSkRpZ5sanuE5AfXVFANg0okpCneCm5mSY2I/dJ9cdOb9rZkKeeR/bpe3K9T1uHbzfSCKrqHs+i7dDqdUoGvPsU0FinjqQIN2vQLkDNR7obaHACm+cnTj2OHMm6rvA83+bGPB2BGT1c2mmoUBw8slZk9tpvcYA6KTqZlzMbRpYSoNZqFJrONT87Fce40Yn9ttpUQV29pBoHKWclsHehEGJntH7YuRxNVNVKSa0grtYxLK6s54RSU9e5WNiSZsDSBeqlEKduQROpVZCpSVHPZl it1BrJMY LIYvB+R2bV4NmbqTsBPQvyrpLaEKbcu0NCCOo7n1PFVlgrcS9RXiggispNlRW2FKuwMS/nrXv+zYQc8DKZpQQkJ/MJRAryBdSlByJdRpwgkzwff81GdNmpo2cTh6t+KpW+jpJrZoR0e4r4cHXe1vfMbMxSnWOPiVkySLDXTcF2wYYS1G2nR5rBueEOwB6tWb+amdUb9ow8lSince3egFAxrc5YK3dgXdSUvf/Yo7DWQMtzKPSepUc6VGAJUWdVJwaACoMJkvgxIJzYxq2cGQAek2hUw== 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: The check of THP mapped by multiple processes was introduced by commit 04fa5d6a6547 ("mm: migrate: check page_count of THP before migrating") and refactor by commit 340ef3902cf2 ("mm: numa: cleanup flow of transhuge page migration"), which is out of date, since migrate_misplaced_page() is now using the standard migrate_pages() for small pages and THPs, the reference count checking is in folio_migrate_mapping(), so let's remove the special check for THP. Suggested-by: Matthew Wilcox (Oracle) Reviewed-by: "Huang, Ying" Signed-off-by: Kefeng Wang --- mm/migrate.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 646d8ee7f102..f2d86dfd8423 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2483,10 +2483,6 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) int nr_pages = thp_nr_pages(page); int order = compound_order(page); - /* Do not migrate THP mapped by multiple processes */ - if (PageTransHuge(page) && total_mapcount(page) > 1) - return 0; - /* Avoid migrating to a node that is nearly full */ if (!migrate_balanced_pgdat(pgdat, nr_pages)) { int z; From patchwork Wed Sep 13 09:51:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13382702 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 94683CA5534 for ; Wed, 13 Sep 2023 09:52:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 440876B0170; Wed, 13 Sep 2023 05:52:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CF046B0173; Wed, 13 Sep 2023 05:52:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F4BF6B0173; Wed, 13 Sep 2023 05:52:08 -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 0473B6B0170 for ; Wed, 13 Sep 2023 05:52:08 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C7ADA1CA9F0 for ; Wed, 13 Sep 2023 09:52:07 +0000 (UTC) X-FDA: 81231108294.15.5C23322 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf06.hostedemail.com (Postfix) with ESMTP id 92BC418001C for ; Wed, 13 Sep 2023 09:52:04 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1694598725; 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=XimLV5Z1rXezPIZu6awNd81iU32QlWiaxWWjX2F1Naw=; b=Z1Ey8Hhkw14ve+o9C++aardRRT4Tdkus4o4QB5OoW74clV9wtwTM0VkvufFja9RVLX4YQu ADGnBs0K2Zdj1kDjGntMFIFFvQVCQOyRgmlV+MknuXMJhi8gTgLZSeVYfVmVsk+FEa2Nrk dpMclESt2W1R4iTT4qCGN1WT5WFeamY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694598725; a=rsa-sha256; cv=none; b=ubn9iV5ECJwuyvd8G8wtroaJfswLIPlNSUDxfLIO2nVcOPPrZzJAHZ91yoZPmoFYdyiGx5 jfiSgn2vIHFPe2aLDosNTfwp8KJhOqjKNbzB+aZ5EE2LcHklSgRhO+S29iYLD5iccZ1wqE uOEUyIb1QyFvmsYgP4hasJevnmHB7GI= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Rlwcw44lpzMlHJ; Wed, 13 Sep 2023 17:48:32 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:51:59 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 3/8] mm: migrate: convert numamigrate_isolate_page() to numamigrate_isolate_folio() Date: Wed, 13 Sep 2023 17:51:26 +0800 Message-ID: <20230913095131.2426871-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 92BC418001C X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 459k6hm59mpc1brrmgfdtffj1sk64jwp X-HE-Tag: 1694598724-24299 X-HE-Meta: U2FsdGVkX19ijG1B+b1QCa+u6wG1qlgdjkFgqCdq5umMEz6pkPVR48bcwlU6776FDdtQnX52zzDZBzznB+29iZQOrV2rTFrPwGBjyGYeHbgiFPNZK5pgeblIh/SkP0JC4aUQSNcVAABj7d7nxHCqjigSSSXXj6LsQIOX67w199k8rKQJQD8t4vdpTcxhBW0B/r4dwuWjFjWQw/G0QpPleml1ZL39TdWXHY9Wg6I1ola+IZu62ZGxsKT/swwnlEz6ByKInIKE47sqrmJGqfO0zrhBeRTrzwYlnr6JrA9NG2LOtSa9WB+upOLEIWi5wGHnlEpww/lNBJ24YVsgtDE/q3VIVZP30ko59woc90dtp/rGgVo5ab5FXJAjt2rEEDsFYH2PAgRSLFRwkYm71ffCJwouyfJSS0xuBS7ii63lCuFagwtjp2wN+NRYsdKBKd/QJylv2h5rzPeTfnucNStU9m8mCBl2u+LMlBRgJENsG8YMsvNiqO3HsiUHZrRaUu/9geofrMIN7h+8f/cPOnAVYb0ZQ+UOEbY5OULNpFYE2mffQ7HEiZlRxmyh7Y5k+IZoirHzMGB257ocyvm7YOihaNUYyo0d0gMlemFaFbv5yZ5/bxtrh8W418Wsnexx1U8ugGUty0LEMI2TcxFH8ArjJaovSb78PHuhL2FkVKfMHlZoK406pGm7wweegV6cIYlJpKClfkLvS8PqJJh0t5Co9Cie1eHuWuBMfpInFWkRWKYgw/ia2GsAslr6lWuciCxA2tBg8VfHoTAY1+XUC2eF/0QDs4o3bP02DyclLokRooullot8f16zWKs3byYwq9G1UqOBokfVuUXx2gmOfMzY2PPOZjKN83H2lwnSDZOrRZD9tf1U4GIe/OSOc0avvJp45hyR4obeJUlTztlxCFRByTIOyzVupOed3B1VNHc/cSx7Z9Kfu26E04AjpFba4XV8q06XGA2EOK6qZBrKLfA BDHik6+B RdzM5XzlbztikjKCsAEj5Jd2iJFeZrotjbWdzFi/14WTCbQ+m0RXAOlwqWh1GPQqoiShos8k9eXDRdCC65+ilsFNNms6L92Zn7QMqSdH/vvGsi7vhlCY5YVUomz/6zbhIeik/cAzNZCeWH+JH8tfEEwJ+14cBgMpajRTK1Tu40c7mJl5wbPbcjOF6nnfONIU2OTbi3YFulb8Wrd0xjCZFQRF1/g== 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: Rename numamigrate_isolate_page() to numamigrate_isolate_folio(), then make it takes a folio and use folio API to save compound_head() calls. Reviewed-by: Zi Yan Signed-off-by: Kefeng Wang --- mm/migrate.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index f2d86dfd8423..281eafdf8e63 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2478,10 +2478,9 @@ static struct folio *alloc_misplaced_dst_folio(struct folio *src, return __folio_alloc_node(gfp, order, nid); } -static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) +static int numamigrate_isolate_folio(pg_data_t *pgdat, struct folio *folio) { - int nr_pages = thp_nr_pages(page); - int order = compound_order(page); + int nr_pages = folio_nr_pages(folio); /* Avoid migrating to a node that is nearly full */ if (!migrate_balanced_pgdat(pgdat, nr_pages)) { @@ -2493,22 +2492,23 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) if (managed_zone(pgdat->node_zones + z)) break; } - wakeup_kswapd(pgdat->node_zones + z, 0, order, ZONE_MOVABLE); + wakeup_kswapd(pgdat->node_zones + z, 0, + folio_order(folio), ZONE_MOVABLE); return 0; } - if (!isolate_lru_page(page)) + if (!folio_isolate_lru(folio)) return 0; - mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON + page_is_file_lru(page), + node_stat_mod_folio(folio, NR_ISOLATED_ANON + folio_is_file_lru(folio), nr_pages); /* - * Isolating the page has taken another reference, so the - * caller's reference can be safely dropped without the page + * Isolating the folio has taken another reference, so the + * caller's reference can be safely dropped without the folio * disappearing underneath us during migration. */ - put_page(page); + folio_put(folio); return 1; } @@ -2542,7 +2542,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, if (page_is_file_lru(page) && PageDirty(page)) goto out; - isolated = numamigrate_isolate_page(pgdat, page); + isolated = numamigrate_isolate_folio(pgdat, page_folio(page)); if (!isolated) goto out; From patchwork Wed Sep 13 09:51:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13382729 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 E646BCA5531 for ; Wed, 13 Sep 2023 10:11:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D25E6B0170; Wed, 13 Sep 2023 06:11:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 581AB6B0172; Wed, 13 Sep 2023 06:11:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 470406B0173; Wed, 13 Sep 2023 06:11:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3876E6B0170 for ; Wed, 13 Sep 2023 06:11:46 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id ED9B1140A9A for ; Wed, 13 Sep 2023 10:11:45 +0000 (UTC) X-FDA: 81231157770.17.DCF82AE Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf21.hostedemail.com (Postfix) with ESMTP id 8A1C41C0017 for ; Wed, 13 Sep 2023 10:11:41 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694599904; 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=qs+4Pob6hE6VoMIGoj7d8hZIC1kd6o6kgmZoesDjY7M=; b=BCt7QqPncINNsm6yb7GuIYN7aiNcn3wZh+LRgYESgygPCZ1c1ZlF5nA82rhcTSGm9gl6Vx V8u2G/RJ3uJCWTg1I/Q11jXzW2jtK9C3iYFleAalsdifdLL/twwhXo6W7b6LeXCYJUPc8r w8xdYd1+TPaKN8RE1c5fVFgNsKY/q8w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694599904; a=rsa-sha256; cv=none; b=anowxMkfvFFtdS3AflX3HwT8V2m1k8QrDxM8kM42o4iALQNCvIRVJorhHqgchh0E+Nv2nD rMAjtCTzDFDYI0Zf42INiAKx4v4Kv8j0pwVcWFyU4UOOF7iJZJN184jD/5atBLDqUaY7+Z cdu/a/hlZ4vJ0S0g2OIMb/cBmKeTkDg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rlwdj18sgzVkgC; Wed, 13 Sep 2023 17:49:13 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:52:00 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 4/8] mm: migrate: convert migrate_misplaced_page() to migrate_misplaced_folio() Date: Wed, 13 Sep 2023 17:51:27 +0800 Message-ID: <20230913095131.2426871-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Stat-Signature: 4baio6ycucsedr47rm3rt9e9yqw3c5d7 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 8A1C41C0017 X-Rspam-User: X-HE-Tag: 1694599901-798059 X-HE-Meta: U2FsdGVkX18dSEm8S0/2ubn8LV1KYYvgNlLtR2FhpRsB8Ry9ti1JmMSWUcWcdSwyKLJ+XH2ILTdcUfvzxSqfZ6GG4iTsnzSb1F7yAJbhs9/9rqoB0h5NRUEvA2aNWRuNaiB3ZtGP5nmR9qqlq9mfuSOJMNW67ldkN+l/i7h02w72grCnpidxBdQfU7fbr1MPFNxyijd6ZJa4ufQu3QrHTHGBGxvPN6WYmp/RSSNj5+CTBVC9IwhITc3zYCRu62epVSdBfD+gsoxLq5w0YTArrbZ/ajFXedMb40FipoSJhV/PIvRE/9etoGeAdGS08NX3wuQl0h8QOVSJP5Y0G3Tq7QqJyMiwzPMvhH8P5g4w7gkekStRXrKtJN9WZy8/f83LqXZIF/LpUaIrN/HlmFaA9I9BzxYXS9jFZGYdXq+9yfn2AkB6ic3ctT0ir/RQ02ReIQwutgFDP8FeASbu0TTWI9w2+Jek+5EGAi1ARTWkmL5GIYIPtKt+sBOFxpKHBOHh24fTnYJRBncRLa2ODP5OgdXhXepcz09sqcKiI/RJFuwwu/6LQA9Uv15RfTTF6wsRa+6FQZFDY0aSk3Mc3166/HNmWjJiUmkKKMwKmfecTuP8A55jVErKNEjBYxViaf1sSnlisHJ7bYHKH/0xtPJKzMDCN+S3qo04k13Mj41MzxBaiOLlqIS8ayqZnHA5nuumPSyHtJUjWllctZhkyH6d19oAl+TUuLh+Kww47rNR/j+m13SBraGtXO8K/dtTdYO9Kd9tDf/dACz7i/5aWtRkpAV+upr5tnWmNIxJ/HD3WaKX377zG4CNF4O65OPSldsxB+oesM4sWJP/uVLhQEKgZmoVxqWkICNAS22ZW7K6/SoXpBhnoOm1R78GgD51GB9jVVGnvuZAU1vtGnZVA5eZ6yAUAzRaRHgSHlLQq4F7hn9a9aJs/ZsTP/2LXTY4muF/NVLQZjJwllrXtCDAFds VeCWxy0r SlrjLXwZLXg3Ue/WDtMolxMmTMAJjdmvvIJwVs+mfr5sOZpR/7XE9uEvELIJao5JzGiVIj3NWvtKKXyktt4KHPv85yLJA0ulIL5OMNm/dCkesq0wurgfGkdCcuF3AG9f9VNzgfIb3l1898rbLjCOFQA0RMBvL3tpA1AQR+GPv9CoMtpdRkPIJHiEqQdRQUrPR8Um0uaguSSmXUyZPPwMtcs+zdg== 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: At present, numa balance only support base page and PMD-mapped THP, but we will expand to support to migrate large folio/pte-mapped THP in the future, it is better to make migrate_misplaced_page() to take a folio instead of a page, and rename it to migrate_misplaced_folio(), it is a preparation, also this remove several compound_head() calls. Reviewed-by: Zi Yan Signed-off-by: Kefeng Wang --- include/linux/migrate.h | 4 ++-- mm/huge_memory.c | 2 +- mm/memory.c | 2 +- mm/migrate.c | 39 +++++++++++++++++++++------------------ 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 711dd9412561..2ce13e8a309b 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -142,10 +142,10 @@ const struct movable_operations *page_movable_ops(struct page *page) } #ifdef CONFIG_NUMA_BALANCING -int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, +int migrate_misplaced_folio(struct folio *folio, struct vm_area_struct *vma, int node); #else -static inline int migrate_misplaced_page(struct page *page, +static inline int migrate_misplaced_folio(struct folio *folio, struct vm_area_struct *vma, int node) { return -EAGAIN; /* can't migrate now */ diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 3e9443082035..36075e428a37 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1540,7 +1540,7 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) spin_unlock(vmf->ptl); writable = false; - migrated = migrate_misplaced_page(page, vma, target_nid); + migrated = migrate_misplaced_folio(page_folio(page), vma, target_nid); if (migrated) { flags |= TNF_MIGRATED; page_nid = target_nid; diff --git a/mm/memory.c b/mm/memory.c index 4c9e6fc2dcf7..983a40f8ee62 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4815,7 +4815,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) writable = false; /* Migrate to the requested node */ - if (migrate_misplaced_page(page, vma, target_nid)) { + if (migrate_misplaced_folio(page_folio(page), vma, target_nid)) { page_nid = target_nid; flags |= TNF_MIGRATED; } else { diff --git a/mm/migrate.c b/mm/migrate.c index 281eafdf8e63..caf60b58b44c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2513,55 +2513,58 @@ static int numamigrate_isolate_folio(pg_data_t *pgdat, struct folio *folio) } /* - * Attempt to migrate a misplaced page to the specified destination + * Attempt to migrate a misplaced folio to the specified destination * node. Caller is expected to have an elevated reference count on - * the page that will be dropped by this function before returning. + * the folio that will be dropped by this function before returning. */ -int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, - int node) +int migrate_misplaced_folio(struct folio *folio, struct vm_area_struct *vma, + int node) { pg_data_t *pgdat = NODE_DATA(node); int isolated; int nr_remaining; unsigned int nr_succeeded; LIST_HEAD(migratepages); - int nr_pages = thp_nr_pages(page); + int nr_pages = folio_nr_pages(folio); /* - * Don't migrate file pages that are mapped in multiple processes + * Don't migrate file folios that are mapped in multiple processes * with execute permissions as they are probably shared libraries. + * To check if the folio is shared, ideally we want to make sure + * every page is mapped to the same process. Doing that is very + * expensive, so check the estimated mapcount of the folio instead. */ - if (page_mapcount(page) != 1 && page_is_file_lru(page) && + if (folio_estimated_sharers(folio) != 1 && folio_is_file_lru(folio) && (vma->vm_flags & VM_EXEC)) goto out; /* - * Also do not migrate dirty pages as not all filesystems can move - * dirty pages in MIGRATE_ASYNC mode which is a waste of cycles. + * Also do not migrate dirty folios as not all filesystems can move + * dirty folios in MIGRATE_ASYNC mode which is a waste of cycles. */ - if (page_is_file_lru(page) && PageDirty(page)) + if (folio_is_file_lru(folio) && folio_test_dirty(folio)) goto out; - isolated = numamigrate_isolate_folio(pgdat, page_folio(page)); + isolated = numamigrate_isolate_folio(pgdat, folio); if (!isolated) goto out; - list_add(&page->lru, &migratepages); + list_add(&folio->lru, &migratepages); nr_remaining = migrate_pages(&migratepages, alloc_misplaced_dst_folio, NULL, node, MIGRATE_ASYNC, MR_NUMA_MISPLACED, &nr_succeeded); if (nr_remaining) { if (!list_empty(&migratepages)) { - list_del(&page->lru); - mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON + - page_is_file_lru(page), -nr_pages); - putback_lru_page(page); + list_del(&folio->lru); + node_stat_mod_folio(folio, NR_ISOLATED_ANON + + folio_is_file_lru(folio), -nr_pages); + folio_putback_lru(folio); } isolated = 0; } if (nr_succeeded) { count_vm_numa_events(NUMA_PAGE_MIGRATE, nr_succeeded); - if (!node_is_toptier(page_to_nid(page)) && node_is_toptier(node)) + if (!node_is_toptier(folio_nid(folio)) && node_is_toptier(node)) mod_node_page_state(pgdat, PGPROMOTE_SUCCESS, nr_succeeded); } @@ -2569,7 +2572,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, return isolated; out: - put_page(page); + folio_put(folio); return 0; } #endif /* CONFIG_NUMA_BALANCING */ From patchwork Wed Sep 13 09:51:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13382704 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 D44A0CA5535 for ; Wed, 13 Sep 2023 09:52:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3CB666B0174; Wed, 13 Sep 2023 05:52:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A2B36B0175; Wed, 13 Sep 2023 05:52:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21C666B0177; Wed, 13 Sep 2023 05:52:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0E1326B0174 for ; Wed, 13 Sep 2023 05:52:10 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DB9EEA036F for ; Wed, 13 Sep 2023 09:52:09 +0000 (UTC) X-FDA: 81231108378.01.1F947E2 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf22.hostedemail.com (Postfix) with ESMTP id 2F932C000F for ; Wed, 13 Sep 2023 09:52:06 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694598728; a=rsa-sha256; cv=none; b=6jpZU1lHeJkYH8508/nrsbR7u6cYae0xM/AEGJWLrRDtoHtK8jZhehFORBqOTcAEIAaI+E TimpYZ0xSKhasrGV0BLG3TajUVFLqkdghfXUfG4acj03A795j1Tgm3medlb/Wtm+NW05Jg pn/Tg6qLax7ZvDTJc2UeYLWEvFkQZWk= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694598728; 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=tynzkeTlgRE0TnuNJwLboivyiix4m9++Sswl3Rc9Qjw=; b=IU3Cyc0VRqoNX1jgguEy3CwVk4dVaxN3j3aQX0NyMKSBbHXmoNZRDesdjXtTAVFz8HGGr2 hlzF7EXH9rqOk7lGNb1cxzVwqRXZltmqHmGUSOch8dZJAwV3xMNeIxfy+tYIDMv5hpybqf US2ot60+FS1mNiKDzLPhXQtNEvmPFyI= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Rlwfh3mXTz1N7wJ; Wed, 13 Sep 2023 17:50:04 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:52:00 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 5/8] mm: migrate: use __folio_test_movable() Date: Wed, 13 Sep 2023 17:51:28 +0800 Message-ID: <20230913095131.2426871-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2F932C000F X-Stat-Signature: 1hk3g7tcppxqj4skxiot4g89ym1bdpfb X-HE-Tag: 1694598726-538308 X-HE-Meta: U2FsdGVkX1/Sy4K4N3EOkigpCRQ4NsFLrl1xyQdGY1hfD0KZQQLXack9qqoFQgFSow3fBEif6gWaVv2V3d/2NL68gXTBYVliYGcGDffPPTOchhrjvfZ5TC6mTkZCQUMpJHYHMjvS1v8uYflf+izTlpLgcQzbwJHLsrDnba8YjGhwDLUcLJeUjBo5Ei7vUG8QjXe6CsrYeMf2r9nrrLOh5+6yGMagvmkyefECADDPE8JCKyAtOn8Qc40FU13oKEvzdNBNhUnOop/l2AqXC63oT3wLBpAFABGmVTqRqVVCPd1vCOaSdCCoFoKJmRPJeWxui9q6nzVPCrOAz924P6SlAhiIMaWNyOYLhPRszkpgEkPByRCiyFIL8D6IqSUBiKiz7NHf8MyT+ZJqaeAvi1rpYhiZ9TsR5AcZOoDmOdMruJ7wiVjF3Sm2agGTzofw6CVNeN4voox9iWLEQiK7TMqomlQB+MxLpm6XZBi1VG8c3WmG9Xmd8nbCsLjEK8NNLKcPGzH0aehMNUPhwhdJAv9zY2240Kt0JM1S0VoQfuRn3uqsB+ixJwM8Krfm2j2PZUcuxOhO+qm439xUm0SxHiy1OuQOAFQOhM4RqWCMOczdEk+SxE+FleLFQhiQoAszIn8VhAsLlvF+bBG8P/oDBXYR07t0zRs48Jht1cYz44Gt61F7zg48DQfDSPW0fssgM4oFoe++4SyuGyAXqSEBTqO6OrzqJ+VIyLEQJ0i2Bvez2gafDt93VCjvLAhDNoL5dhX4juh5uZqUy2kpqps2CIA5IFb/G3M+J/Q0Nc40IjRlPmrdUBaM2l2kvs0RGx4q4ofwsYuqyR+Psef7kXtL5Z6H/IksXyYg2hmuVwexMzXH4GvLGZtnrRndAG1IbRExXyythw4f48dY+1nYFXhIuk4MmGfngTzsUV6kWOgjoAnctiWytdHA2eMkSc0VecTFNydQ0dI+tY8wmO7yU6sFuqo FNX4zYNS npBL530A91gw0d5JIRtc3OTIAgfQF6ExEmLz6j7HoylpGgknIejOHyAX/p2DQH2erRcSuXVe8IrovvwlJIJw4rsjBGZUi0SX2hV2zetM1sXGyYejrX0NKrSVeNFJuiMXanrNJ4ur+DpkddBeZI1zb1x/rMoTt5W84qOH67UUS8axKP+V5nBV3HNODCqn7oAQwrE/FSgOeLTQHU6IO/AIHLqGS/l+ZHE4QzRE59GVd5ZzkqjqwrClfNqGegCKMLOe4Mj34IspvHSe5qNcB8ptxmbB9CBzpS6wrPH6SZvExmfuo3eI= 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: Use __folio_test_movable(), no need to convert from folio to page again. Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand Reviewed-by: Zi Yan Signed-off-by: Kefeng Wang --- mm/migrate.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index caf60b58b44c..264923aac04e 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -157,8 +157,8 @@ void putback_movable_pages(struct list_head *l) list_del(&folio->lru); /* * We isolated non-lru movable folio so here we can use - * __PageMovable because LRU folio's mapping cannot have - * PAGE_MAPPING_MOVABLE. + * __folio_test_movable because LRU folio's mapping cannot + * have PAGE_MAPPING_MOVABLE. */ if (unlikely(__folio_test_movable(folio))) { VM_BUG_ON_FOLIO(!folio_test_isolated(folio), folio); @@ -943,7 +943,7 @@ static int move_to_new_folio(struct folio *dst, struct folio *src, enum migrate_mode mode) { int rc = -EAGAIN; - bool is_lru = !__PageMovable(&src->page); + bool is_lru = !__folio_test_movable(src); VM_BUG_ON_FOLIO(!folio_test_locked(src), src); VM_BUG_ON_FOLIO(!folio_test_locked(dst), dst); @@ -990,7 +990,7 @@ static int move_to_new_folio(struct folio *dst, struct folio *src, * src is freed; but stats require that PageAnon be left as PageAnon. */ if (rc == MIGRATEPAGE_SUCCESS) { - if (__PageMovable(&src->page)) { + if (__folio_test_movable(src)) { VM_BUG_ON_FOLIO(!folio_test_isolated(src), src); /* @@ -1082,7 +1082,7 @@ static void migrate_folio_done(struct folio *src, /* * Compaction can migrate also non-LRU pages which are * not accounted to NR_ISOLATED_*. They can be recognized - * as __PageMovable + * as __folio_test_movable */ if (likely(!__folio_test_movable(src))) mod_node_page_state(folio_pgdat(src), NR_ISOLATED_ANON + @@ -1103,7 +1103,7 @@ static int migrate_folio_unmap(new_folio_t get_new_folio, int rc = -EAGAIN; int page_was_mapped = 0; struct anon_vma *anon_vma = NULL; - bool is_lru = !__PageMovable(&src->page); + bool is_lru = !__folio_test_movable(src); bool locked = false; bool dst_locked = false; @@ -1261,7 +1261,7 @@ static int migrate_folio_move(free_folio_t put_new_folio, unsigned long private, int rc; int page_was_mapped = 0; struct anon_vma *anon_vma = NULL; - bool is_lru = !__PageMovable(&src->page); + bool is_lru = !__folio_test_movable(src); struct list_head *prev; __migrate_folio_extract(dst, &page_was_mapped, &anon_vma); From patchwork Wed Sep 13 09:51:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13382706 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 89462CA5537 for ; Wed, 13 Sep 2023 09:52:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F6536B0179; Wed, 13 Sep 2023 05:52:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A85D6B017A; Wed, 13 Sep 2023 05:52:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01FBB6B017B; Wed, 13 Sep 2023 05:52:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E598A6B0179 for ; Wed, 13 Sep 2023 05:52:22 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BC2B21A0321 for ; Wed, 13 Sep 2023 09:52:22 +0000 (UTC) X-FDA: 81231108924.10.7A601FF Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf12.hostedemail.com (Postfix) with ESMTP id 1BEAE4000B for ; Wed, 13 Sep 2023 09:52:19 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694598741; a=rsa-sha256; cv=none; b=5MAoaT/pU1qL7lN4yoE3wCTM4wCbe8AxyS0JQTi6R7vtITaqSBDetvOJLX1m24MnEDY90O N+wCfAQ4e5owZ9kr9BH3dc6gLFpdFPJCQnwBfc8ZyjvLI54woVKGT2eODPkm9OC601cqmI uyOeSdj+ythsWXQonOo6QxRM3dWpkqQ= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694598741; 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=RK3S6ofLX88DWyIyY123P5aohf1PFWYOerflINyiNM4=; b=22ZIV4ueH18UvJ20e9fUDMDrCLOsgdcmOhqwj5XLukhJ2KWtlhkwj2ZXvf8D1qFYSu4iKl cYRDHW/KvbxM1eK1WrhTd4GYSgIbRFWEHo6dvfdnDKNBcUh34KLlmqZG+b/YVpkOsP2lBN O9kJXZruGR1YR1bESeDd/nZcsUCkSvM= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rlwdk1Y6FzVkfH; Wed, 13 Sep 2023 17:49:14 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:52:01 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 6/8] mm: migrate: use a folio in add_page_for_migration() Date: Wed, 13 Sep 2023 17:51:29 +0800 Message-ID: <20230913095131.2426871-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1BEAE4000B X-Stat-Signature: bd6pzfux7kzqbaqmks3ngp4g6ta857x6 X-HE-Tag: 1694598739-478013 X-HE-Meta: U2FsdGVkX1++9bhSt9jvyQwtvnx55GoMdrl5cH5AaYYjupvxzA8O+23rtx2PXk/jrEal5qkMtdhJ4LgyCp6Huv/MOMsuYhQUc6CEmM9qcv0mCjzjoAhCI8LHaAY97R5yjXynW2Ycw0AbSF398hca3Q0WpmfjN9Us54M3KXr3wHiEbj/HRc3sDyuVbNtQ5OS40EUwEqJOGIpmiRYeziKES9dhRC3fyJTlZfQ5wzCfQ6I5doFYB1WfnozWZ7a7Z93DjsyiIP5a5O8IF0ApmEXIx3YJ0qKWEZ2U8FeGH5PtZPEi4EkGKkolap5EMBk1e4P/hc/cBFZj6BHpC4vM1hvIZ9f3gVxMOBo8+7GC+jsbj7yqSuA7Wg0QFXk8R4AVzuWWugRnYliKoRvCUWNehWt2S1qErHrVN9ibJfWYijMv5Wo/fhTp64X7O9nqPueGmk7tY8kwTDbFdK7XbhvHe+wSwZobUdrbaozeHxpHmxYoI5Pta7kDLS8AaY9ynHuItfzeQEwPE/xlL2KGbQXa/WNMzYsknzHP9wl+hfV7LmknPkrVArWf0u/6e0In4RmGJwOkL9WLrfZgq1fRXRyQq7VTm6o21PP1qyolX2U7tX80r554GziW+JaRd8KcAyocI+4cfu4b9jZ6U1g65jjhJZJG7pBoLsCllufr35BY0NUl4CT2qwfGYILQuuB+2d8aAuTWvMDgrcjbHwPCRlymsjfukIH0wKgNkrLTtxzbzdJsW/viIHGYQm8N8u0/WKPlzwyNTXzsZ9aqjiSv2GBRPyJKsV80eUIdAZOTSc8zdP6T1Ot1vhQEASkxhL45k5smAHpzQlU6myl2NYWPwb42PDbl6oY5PP6wMqaLFbhTQGFsBts/UKDlCS+XA6tSY7ZlzTsHiiDw+XWW7kAYI3hyqsnncCFBljEI9bMk4Kw/gH6Nj8TO/wcxQr7cM4FsyVrXie2axZeMDS8jx6SMtFOCu5A 4A3k60B5 awiuJ9M1TamdbCy7HDkSPH/fRQGnpC631/lB2M7rkvx47i5MTHOnM7OMXidHR+Hldeiyk/xwQAy/OOz3njbo5vbBPF/l+9QOQ6OzWEQ8RrspZ31RaIDt6uIStIMukMQUMhw6TwO+te/zPsOTxj8oNI5WPqvAtdWEUJ1HHLWiFprg4P5H15wJQufZdhUyQzAeX3hFY5H/FsvFytZH4f+mvVaQFHg== 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: Use a folio in add_page_for_migration() to save compound_head() calls. Reviewed-by: Zi Yan Signed-off-by: Kefeng Wang --- mm/migrate.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 264923aac04e..cf5c9254fdad 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2057,6 +2057,7 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, struct vm_area_struct *vma; unsigned long addr; struct page *page; + struct folio *folio; int err; bool isolated; @@ -2079,45 +2080,42 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, if (!page) goto out; - if (is_zone_device_page(page)) - goto out_putpage; + folio = page_folio(page); + if (folio_is_zone_device(folio)) + goto out_putfolio; err = 0; - if (page_to_nid(page) == node) - goto out_putpage; + if (folio_nid(folio) == node) + goto out_putfolio; err = -EACCES; if (page_mapcount(page) > 1 && !migrate_all) - goto out_putpage; + goto out_putfolio; - if (PageHuge(page)) { + if (folio_test_hugetlb(folio)) { if (PageHead(page)) { - isolated = isolate_hugetlb(page_folio(page), pagelist); + isolated = isolate_hugetlb(folio, pagelist); err = isolated ? 1 : -EBUSY; } } else { - struct page *head; - - head = compound_head(page); - isolated = isolate_lru_page(head); + isolated = folio_isolate_lru(folio); if (!isolated) { err = -EBUSY; - goto out_putpage; + goto out_putfolio; } err = 1; - list_add_tail(&head->lru, pagelist); - mod_node_page_state(page_pgdat(head), - NR_ISOLATED_ANON + page_is_file_lru(head), - thp_nr_pages(head)); + list_add_tail(&folio->lru, pagelist); + node_stat_mod_folio(folio, + NR_ISOLATED_ANON + folio_is_file_lru(folio), + folio_nr_pages(folio)); } -out_putpage: +out_putfolio: /* - * Either remove the duplicate refcount from - * isolate_lru_page() or drop the page ref if it was - * not isolated. + * Either remove the duplicate refcount from folio_isolate_lru() + * or drop the folio ref if it was not isolated. */ - put_page(page); + folio_put(folio); out: mmap_read_unlock(mm); return err; From patchwork Wed Sep 13 09:51:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13382703 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 5A593CA5531 for ; Wed, 13 Sep 2023 09:52:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7267B6B0173; Wed, 13 Sep 2023 05:52:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D6646B0174; Wed, 13 Sep 2023 05:52:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54F2B6B0175; Wed, 13 Sep 2023 05:52:09 -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 4354C6B0173 for ; Wed, 13 Sep 2023 05:52:09 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 18C541A0D13 for ; Wed, 13 Sep 2023 09:52:09 +0000 (UTC) X-FDA: 81231108378.04.228FACE Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf25.hostedemail.com (Postfix) with ESMTP id D3DC9A0022 for ; Wed, 13 Sep 2023 09:52:06 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1694598727; 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=edCISLjT6+ZkLMLK7dCnKkIlBAZTUznn0Sy9MjDom88=; b=inePx/fgnL/h321IDu605/sm5/rGJv9HiDTJ6acXhxN7MpDhl3IncewBMnzI17haxjnQiQ 06oFN8R9d5PJ2RplygAkG0j/I+Ae+2S8ptExZa2HRnrm6MDO/KW9l6FapBrI/56YXWPTM7 8L72pVKoam/PIwjLUsWBSHh34JOxJgA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694598727; a=rsa-sha256; cv=none; b=JSkth8ZkXPkooyJBrjWyT0LCWuEfsJfryztzW0itlwwor2v0NZit15ful6d5HlgZs9pb8g fJNIX5HtnsVlwFv/S+zdAWveBBalq5ue32YeMxuIf9fk4EVbHMSL7bHfm+Aj2OrzY7J36L G3a6a5tXuYex9xsNQqFZrbq4ZBIdtcY= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Rlwcy4tMkzMlLX; Wed, 13 Sep 2023 17:48:34 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:52:01 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 7/8] mm: migrate: remove PageHead() check for HugeTLB in add_page_for_migration() Date: Wed, 13 Sep 2023 17:51:30 +0800 Message-ID: <20230913095131.2426871-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: D3DC9A0022 X-Stat-Signature: ju967n6w67wm4jofs1xas3nmk3no8ebd X-Rspam-User: X-HE-Tag: 1694598726-166742 X-HE-Meta: U2FsdGVkX18QtfCoxeYgXEjlDbUpne0NtbPa+NYXXH7BzWIZ3JisMfY0FkzdvJeSg2fL2x4h7zn3XIfWMlgy4B1nLNmYlgGQo4iI9aNanQMQQQEE5V3aP+AbbM0i0HmKep+xwismdhTJquO1HZGr9wg3PX87ll+h8D5boKwO+Gv4d6GuuXgx7EyUyz/E7Zcr8uM5go5hp/J6KMj+tOd9sy9ZzuwwLR4WgkGEbWyVKAHdQ3aIPeBWdtW2Hc2OSLWH2eDVWv+4zP9FQgsUlSZpaxwON8nClKaOL40V6uRsEpnDssiHFKpxkPnFuHFtCZmItV2WVMkYQvy0ZyO94izxQtssQqId7m0qkv3nqJTaaIwFyU9g+nkf5eeZi2j1pFlbeVvcHzNMnjqqp6zsy2DcaCs1/WEPMH3OF8vvnujm6+8QMr1Wi6Ob24vA56GJdW4zI7zAoYFfAs30A/JHIIcqq3rqJVJFDHKzCHJPzlNv1pM0YeScuENyMo1tdLim5LsMtPy2/DL3y9d0CegCO+iRz+kDppX7kjQEGb2vsRbW8S1FhL3OIpDWFTw0oSEBzu45lA6iXYQ0mllXkiYM980i9cSbV4Dzp6os8/r6A1LRXH/VFlKct5MqSd2b9FhnJuMLfVCJfCOdNtwjaAs2Y828SQMdkEOAuPebECu4rcIJwGuJQccv//DCTUTlXFagjGIrh/ZqwG4AujD4zm2pGccjYWSMGhnabPCt/2qr06VzewW1eY4l/AH4MtcEHKhjJcRdCZVjdsYI05f75f1UUl/QlQROB1zDZ7LUZHz3kv5EoTa/i81KmBt/6Nx6bBLBtp7WTBVc+MRH6Jcm4rnCv9Txa9SWILoPnIQSwoJWdtUa3Y3CYnI3irfkl/K+yim0JDMkaBIUnwkh3LCztNc8b2nsEPhDY8R63ebL/pyllxSGENlKHYMobbPFIQsUM74E3YmyXQ1bqcFpbpSKxqihqWj MKCxDHoH fueMVyvPMl949yZA+9yoXGXCBsEpadzIbPObE+MOOOjXn8nnF+Iv1CCnPYdxouv/LzvyKt0fB5jLL2JvBjN42QEFVZeQgTAJh6z7EGki8E9OAeMbOkcRD/wYK9D3aay2cRKbnTCNADar9MYnWOAR5+sCm+1F/1sdDPRW/vvLRIv3eQAJGPnxjUa+EDu499cgLTRvNrCbDGeFeulT0Xl63xQmCdeonOxsQSBCj3Lm13bEPfOpUl/V0FDNWQgnaJw5ERJBbVpHkvryebeNvF9iqPoJqQQRMGghmv0L/XrRIYD4ruUGWpDSIYF+aVQetCytjd4kp 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: There is some different between hugeTLB and THP behave when passed the address of a tail page, for THP, it will migrate the entire THP page, but for HugeTLB, it will return -EACCES, or -ENOENT before commit e66f17ff7177 ("mm/hugetlb: take page table lock in follow_huge_pmd()"), -EACCES The page is mapped by multiple processes and can be moved only if MPOL_MF_MOVE_ALL is specified. -ENOENT The page is not present. But when check manual[1], both of the two errnos are not suitable, it is better to keep the same behave between hugetlb and THP when passed the address of a tail page, so let's just remove the PageHead() check for HugeTLB. [1] https://man7.org/linux/man-pages/man2/move_pages.2.html Suggested-by: Mike Kravetz Acked-by: Zi Yan Signed-off-by: Kefeng Wang --- mm/migrate.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index cf5c9254fdad..7b07c97f5a6f 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2093,10 +2093,8 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, goto out_putfolio; if (folio_test_hugetlb(folio)) { - if (PageHead(page)) { - isolated = isolate_hugetlb(folio, pagelist); - err = isolated ? 1 : -EBUSY; - } + isolated = isolate_hugetlb(folio, pagelist); + err = isolated ? 1 : -EBUSY; } else { isolated = folio_isolate_lru(folio); if (!isolated) { From patchwork Wed Sep 13 09:51:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13382707 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 40D76CA5534 for ; Wed, 13 Sep 2023 09:52:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CCB066B015F; Wed, 13 Sep 2023 05:52:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7B2B6B0170; Wed, 13 Sep 2023 05:52:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6A266B0173; Wed, 13 Sep 2023 05:52:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A467C6B015F for ; Wed, 13 Sep 2023 05:52:53 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 720C8B3C90 for ; Wed, 13 Sep 2023 09:52:53 +0000 (UTC) X-FDA: 81231110226.07.04A86AE Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf18.hostedemail.com (Postfix) with ESMTP id 1E97C1C0030 for ; Wed, 13 Sep 2023 09:52:50 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694598771; a=rsa-sha256; cv=none; b=lN5PSfPu47F8fXF6sZKVMEGv79/NuWiIDifJD1K8yRkd9se6TceUQBc9vZXvopln8K+QJD UGVEMQeuGwhbPNSlAmo+86GEg2cSTSPq4Tli0W/onkiGFxF7+JV1AlfDZD2fAoAyQ4eJQl fzwOMYqDnW6u96KLOI6HaFWmaLRhc4w= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694598771; 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=DCfJIYv9BZvAD508DaHGVzJ85GuKmA46MB8WO109kEY=; b=z6W5TCP9ObgWYvWpJdbLUhB98tRlJtHSvAopBgFRdJHiFRDGwBDl27I0b3fGzG9aUtBQVW JNGibDomB5+E7xuSvbDptFZep76XQ5JX5BVx9zb5+Lg0Q9P7Mz0wQnk01o5uEM7LSbAGc1 ED18Biuyb9mnzJfFkcKa0AgrbDGKpyQ= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rlwdl20fPzVkfZ; Wed, 13 Sep 2023 17:49:15 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:52:02 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 8/8] mm: migrate: remove isolated variable in add_page_for_migration() Date: Wed, 13 Sep 2023 17:51:31 +0800 Message-ID: <20230913095131.2426871-9-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1E97C1C0030 X-Stat-Signature: dxnfknehdg4hir4sd3apy8ao7kox35g8 X-HE-Tag: 1694598770-185631 X-HE-Meta: U2FsdGVkX189hArBSP9rxycoJgGgdtxXbwgcuaHi+ZBocot5BoFzL8u4FVLoWT4BkF+NbT+2ZJl+74RY9az1hbSDIzD9wD69XLS3Arnx+P7hTi4/OWC2RiXYLOl04ZvyQL0UOxJoU7wkZegetMTnDEmIHOMTIpNp+vs9oreJEU3aV9uJYuKhomvWF9sJXWJjobZtuh3IdW+jZFqBT1vWrRPaNHlYfxEY3rp6Dm4I9rCyV+5ZZZuDiN7Qkw6kdOZ2XYQoyt0QYnXgancsPRYTo3bMxuWhT2/4nrwYbpVoLKqABLnEegM8zAbNF79jyXnC5gcG/FUkPHo4crxVElQoPVf5q8zCW9ge8PK7ErrEf0zMpcZzBiw7ug7tmtx14EEpyEqXX/KDrQZXkYTjavG5E01bskwg2sKuOE3M6Hz7opPdwNbjfLRFsHoMUeyvNVioPypbEwJOSfry2kwtV3VuuahBJS9jEj36dt86cCpDszvHRpK70/g//ODq0EuL8bYvdwiF7yyXjrv+Jys+hvYWP0UZvW8sxiXLQkC3HPxyEj6wZNsF29bS+KjOwqWFJB/kYzW3F3DiuJlwRAlObRO/x68NPxs0TQAT0dFRN61YCp4gmw0NRvL5uFpJTCgZuCx6vneEZS8Tr/0iIdJkg4/Qy6QS+DtDJlMEnE4+0KG3WSWXfar6UCF5zgQaHOJAkcdF8cxb/QQ0eNfjpPMjl6hncqHJ/fp/iEDWg+0RUesRC5Y6wlmnz0nqZ2kA7p85Bz9efCZXmTPgYNWfkVXdtryHvyYUiCqLmWTc6vymutCqi/p51sJ2e5+WrlXZpW53Df0+KHK5h+7pN7YsiswQ5Q0hYHRj5Fr8fUK0auOp8jT9ldPxmFsZ06AzKrFKEqjMDZdMAqvDmDHuPqov/quyCXXTyWf+NutqFBH6BaACNAfNlCPFKSZ0oG07JwuE+LftZZa0rr7hsE5h2ZHlB1Uxrv3 Sz8RMUha XHKKVJI6o8aQ51Rd5Ig1gaJAO4rVqWVha7RZnJG143M+sKWErj5//079o7nxieQkFotK5UxokUMk85GtZCVrQImZmyoVVCQJPlH2fAH0DSeqLNYirgHZKJApcnSH6ZATwi47VyHDLuLAxEVpnwZ9ei5QUONpSFcNCXzEYbT3nT3EHvjjrH9br9lSU7G+qi4mh6IsWuPRDOs7ev7jCbDmtR8zFjxgmbDe7DC8v 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: Directly check the return of isolate_hugetlb() and folio_isolate_lru() to remove isolated variable, also setup err = -EBUSY in advance before isolation, and update err only when successfully queued for migration, which could help us to unify and simplify code a bit. Reviewed-by: Zi Yan Signed-off-by: Kefeng Wang --- mm/migrate.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 7b07c97f5a6f..a5d739603458 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2059,7 +2059,6 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, struct page *page; struct folio *folio; int err; - bool isolated; mmap_read_lock(mm); addr = (unsigned long)untagged_addr_remote(mm, p); @@ -2092,15 +2091,13 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, if (page_mapcount(page) > 1 && !migrate_all) goto out_putfolio; + err = -EBUSY; if (folio_test_hugetlb(folio)) { - isolated = isolate_hugetlb(folio, pagelist); - err = isolated ? 1 : -EBUSY; + if (isolate_hugetlb(folio, pagelist)) + err = 1; } else { - isolated = folio_isolate_lru(folio); - if (!isolated) { - err = -EBUSY; + if (!folio_isolate_lru(folio)) goto out_putfolio; - } err = 1; list_add_tail(&folio->lru, pagelist);