From patchwork Mon Aug 21 11:56:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13359340 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 395B4EE4996 for ; Mon, 21 Aug 2023 11:45:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 979128D000B; Mon, 21 Aug 2023 07:45:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 928D08D0002; Mon, 21 Aug 2023 07:45:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F0108D000B; Mon, 21 Aug 2023 07:45:41 -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 6D1D68D0002 for ; Mon, 21 Aug 2023 07:45:41 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 39DB11A0B5B for ; Mon, 21 Aug 2023 11:45:41 +0000 (UTC) X-FDA: 81147932082.17.801F7A7 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf21.hostedemail.com (Postfix) with ESMTP id 28C611C0023 for ; Mon, 21 Aug 2023 11:45:37 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1692618339; 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=YFn9sPOOtQsACHVP40lHzVSkZGNDT8Y67dEErfZg9ZU=; b=y7m23sTBSS/gsswlTU32DbKn/yIWNL4KxnHtFcMOO/K2CKJe8jOXLEF+cL0sFxkW6iKS/4 WscTddVV/IQwOp/PpDaKtKRsZu5ZNL7aFAHXrDWdvltGa5aeQXPZ8e7nxig02ElKo5wcF5 jsP+lFnjyAMjwygB5RMEymjD41IYpM0= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692618339; a=rsa-sha256; cv=none; b=gM0kGHh3uxueQtpxWJ78Et+BJ3H2QaA5Ml2mrBwBoxQA7MfWdhi7ijf0j7qIKtCyUjv3Tu L53AKou2ABBheW2ojXqwYyNli69FLfSfi5EELg55Bh8QnNH0oawRWFgzwa59XgJW5Qou79 grWkqnXsnnCQ57i1kiHZMYoT9YaXRys= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RTrDH3LQcztSfY; Mon, 21 Aug 2023 19:41:51 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) 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; Mon, 21 Aug 2023 19:45:33 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 1/8] mm: migrate: remove PageTransHuge check in numamigrate_isolate_page() Date: Mon, 21 Aug 2023 19:56:17 +0800 Message-ID: <20230821115624.158759-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230821115624.158759-1-wangkefeng.wang@huawei.com> References: <20230821115624.158759-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 28C611C0023 X-Stat-Signature: kj7dr16b5bq3au5ikzea7mjyy3dardye X-HE-Tag: 1692618337-187707 X-HE-Meta: U2FsdGVkX18QJUs8ptWxKi2QRmzPY0IW1/edjFfyX5/bBtdzsBhG2WJkLRG5uotcqm7tWh5vk/Wo+eKOGadu2YIqut+RvCoL0N+e5tfYOe6PMFaM7mVffJc+3AAsxo4fWYVtAfaDkHnZtqTnOxtoBbPF2VeNFMS7wdcWOO8b5vbk1rKTNdVANmq5uvh7K/h+0Lan3ui0IvayjOB1qe2+MkuTIz9pBbCH0GhsY9PuG0Dc6IG8vK5v6b7jmAjKnEqi9LO4bNbODE7qeO6TDHjUK5lVbwcMbCYf0IVdBx3SAHf6uOGnPNtHReMDN3ytIR1AnRzbFomtR8bmnRJlKbtpx+2/wYGTPqXNDheAPVF4FZQV/vfxRGWThMeaj8uiTsaLmGVoNa4eIY1YSsRFZSHVBu3aj9NsRG6y+Jfta8PGX8yZBKQmwgjA+NZi3GhLo4S6d1LNNtfVLAbhi1DAZ83fJD+6VhwVIKmf+XaYENUPPShwyvqzNDXHlT1xHBeiY2uyQy1ijMGqUJ8q0Yaer0cASvuKwgG2tmlpXJdHSxO6xT509iDXJ7hWmdZ0NaleBFenw+vhKN5FDRzX5ioSgx9N8ll0F4fyWIvw+Cxd0YgdhxzVuXs4k0X6vj36MeHJOocohiHh/lnfy1Fuqv6qqZw2XmoNI2K1JJYpxim5H4G/bZqev5KAIptqY42wV3PyyKjT3HGXri7WUlv4o+8rOkLz2wvgPCw4wQi3zIB8oLZLvMGshWtitTUkkF+p/MsLpTPrxE27VjY2vCt9v+kgpZNj5gHwD93/ro+Q1avlWysDi+RtP4ZpTtd5Sc2Ql/8BeMeNVWFWb+3+R90gDOxSiQFUyO0J40Q+Ovl2adkIYG95LP4WpV1eCvRU8PYF86LRHqFAtBY0TKbvjLoC9wDr6JWA8FgPMqJ5lBBUe71KMkVl91KLbarD8s9wiGhr4bJ+NSCXjncsrJXTnYaMJOI1ZVU DbMYQwli 3rnyO5PZCoIcCz1CiTYBuWTtaSwQNftRsDx0NR9BCmluWbywS1X0EwJa0JQSstDSeXflaHIZLwkEd9v731NNl/CsdV8bBkwZ52BQm68cOCW+KBXkcARXKK9GZUkr1AfnWfsQRPPb+WmEZLV3wddXbG31yIx4sErELHL0GqaKEUBjdMjB1KYw3FY40I5+5lofcZz8xp07XNF9wYnuuH36G8hJaQzi+bij61Ww7lzIKMWXxaQc63meBcRIjj+JNrOeSTgFz 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: Since we begin to convert the numa migration code to use folio, which could let us to handle arbitrary sizes of folio, so drop assert that we only support PageTransHuge page(PMD size) when order > 0. 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 Mon Aug 21 11:56:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13359346 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 C4956EE49AC for ; Mon, 21 Aug 2023 11:45:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E9EA8E0008; Mon, 21 Aug 2023 07:45:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 273F38E0007; Mon, 21 Aug 2023 07:45:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F25748E0009; Mon, 21 Aug 2023 07:45:42 -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 C289A8E0005 for ; Mon, 21 Aug 2023 07:45:42 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 91AEB80BF8 for ; Mon, 21 Aug 2023 11:45:42 +0000 (UTC) X-FDA: 81147932124.02.C0C184E Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf15.hostedemail.com (Postfix) with ESMTP id 4B6D0A002B for ; Mon, 21 Aug 2023 11:45:39 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.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=1692618340; 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=MMDH9YItxAMheB2YJnFwOxwJMEtTB/LhDoml9IbDVwo=; b=1Gfv3zLYqqmvY3IoQUJexYhB5IU7CZ/vwrI9skVJV6GPpEpqm0mYRSj+qdG/Ef1KdqDpkV PVpdGNEKs/0ZAfBgSvY7VpXNAtfFWiM7quy7zV4lJOhJN6aUbt+gh9Biq+xxQBO07DjyKp 3JCh4TZcR2UCFHRLWzrKVEIHG5GmGiw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692618340; a=rsa-sha256; cv=none; b=WJoW1w78mgq34pZdslT0l0kyd1lFuX7uorpraNZNnnpdu9ld/ltgOdsYvRsRRxGwSqy7CZ dzrcwE3mf5Yp0N16nrn6ChwjFB2h86gfbUWJ3iOa8VeT+3eVL29hAzYFPwU2CzkUrUC7CL 3u4yVNUEmYBuPqjZR4ay9uE1f14YXf0= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.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.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RTrDS2k1tzNnSV; Mon, 21 Aug 2023 19:42:00 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) 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; Mon, 21 Aug 2023 19:45:33 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 2/8] mm: migrate: remove THP mapcount check in numamigrate_isolate_page() Date: Mon, 21 Aug 2023 19:56:18 +0800 Message-ID: <20230821115624.158759-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230821115624.158759-1-wangkefeng.wang@huawei.com> References: <20230821115624.158759-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 4B6D0A002B X-Rspam-User: X-Stat-Signature: uzumwxy9kr7xarmexf559yz8zd5h7cq7 X-Rspamd-Server: rspam03 X-HE-Tag: 1692618339-862941 X-HE-Meta: U2FsdGVkX18FX7R6dW+g+62evzfSv06O9avl/po33e9FXmFstmOPrEl6rHjwNTGdNK3pZExZeCpGTOF/cWqdNSQMQ7u2PzjvBO3tdV9O8HOg0DxzsL75qvCIWM97EgIMFy2Q/LIGaNNV6Th0umsgwk68uOFxdScyfRlpEJoG9M75KDa+mEkQmZU+kud4BYPc2Re8R1A5zLe2V+kjDhlbevQ2tTjJMgpeaC+IZuzb/fToPVv0tB6fPngIMUKD33WzkCNL5Lsk18keq75BvE9bYFEG94Gv7JlY5Bb9QNsxIa2lY+uSTS/y8Mnswn5DMZ3G+bzK97wGzhbTeYHeobgeBzVY8jFK/AxdvD9PyU3azxdgmg3tp8W9QWOqrOBBfaio0/rpH7uPWwSmXMNZqhS8CVP0vlW8Vsz3Ga/03vVqp3NnfPBpItGVwaxBvpLxHE+SqhVnGsWTu0sunfPvS6yppuh+6Cdf9fLQbZ+Bj3tTPDAFHKvUCkhoPveVRi3A2L37oC2elitl/oWvS6PRdIacGQv758WQwqOKsHOUtpxNbtInARNeU29x5zTfFtuqY37I6flkiXtuH3LtnfRbg25oZsLZyVuGl6aSkPy53PeO6+GwLWUEeSiZsGwcKI6TeMeeHv69uxAshSSm99bQ/nwQfXhqeQemIlPPHrqiPzDp7r1CkXtS0K/nlwrejnSZ3Sggre1ooB00i3wTWwFEvSKrZI/Qn8QKDazyLJeMXjBlUVSJqHhXVgFSibjeAVzz4BiTb/psSrlmnxfsyr975Svqq5IjMMy4OunFEK7teiWbmATXF0WQAPQ/bvd+3ypikSBdB8h6hcOiXXeWM6AZQAKBrMchUJ4T+DRWyrFQAUDrUmlOCEtVBmWFMXvAdU3Rp/ls0BgFuTUiOCgD0pxWEdOyHWe2KEUug8y11CNqPzu5OkQz3ex7KuUtdWlrIU4Ygy4vt/1C9pdgzmQRWkXJCB3 PFJWlCvd sAs3kVzjzlBrob72v1Me9LZY5EKzu2UYkRCGMVPMGU+EqqbmjfHgij9tslyBXIC3Ws++D1U6y222CixKNTnohP2+Y4M9jnrN5RQX0dNGaM9ddsniElSQUr4C4N/o0B7Za7mFO9+8W6jHdY3Hjs1T5ov0Qsrg96d08tKMXSbq3BnfTInsyZ9fuaCcw5scWIaNqsdynNAhzF7GofxC+FpbL6czdjGbQYlAimEGcoEdI0Y8R1UzLR22sWlRNAg== 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) Signed-off-by: Kefeng Wang Reviewed-by: "Huang, Ying" --- 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 Mon Aug 21 11:56:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13359345 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 36FD2EE49AA for ; Mon, 21 Aug 2023 11:45:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D54878E0003; Mon, 21 Aug 2023 07:45:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8189F8E0007; Mon, 21 Aug 2023 07:45:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57F648D0002; Mon, 21 Aug 2023 07:45:42 -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 011E28E0003 for ; Mon, 21 Aug 2023 07:45:41 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B81F1120BBC for ; Mon, 21 Aug 2023 11:45:41 +0000 (UTC) X-FDA: 81147932082.10.C8ED63F Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf01.hostedemail.com (Postfix) with ESMTP id 6366B4001B for ; Mon, 21 Aug 2023 11:45:38 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692618339; a=rsa-sha256; cv=none; b=1dnhdZQKnLzWr1IOXIooYDZgFDuUx/QxCi5WMlKXIXrQxHlQffRJwFZ1Zb16iCxlt64xya mMX56WRv87cNuoxREOL3j4GI2ekwaSmoa8fHDjCzrueFv5R52vM9Cronwc7jcAfYqvVGAR zKbjzXy7XbQ+RvP37Y0gH6F1ZTa7+QA= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1692618339; 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=I41Rmr70L+mSC1kfltJOSaYN9UhRfL5214LDD4T0WaI=; b=wOf+78sa5kOu06eT3CuTnmJ7dThs0cAhz1q2/P6R45wAVo/m3h3m51kmOfupK+k/q3AMHU YLZMyaFcG64hr/8vnwCiyvIhmf4TiHtm7I868+3nh2/rjrq3TUiyy2Wt2NyreFGZeV5pec wl1yIiIBxPux0AYIITMnBTMDVhgj3Iw= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RTrGv0Z7QzrSwY; Mon, 21 Aug 2023 19:44:07 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) 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; Mon, 21 Aug 2023 19:45:34 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 3/8] mm: migrate: convert numamigrate_isolate_page() to numamigrate_isolate_folio() Date: Mon, 21 Aug 2023 19:56:19 +0800 Message-ID: <20230821115624.158759-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230821115624.158759-1-wangkefeng.wang@huawei.com> References: <20230821115624.158759-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 6366B4001B X-Stat-Signature: y8n7ckpt5dedr8iggdkgwc96aeg5gsh9 X-Rspam-User: X-HE-Tag: 1692618338-124992 X-HE-Meta: U2FsdGVkX18w+3sm4vIaqVDScXynIIRuQqbFVqmf+rcli2AqbG4XkyS5vMcCL0YbUpM/5ezly8D2V0XGUt4soyZXuYw/flYXMmI05iPPbqfYdfnF8pJSpH001Oge+Yw3IMcY/vhvV/dfRvpR5xXq2Jv0s92/vMjRzFXMtdZ19MBmzCZBoMfOPKao1gAQfDdQy+AsmwfVKhbQX5qMxnqWIjh58abYtfoVYC5/curatSaS3O6Lvq6FAwjoT7VP9ZqHYviyXw53RXX3vIIsH3Ho/fDcZeJQuDEEg+kzFP63vFf9t7JzS7SaLiGV7kI6myp8RIEF4MJydk3HtQwDSGQLsMl2Sv3aErB3Q4pNUTDdS7qDktQRjcvoMsUakUubxplVQTPlIhNlstrefaWAtTPIdbhBEo8eq61SFGx0HKbTApQKZBL1Y8rKaTDbSNeqPfOgxXAYvxqSG4xxl87aShx0Ivc1FenhJdxOmiwMvGJ808TA58em0WILte813jis+msq8rIA5Cg+k4AaxLvBgp5IkDedej8Ogl0l+T56xIeMOMpM8rZffK5Ti04PBtS1161OvfRhIVaAv02i+OUJykxMzoD9eKl1aJO5NYbjfcq2tMWra+dk0VZ3A0LufQeStUiCWR7AncYjJIDdtVoIFZa40C0K9HtVi0rj2xZnWe6o6k8O13Xm26a18Iz0siBP+otZbTasnUlh6Oqp4yoojy7wtmC8+HkYgb/7FIkv1tU6n8JTArAy80aJKhBkP2ZxDP6jucBbVKL8AHbMHyg3V+oI1JaaGTyWLhGw3E1PPFnl1+nB99wpYlLVtBVitBGg2msmVPZL23Uq1jxRsAkA7uG/Z9+SKBhy3aq1vcivaW4C0GmI9iI0diEqEhQYjAnCLp/jtOt0O3D3AI8YRDLKtB/viscSrK9GYacvVQ80Y9hXZdyvHqaBtnybm7RYh9JYr8VeDCqJNePjREXl7t9yOET xJarnrZd Oyj28eRjf1/ToXZulYKhyh8kIRcZWnATvEr2jYX2Y5GFMUzOrmpO8+5fGLPaPC8hzCVBfI/VvlnVEVtKsc6e5Ah3ADsxfhdEunj7JKeJohx+EjWHDNzlwY27dWd/xvNO7PMFUfRCS3cdRAhGJZcY8cZZa0c/CeXwJvi6bYZiy9tX2Zq/oKpJIeYD1ocFWWFpakNJj 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. 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 Mon Aug 21 11:56:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13359341 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 33B33EE49AA for ; Mon, 21 Aug 2023 11:45:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29D718E0006; Mon, 21 Aug 2023 07:45:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 273EB8E0002; Mon, 21 Aug 2023 07:45:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0ED4B8E0006; Mon, 21 Aug 2023 07:45:41 -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 DAA468D0002 for ; Mon, 21 Aug 2023 07:45:41 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AC35F120BBB for ; Mon, 21 Aug 2023 11:45:41 +0000 (UTC) X-FDA: 81147932082.07.4C0484C Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf20.hostedemail.com (Postfix) with ESMTP id A257E1C001B for ; Mon, 21 Aug 2023 11:45:38 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.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=1692618339; 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=b6a5Lr7QxakE11InEGULrgvVA3wroipO65uNIXOCIbY=; b=QyQuiewH9eeYgpPBOta2e+BLFD/35HKhindVgfFCB+ngZRDiut6Nq1M2q0uYJoqEq2Cg2R BsaBy2BH+oza20qa8j/KevFoGglxV7UkjLo4Si5RnqCs7ytasrdc2OKolteg/cNnCn2ZM1 rhFqeE7ps7eg2m9xn0DLzUNZ9eo8ViM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692618339; a=rsa-sha256; cv=none; b=N4eQwotMh1gue6+morSaOt0mpAYVlEItiwLafgsoN3FaOTU7S5LpG4FqlUWKQYfeNmcVB5 BwoK/zrJWsRMXEZv5pzapGv8JvzB+Sxo+Gk1wmPoatV8aoujyM2CiP+T7KBN/OB3JInkeh uBLiAWV0XLb+1VLpyyw+KBl+Pp01nxo= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=pass (imf20.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 Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RTrGw2d0Lz1L9R0; Mon, 21 Aug 2023 19:44:08 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) 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; Mon, 21 Aug 2023 19:45:34 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 4/8] mm: migrate: use a folio in migrate_misplaced_page() Date: Mon, 21 Aug 2023 19:56:20 +0800 Message-ID: <20230821115624.158759-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230821115624.158759-1-wangkefeng.wang@huawei.com> References: <20230821115624.158759-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: A257E1C001B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 8317g7oqib9sjexnzf71tmsstrk5cm8m X-HE-Tag: 1692618338-264858 X-HE-Meta: U2FsdGVkX19QIYlyFeyuPw4CAwpucFyzAXGHFrHqQDBqzjmVk8vRhKBJj5zTVK1/aPRNPEJprhAsE28RzYTwJMiABFuIxh6WxQcgtnyJU1Jt/OiXbPhnEdEpNrGwb/ruJTjrcEslT35aWHjXLuhmi4LnOYTUv1M+vMFDLebASiRqloWyzPO9pcwwK2SS+sjGBX26fiLHttMPFcGiR9y9dN27x/vKZoljwanlPiYNHRVQAcYoqbDM3IfNLYfHjz1oyj855pOng3wJ87BhCV+VuwsDEE2f7TcBD9vX1dg+hQPWVblgCTJXWwcL4yRYC7beTLIksmZnPT2Y2hFKDvMhYj+pT7CP7RUEjIyJoHyEz0kPI7rYMht5wHn42U1LRuraqc0QZ0MiVmgmsEKbm0BA1Yko3WLmqylicoHWcR0cmG/NDHhmF9Jx7NBkE9/zk/n3sMhoAcZcBBFqtzexQzxsy0WcELcKXImeLS3JAfldtvmRIKwkxrHrTGciZc7SoWaZ8mVIQ8uU7KFfX6TmCA4cLI0t3xzwCutU44r2ST81a/wgC9rLlTOiQktLnWXQDyjzTq5lEiXcoqmlzI9tJmle48FyKUgnpsmvQsRNbGqAukFXKtSJG5fBAmUiqQ/IY7uG6dxAQQBmOoD5BSg8bR5ff8gUUpskbvsi3+ZOBQmb8c1XncBYRS/i+DNO6qSNu7iIvJn6iiipC3d60JP1LMhDX9QdyxeeLYge8vnKvMMB4GaPZ4zWkgskjZjvEApUee4N947aynCydjmvnUqhaYufZLFtX0NzBnP2cNgpmaSLCra0QInDVPZkQvZmpIiZWQjJtKt16lbokgYDVGx14sFI++VJxpydE0paHtpMYvPGOcLH8L9VUa5t6++/btokIvkCkAwMcXEjJoNlnekJcYyEOZyEHXveFzIcvdSoCiGk+gcb7GcqM485kFU4zdrRfH96Xr1IelnglCXG3vIRR1y zh3w9ed6 xXgTyPly6QBheuI+d/uTuuSdm3+8IS7FqSzf+2rcZtRl9M4Cz1qoCkKzQCYuYPHDO8YO7t4MEkw4zl3vo/ektJ83+yuLYzljIvtjwsMiCORVFICqeoq3RFAOyf4XK4BTrw6YP8AIsw34loxD5J+jZi3EOb52Rp0AehxuFg7ghqnncDHQL9yCTFHSDsr3NxyxTuw50 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 migrate_misplaced_page() to save compound_head() calls. Signed-off-by: Kefeng Wang --- mm/migrate.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 281eafdf8e63..fc728f9a383f 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2521,17 +2521,18 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, int node) { pg_data_t *pgdat = NODE_DATA(node); + struct folio *folio = page_folio(page); 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 * with execute permissions as they are probably shared libraries. */ - if (page_mapcount(page) != 1 && page_is_file_lru(page) && + if (page_mapcount(page) != 1 && folio_is_file_lru(folio) && (vma->vm_flags & VM_EXEC)) goto out; @@ -2539,29 +2540,29 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, * Also do not migrate dirty pages as not all filesystems can move * dirty pages 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 +2570,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 Mon Aug 21 11:56:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13359343 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 A202FEE4996 for ; Mon, 21 Aug 2023 11:45:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 87E898D0002; Mon, 21 Aug 2023 07:45:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C1C38E0005; Mon, 21 Aug 2023 07:45:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FCE58D0002; Mon, 21 Aug 2023 07:45:42 -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 F28288E0002 for ; Mon, 21 Aug 2023 07:45:41 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B8DF91C9A96 for ; Mon, 21 Aug 2023 11:45:41 +0000 (UTC) X-FDA: 81147932082.06.EF2D33A Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf22.hostedemail.com (Postfix) with ESMTP id 88D68C000D for ; Mon, 21 Aug 2023 11:45:38 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1692618339; 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=496QIw6C5jV7GVvmMfl4tBYrr6HieHOGuCrhHEnGykE=; b=xRmk0h9owxUXAeOqARKd2MHiAEgMtONM9FhPQSqxsLcay2droAhecZm5qiEHLR27OoN+jQ wTPMDV0Ci/d8/maIp4wImyLexpgqmv3rYkARQrdlFvdVXl5PfAjq+EuDtwYIy4aZV7iRbF Vfb1+wqpJH0MrqxKtzcf8TNWCmbm214= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692618339; a=rsa-sha256; cv=none; b=gj8IUwkdNZB5CjNiY9BbXOOh/C77EMgQs1x0UZHIIp+N61yrnSdYNkDnWUA//AXxshMjIS 26oWQxGBs9zUmSjmMFtNeMDtSokxxNEgQkPCYSNSpS0L70PdRfOmKSbjNwxZ80oTr0OW9g +8nQi/rhJJXeg8Db1hL1DLDHMBtxwdg= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RTrDT6tzyzNnKL; Mon, 21 Aug 2023 19:42:01 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) 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; Mon, 21 Aug 2023 19:45:35 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 5/8] mm: migrate: use __folio_test_movable() Date: Mon, 21 Aug 2023 19:56:21 +0800 Message-ID: <20230821115624.158759-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230821115624.158759-1-wangkefeng.wang@huawei.com> References: <20230821115624.158759-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: r36fw5n6cmekyjffhgk3uojcu7kjm3x9 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 88D68C000D X-HE-Tag: 1692618338-777659 X-HE-Meta: U2FsdGVkX181oisLcE3Wkd8xc9+/a4u4NtwrVgboocteQowUZubXgYyrueiPzYjgL0jsKwwtioEC7cfGDNuFzN25aEnt2o0VIytvBwlgf4vH+BdGxb2JB+HTHwieFjK+5VLMBCIS8ALQhpdqX/x35TgVKaU/NITf6x0bIOe/bbtWfa3EoHuxf8LREaDYHC7G4BY328DQ+ww+Vwjo6dyYDk3NjiGORAGWFSwSEZkARz+iAMx5JiAaSr1dbPV+KvEbxN9cqF1o7DXchjTl9r8Zn7M9JDGVwPB7oSnoyaxJ9RqxYFwGeDh8Mm+yw37RH6uUOQwNttcGD8qkFk0G4yBuGHZI1+ACtB5iI2zCblF+zfvvEkOZArVDZzkOg2YLQP15KIbOVAbswm9fxJMQgfqLSxJxpl+oIjC0+yIoyHxv044LKvVrrolsKsRQ3QnGb2i9iNnNaATZniTmr1MkAIN7ASU0QTks3wbBzJDdO2lTY6uVJx3g/DLKLu7W3eCcK09B8R6QZteHW8yW2xGoF34ZMK5gIYmiIgNKyntk3ckTM7NrteUUZ5KvwvCtiyNOSSJ9YZM6j+wsWvowoLfp5sJoHY/0buIh93pAZ7+bG/+JmENa+5mx55yvg0X1cV46BzUx9p/+CTZ5O9BShNbt8ZAyKwLtsNC6j3HvNQjlE9pF0eg4ekL7SJCw5lHo2K/eFYWx/VqmIMMlvTUQDFBCgQgSfEAHgh7nqL10flPLLVzLqVbxqfTsHZkZZPaBtRd/230uJzwjKAWn/0/bZncv4Pr0anNWl5Xp96m47n7jnRQSdZh5Ip7QICKWf/FKS0cikeAzdKWP+TVXVVonGE12VLFajfs/YkfXOOWUOTjXM98+xoAvxgH4PFzWyAxBQgIo1pXMbagN0XQQR4xcVL9m2/vKmQ9dAzYD9wYSZjcFgt9zYLNB43QG7N0dQ9dWTravagNj7kEjtwxWuArwGV8rG/0 l04bHmhm gFBj0SHmB/TGCO1HTwZ5218vP9Fdvoq5HJI0I9lwRiBkaJUEtHrMBimvai1ar0f76RXWZbYhZELmW1W4WiYaD+Y02Fq+qUe7NHV1YWAtXMoKV113+k5N2vlVFEEQs4Zskq5RRavHjFGOhjY74sASs09xrWfwz4tX52e7A94Lq85sf3m3iCNq0BhPMK5Tsyn/PEHvwrs7f2s1MahEb0Slhoqoo8238AKgXc6LPxPhSm7tFDBJlOfnP+VYPdXlgwsOBYjbmH3NSkvxQzWEJlo27s/tUlQ== 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 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 fc728f9a383f..b715cd59bdec 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 Mon Aug 21 11:56:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13359347 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 A12CDEE49AB for ; Mon, 21 Aug 2023 11:45:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 561938E0005; Mon, 21 Aug 2023 07:45:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 496708E0009; Mon, 21 Aug 2023 07:45:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 162C18E0005; Mon, 21 Aug 2023 07:45:43 -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 C9B368E0008 for ; Mon, 21 Aug 2023 07:45:42 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A19FB80BF9 for ; Mon, 21 Aug 2023 11:45:42 +0000 (UTC) X-FDA: 81147932124.04.0B5BABF Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf27.hostedemail.com (Postfix) with ESMTP id D81D240002 for ; Mon, 21 Aug 2023 11:45:39 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1692618340; 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=gYRQXXuBTVIE5GzI3ExSiDKN/ek1HbmSw0AD4SoCzLw=; b=KSgPMwGwIed/gVc4UY2V9iwoecE5XLj2YZL8FemiiRsfE+gQG7z/82zuDnEcwwcr43+iHF lw7CuBlC3YFEdU6ze74GIdtWx1JUJjtQ3Fdqk0LJRdWszk3SOn86scU+8fPJG5Akyddh9w +Rb+8Ma5ByQixM4D1/+ehG7du7w7taY= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692618340; a=rsa-sha256; cv=none; b=YyE/thDtSMhRTRU3TAz8zPC+7/RwTHXfInEnFQevTpdDZiEd4vFdRa2JSzE/8qENVYRk3D wvqdATw4BdR5dZ9gSLbhZyLYOZoYkm2LxptNA3O2ExivwI0tdjBHNwf3R5PDw/gKdJ4tUt RiLrZmBQUV4HuwLV1cIRiNT7z9bGFaE= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RTrDV3ZNWzNnSY; Mon, 21 Aug 2023 19:42:02 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) 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; Mon, 21 Aug 2023 19:45:35 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 6/8] mm: migrate: use a folio in add_page_for_migration() Date: Mon, 21 Aug 2023 19:56:22 +0800 Message-ID: <20230821115624.158759-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230821115624.158759-1-wangkefeng.wang@huawei.com> References: <20230821115624.158759-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: D81D240002 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 9cid48x8ne9p71jskm8b6d3jz1ksm99q X-HE-Tag: 1692618339-961277 X-HE-Meta: U2FsdGVkX1946tHccJcJEwF6geexi6wk6uLC3DJ7uMOmkVFSKLBwluzzylmpw/wB6IkkIHIzoGQI8v3KnuIONNL8GDjsN0DzBQBJZNUtcnZK/8czqLpSthlmwJhRMn7QioSV6kmpB5yGlBpxcbUVUpP9NsydbW0cL5IEzPrGB1yblpdPsszKNiXiBP32+qmKVyALXZ+OMXDwDtX4suQ0SwAmABv94choauTFSZ8joCbW5/DeZ7ddlqQAdOKbh544aL/oB6meniL5o1Zppx4+GoZeqJWQwYWYKByLGIE1vGTtEzqK+pjXJdld/0s/RQn0zHkQAW0e0vnSmrLz9IQPvLbQbyFs5tRmxEEsNpdn5Qqajz5fJ6Jqy3dzRC7Ull3NtoH/UGjrL32Gzs9tSn5fTrcHMnyRViwh47xHqqD4YfmXmKCd3a1E1Ayy4oGRCKsWGpMEEP4c5ZZlXjjTRX0cQHdkzANYcwYpOkZDVTUhSoKPP0HCosmE61gyhbUu0iflHRXwZncarrSPefURSiuHNn8Ci/5XYtRfb+M4zsutUGuc00XKv8eiAo4aUMBOlr/zK3alJNzlPwfIKrvVyksI0tuiKBGzzjALeCcy3pmp5/B9atNPa6LYLhsrP719dHS7LiNPxt36wAYvsdfaqEnMS9ep1YCGAuJbwK8yVLxVC6rUW5nNxekwWvEGKzXxDMyGuLxJtRzKYzyBRMoptK21HmJnqBV8DNI310J1l9DMEYXjX3I4NvmNRb9gU8wTabmjMJDNIAiMTVcOX9lnH+zZ0z/QDCwyWHE+3pg9fTksgQnJiZ/5koEHzrURPj1Dx6/xZFuG2zg4N1Og1jn7xsNcukbc8NRWJVBYKhDUG0KoK53VT5aRkqKijYM0Gkhh+hxbIlrxaLqKAuClR0yA9uggsgPfywMfcSUhGgaOJnlH9DivbnS+lDeKCbyjxXoK9Yo50nodU2AL0hXgW+HxFde wH5uF6jH byRqkGTNgkgqIyr7UmA1tR+tvdpVNPsGK34CDKVBG9bUVbc9YxoKUq9ynljy563CWY26kLQyyjQQK1fJQiEKT/7zaeSOqBUAOwlSTAvUvTjccu0Dk0UIxd1pQS8BwnykQ4sgvQcqg7JzXU238+Hj9APm0QDa6F3103oURhUjW4ARQvPxJkEBnVDiGX9XC2pag0Xo7 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. 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 b715cd59bdec..73572d5a5cd4 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 Mon Aug 21 11:56:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13359342 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 DC2BCEE49AC for ; Mon, 21 Aug 2023 11:45:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A4308E0002; Mon, 21 Aug 2023 07:45:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3ACAB8E0008; Mon, 21 Aug 2023 07:45:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 187A38E0007; Mon, 21 Aug 2023 07:45:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E441F8D000C for ; Mon, 21 Aug 2023 07:45:41 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AE98A1C9A56 for ; Mon, 21 Aug 2023 11:45:41 +0000 (UTC) X-FDA: 81147932082.10.8A704A5 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf26.hostedemail.com (Postfix) with ESMTP id 78F20140007 for ; Mon, 21 Aug 2023 11:45:39 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.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=1692618340; 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=HnLaJls1IH72MtR6jX/8bAnP1g/8utXa1KLvGbePzRo=; b=X5UoLVUVKIEp194X6SZ05eIl8+NUrqiF/Vlfunt2HnIrDTsSVLtDqgPMGShWYsawlWo2F6 ddB5o7PWe/3myE3lLbecokbHYqGy7iWzA02rLddsod8Zj36y2eQYgSivMJCl4EloVMj6Nn 9J0+iiMPZQ8CJN1ERk6XbitsjI5G3YM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692618340; a=rsa-sha256; cv=none; b=Em95k9cM3TOeQjHRwS5LCoifSJSmSfb8L7cOUHEt7HVfWfvyTyOaEIrb1puHlGVyRxjgro 6loqs/qUOCmbcLT9idfe4/kPNFoO3XByO+CYO9CLaapzSNd0LYXiHVQzSCTH3IeyJyTEhm 3n9ewPDDnpKATSoI9OhCUXBLBUWaVbY= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.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.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RTrDW04YzzNnSZ; Mon, 21 Aug 2023 19:42:03 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) 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; Mon, 21 Aug 2023 19:45:36 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 7/8] mm: migrate: remove PageHead() check for HugeTLB in add_page_for_migration() Date: Mon, 21 Aug 2023 19:56:23 +0800 Message-ID: <20230821115624.158759-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230821115624.158759-1-wangkefeng.wang@huawei.com> References: <20230821115624.158759-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 78F20140007 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 91gbyumqq1o8ntct335j3fcsegz7938c X-HE-Tag: 1692618339-56591 X-HE-Meta: U2FsdGVkX1/weC2M7k8rCBERN5pDCuNBvR778Evh4Cxeo3uR4YRkWTR5uGwzJPV1yQ24r5Vm/CUXJ31gGs79/K0dUXsIoMuhoFrXaCMkVagcUnNUCwYn1Qfsv2/QD4yyF9f26uo40Ox1S0ouiWAMnWpODBiHGNkwwdJbbq5Pj/Jvv1ImdxkNx4D00arMLQldnzPyZeBqW83Q/e+XwkCNzEEUjsDpZpWH08J/mf5rZAC/M1HXDR5XuNj71ugcaFnLmqtQioR+Q2OMN3/ef+s/lEKvM0+Xfze7N0DimOVBRgON+SJHfGtajj/C7V7UktXJsGaAWLvQOyo73xFWhkZWbtMNhY5C2ioIyx9OWVa10XrnPMhnbBLyPzDjgpbH8gSaP9Xn7buBnGz33J+TDAcEO7703koJ3dr+0HUNZnhl24wUzHc7W/2ZVL+z81K8P4OgdBGwpoiYdFJ2cLOHpqGm4ePDCByvh+sp5grJIHFNM8YDHBP3/2liMm7dpFjB9Zsng89WcJAV/HHr1j7zG2AN7E2LVPwpmlNZ9SiwYMUTCyC0n668kIK7M8nqx2bQx//k/mxUy/o84NtgDRoycHJ9Gs7GX1uyY9OgomogvmWU5OzT9Xs5/c8GSA66TogOtB0fW1f/cqu7iLmxQ1cCO5DNmn+26pEwTdtbQPkqXISOhqUBY1QRhlht2ThFz3wA65rvax2VECh4KnaFpJNYoVX3blB/8Kwf36U8023cYIZwvk9GmpNifwpBqE2PuBnz4JNuqz0n5tdBiKgtP3pKLRpopICrpZGMU1rzcUMFS/iTo+lIQhPMdUvg1dB+8YtaZvAV2XYFOrphzEUdykjaf+lhBjerZK5VTlucawGEtWNez+GACf9QWgtl1adQB9Oy3uvZrb2ylebc+KmgpoT3kc+zqtruaJsHMiGGeRSQrd5Swy+GiaLirY80i3l35c0/hS6F5cDRmgxdEXLU5i6zURK /0eBgQsl msu4zIPqmb86PuprFWzKMd5dg3iyrhMNvrFQwTR1RaEyHiCkgFh5C0V7Wl+VtHVSmCx/Vr6IXMoRYq9YTWT8SuQ2v8sdvpmMHSrpM9LUosMPmpLoye3tCetgogPX20IZitMH0JRZ/00Ha9QZawrAPzXFEKu3FHQyyYla152qYv9HMPLCZDTVYjiNDeeTj+1TbVRf0rIm1tT03lSOm2eT6j/avpJUXcHzQCOF7NePll9BV8wol/QoTz+V1Strh/eFzVHDhRCW/AgGmVV0I5Gx/N31UgYMOFhdC4cB3ceKEHuYOoI0= 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 Signed-off-by: Kefeng Wang Acked-by: Zi Yan --- mm/migrate.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 73572d5a5cd4..e8c3fb8974f9 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 Mon Aug 21 11:56: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: 13359348 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 B4F77EE49AC for ; Mon, 21 Aug 2023 11:45:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35FCD8E0009; Mon, 21 Aug 2023 07:45:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C3058E0007; Mon, 21 Aug 2023 07:45:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1148D8E0009; Mon, 21 Aug 2023 07:45:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EE4758E0007 for ; Mon, 21 Aug 2023 07:45:45 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CE8081C9163 for ; Mon, 21 Aug 2023 11:45:45 +0000 (UTC) X-FDA: 81147932250.05.074C644 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf07.hostedemail.com (Postfix) with ESMTP id 955A840016 for ; Mon, 21 Aug 2023 11:45:42 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.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=1692618344; 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=n7Yv3QZv9dekqlhiF7Y8pWzu8r2nsq4XL3K8G+3wW/E=; b=V74MtPcxLrIT0XFmO+/l7atZl4mnOxmj1o5XPnJANGZb3PijIEL6HAF4okODtEjfwMdRHU jRdlH4IMDyCbl+R8jeERNkecpRCQ0XNBxbfMywcgz+2T+A4528JZeGuykx48SJc6TOTaaJ XfG84JSb4VRN0PtRN6SsjzVv6CgTd8A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692618344; a=rsa-sha256; cv=none; b=GvADGTbvOni69XpLeSx9/rLoiknlwNLoDeNExkmppxmIBBf8f1KiiYApttTuLrl/ruQG/W IDgVHxlSqEKmbsED1idgyg7TIg7Ebb2lPgkOdBrnVasMQZgKsnz57n8N3XYmGXEQOxwAkZ VUjSCV6j+bZh+rQLa8pRHtmIJmB4xQU= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.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 Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RTrGy70myz1L9Rn; Mon, 21 Aug 2023 19:44:10 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) 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; Mon, 21 Aug 2023 19:45:36 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 8/8] mm: migrate: remove isolated variable in add_page_for_migration() Date: Mon, 21 Aug 2023 19:56:24 +0800 Message-ID: <20230821115624.158759-9-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230821115624.158759-1-wangkefeng.wang@huawei.com> References: <20230821115624.158759-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Stat-Signature: 73bzpkqyeaxpkes1yrb9f1zz7k3m9i3j X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 955A840016 X-Rspam-User: X-HE-Tag: 1692618342-541499 X-HE-Meta: U2FsdGVkX19q5QZj42psnoa29OaTE5D/Yn7RKO/DnnQHAOOqfjVU1UZYoupYpZa+uqKotpWu9CewLIe07Uzo6tALFCw4UqGOeihVpZT/Aktr8D+G5sxJY8rpOdNglbIRM4qkL0qmQgs1YqhiQdnoBI208gDwPwh+KTZG7yjOuNd6TBLsvB27zEFrBDYLGTGBkHU5psOt2o+eNb2ZaMMWZ27HhmB/Sa0LiUTg9AX2uG23AyOAbc4yUBDgRFyDZP6sZqMxOGvtQ8KAL89Pj4BRvYNtnmdCzZuQ/UV8vWDli7EhyuckM9JunPHWM7c5mOVuxN+jxVAVrwfytF0lToRupLYpLZTjueB1No8GaRmKbaWoYRgq0kutkXEL0ippo1JimksYp4Nt+OwFNQZzD7Cz1ZOP9WqUdPsp5l9qVtB3qd09N9jfSpL6oYZHG8KIh1em0zXvNkHXyaaEnddooLSJi7402WtYEa74Olq9bRhGp6VkSJB0KsqRUMZN67rVZIsnuNofv8sHw2yteYSXIFRa0agHm40NdGCZ467NulTrdqfCQCrRn/rYlXaao4daEoJ26r4P0ZWnF1vVkdis1IuZZzLVyfyMBVOZ4Ive/YMegFKGmort7i6MySbJULxi5IOQj2TAynSbSnv1DjTysyxpzTl6yU+SNU+7rE3lyXXel3HzIWYE7StOzZAnkUH+/Yj+F3g7ywgLmtI571sGXo8sgWMVUzaAmr3wQtONMgtrCDWXF8huoKpYcp2k571n1n0O3IGEK7Lj/Pb0hHt7f9KREnw4/5FzkdI+rrtfLpR8XftuXuzHik9AcVx55Rbvjw8uav0V/QgS5KjA4U9kVP4Zt7RQq3nL8zOJ8UncEYr0iy1Lfh4fnlZr5lPezL+B0fZzpPgDlWK4YzHdJieMzsvgxeQdtQ0ieNIzfTyJ/gXtYGtXnlNicDF2I3gxw7bU+hs7+MlwdbPdBqa6Czesm3d ONmJzpRu AFFQ+ngPniBBw/Dyzp+Qhg0btJ2JAqiKeCQ6H9Yc6o7PVTW+Mt348j5wrilZEeobezDQNj6bjVBBRZ5N8KNvX3kGCEcEiwNxV8V4czHX1FsxOxKGxSV2tNgH15nZEleBWmmm5AWHUUerb/Uin33BH25MNzt6B6WAn74DFI6eTaxxrPp+lOenD0CYtLM8r/ENKE3Fm 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. 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 e8c3fb8974f9..9bbd9018ece7 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);