From patchwork Thu Mar 21 03:27:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598364 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 C2D39C54E58 for ; Thu, 21 Mar 2024 03:29:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F22646B0093; Wed, 20 Mar 2024 23:28:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA00D6B0095; Wed, 20 Mar 2024 23:28:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A6306B0095; Wed, 20 Mar 2024 23:28:56 -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 6F03D6B0099 for ; Wed, 20 Mar 2024 23:28:56 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 08BB9C1505 for ; Thu, 21 Mar 2024 03:28:56 +0000 (UTC) X-FDA: 81919614672.16.A60AC41 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf25.hostedemail.com (Postfix) with ESMTP id CFB93A0016; Thu, 21 Mar 2024 03:28:51 +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.190 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=1710991733; 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=0c8E7e9kp1IL6OslTDDHbS61rMdEpOestxLQz5M47wM=; b=fM9Cj1/cMA6Us6rY2/g11lJHiIE+6qsnr2fhEVMzugOsx17VQrl3eE+geHaQhkS2IKsoBv ruNn86Di9ELaLknpU3GLvyfkLxzvAnOdGcuUZUsCpi9Fpoio60DOXXtDVQFnOu4PW6pvB1 iofQHQ7dZuKHicd4y7eCbBl2twlSbdY= 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.190 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710991733; a=rsa-sha256; cv=none; b=LHJs7O/UmX1/LeQOkJDb8/oe1nrKKkcZO3H8Q2o78t5k4UA8l+D5YJWB8ark/aNF5gQGPz WbcMXZ6D0U5siZkigNLoVl/k/AderIGiDUkiICibJEHyVdURIa66/urPSEIy1iT01KvU/I XkXBWl+tUGtsLL1kZX6p7LXRtrf7uns= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4V0W861svxz2BgjS; Thu, 21 Mar 2024 11:26:14 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 4BA6D1400CB; Thu, 21 Mar 2024 11:28:48 +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_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 11:28:47 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 01/11] mm: migrate: simplify __buffer_migrate_folio() Date: Thu, 21 Mar 2024 11:27:37 +0800 Message-ID: <20240321032747.87694-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CFB93A0016 X-Stat-Signature: iceega1d4wrapkof3hyujzfk7n75ooci X-HE-Tag: 1710991731-384963 X-HE-Meta: U2FsdGVkX18PDFBlHWgCr4rQ5KH6gb5IzC+J2kmDpFXca9OPmNQ7XQikXNy9GQXgSqmRwfWFOiHZsAJFBF3ZrF5SEv1EB58UvOYwPSPTMCWYLbs4xFA8oAbS6dcD2tw7P4aHkywBZOWKHpg4jWojM0xyTfc60N3hpikASmOMrznHSfymftITKhQj46xjBLn4LuFbMWsAIhsdJyjE4NPdGhttIdtpm98jFtvG74hvLJbBkZ5OQLeEK7oXxktgFQ4vR+V8WKiKWFQwdL0a63Q8B0cuR0tbYVcYpWTiAmhPfbiCKzpqLNJNIzCYvSdR2mxeb06V95qol0ovTbDR21bO1ZtN2BshcTwLkFLv+RcxHPjRt14tT0HoJBHawBhCaFvgJt+YiWq2D58zm8gUEDXTClIOzERbkf1Z4A9PzFwJL0RxPYMN+YAyFRc3sFbOKvjwz/UWSxHxsUfWdcvGIj/+wGLaFyFXj/GgjP44SDk8xgJEakaHOpCM8invWC61UAzBS6qrElG37WZLBSY0vVIagHlWGCrMmEBX6UTa93NxwtE46JzqO4mIuY2GcUGa8WhzqYw7d3PyW5PgmUFh65QgV2MPdWV5jns+n5zTmL1cD37kzGzt9TUgfyWEw2g83ZVNzGuaC2TELFB6TvBwaawXn3QU7LlT3WueuQyuq7AbXWElI5pY1oR+iv4+FvrWchsgUeMxFn1XBsiKM7y7tL5HMAHQBu8bVHP3WJss1dp9gdH4kKF7G3SvE3eKl0vuWXwce5+x6XJuxNFg5WMegaqQ4uYFKNlXNC8T6yyIYICBDIWmXe5F/cTGuYzsTUxHQ+NXc9+jT5T1YvuOs7i3+RLISfSVG3/KcY3zMd5Ig2ExddEThS0Ljrs3KHYVBAkRDPegAmnA+NcF7hmp5LlJ/7iaLiyH4fM5Ikk2eQeGzoEgzEwI0p/gjvWJuNyzwcJsmvaJLfyuiITDLqxx+WQ95YS es6vHlt6 6LzUo7aON9jQV2SUq/1C8lyRwnUfWcnVkoNSXRVfoJkbrtT+Zwn20MjyNs6Xrsjbqb9DZ1MWZBZNEfUND6yZmBg5ZhuldQxwoX/0yeV301B8mfWysgvMhOKrby8ByhYYW+fWEi0PEpnnIFAxtRYqXdIGkA1gA3xbbP2cQr/yYsghLLt2NxpHS676p74foqvIsChB8mrO1jWNAy78s8xeklyoNBJkqJdzC2vElvd9Hwe+d5CdqHq5/a5SAKeVRQyykCOqM X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use filemap_migrate_folio() helper to simplify __buffer_migrate_folio(). Reviewed-by: Matthew Wilcox (Oracle) Signed-off-by: Kefeng Wang Reviewed-by: Vishal Moola (Oracle) Reviewed-by: Miaohe Lin --- mm/migrate.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 73a052a382f1..cb4cbaa42a35 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -777,24 +777,16 @@ static int __buffer_migrate_folio(struct address_space *mapping, } } - rc = folio_migrate_mapping(mapping, dst, src, 0); + rc = filemap_migrate_folio(mapping, dst, src, mode); if (rc != MIGRATEPAGE_SUCCESS) goto unlock_buffers; - folio_attach_private(dst, folio_detach_private(src)); - bh = head; do { folio_set_bh(bh, dst, bh_offset(bh)); bh = bh->b_this_page; } while (bh != head); - if (mode != MIGRATE_SYNC_NO_COPY) - folio_migrate_copy(dst, src); - else - folio_migrate_flags(dst, src); - - rc = MIGRATEPAGE_SUCCESS; unlock_buffers: if (check_refs) spin_unlock(&mapping->i_private_lock); From patchwork Thu Mar 21 03:27:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598365 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 476DDC54E58 for ; Thu, 21 Mar 2024 03:29:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2C8A6B009A; Wed, 20 Mar 2024 23:28:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BC1236B0099; Wed, 20 Mar 2024 23:28:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96BA36B0095; Wed, 20 Mar 2024 23:28:57 -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 28ACC6B009B for ; Wed, 20 Mar 2024 23:28:57 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 001A7141451 for ; Thu, 21 Mar 2024 03:28:56 +0000 (UTC) X-FDA: 81919614672.14.E0DD555 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf13.hostedemail.com (Postfix) with ESMTP id 85F7520014; Thu, 21 Mar 2024 03:28:53 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1710991734; 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=p7Rro21SYby9XQmy5UCrRBauBgvvyMJXUQxLJbnZyHA=; b=IBd1QEyGHByizuCl95Sl+ByBnfTgYBHDEPfvE0oYZlh0zCb6iZ3lKpkvUBS5ZrdZQLGa7d eVCAMmrInCnNeyVBtMcCMrgikRCyH5tcgGDKPYwqb3cGleEgWo8/05H6Qlg8CWBg3WsbUF MUXnr/O8y5ahRw1pOUTFmUh0OsGVNZM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710991734; a=rsa-sha256; cv=none; b=PxBnxRlOZaetkMGe0QwI4XlaenoFfYS5UZ+L/5DXwAA5GMOoQHsek3g06VUQ/TnKQWFUps +bcAlyw4A9CIvY9VN2444K2ssHvFYwW9ghX1GRTe9hWwXzWZF3EaAq0FJAupNZAFd7ezed q+/gjYyOw7eUnVicKRsjyNZuiF81gW4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4V0W8t6T32zNm8T; Thu, 21 Mar 2024 11:26:54 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id F186014011F; Thu, 21 Mar 2024 11:28:48 +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_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 11:28:48 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 02/11] mm: migrate_device: use more folio in __migrate_device_pages() Date: Thu, 21 Mar 2024 11:27:38 +0800 Message-ID: <20240321032747.87694-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 85F7520014 X-Rspam-User: X-Stat-Signature: hcnp9wpsxfprujzknoxaifzgngg5kctd X-Rspamd-Server: rspam03 X-HE-Tag: 1710991733-541388 X-HE-Meta: U2FsdGVkX1/TXWJcY89xyx/q2jru8oGBvXWFRrItUjbe4TPivH1xEDQ5qs2uby65PpZnOocq25c5pppLOChWWnbz3+bTG69wiJudARECZVsZT6/edy+zQC72ZQi/+V43lIqQp4yVmtmvRn1J9A5RFtDevuhraLp2tApW5yytWjzqj725Tl196yTIIgOqxW1LV7jpW08/Pk2EyTIFRYoun0C2WUMrySbWf2M10fRaCthK9QuZGdyTHzTUik1TGN8+pJKPt57sVy/7/SrJ9Oxi6GFdnv1+uGaTKkLwNpERcEFQQeKym1BODl/Ey8zf4hSnuWSdsH48xSBHWhF0eZ/F3OZSx1O47eY16FtTZNOJ7aYl3MXWa0u9Om8H4Tg6IGbXtggLPe0gEB0Ajf/6hM26b2CbSWCE6tyvNiDNciGeTrVefc8u0WcC5P/FSqS9M3DpWRHf1EbxZCti93Z/MOldaf8QcpoyllVHaybxGuataoTEXIxu1KSRFgADyASSVP52GGrM2t5RUNNX2Ke24Mssz4AxDs7kgEi2t5s+60aTLY1W+GUxZwQp1RzlCn/RtHBbTmkqJFi1Remhmo2B9JRzq3/VjRrmJwZzhy5MrPeYIiwOBbkCyZeHNr8BICJRRrllFgb3ns3mhgnE1fzncvVGuuC58/bRzZjd/gFexbzuML3LVG/jVT8/ZWl3teXqX8+HbYJf9lGFCco+yOFw0N9bB7VxeoCt6Ce1kQOVqvttbY/KYHRrJ1tPbLLaCV8lh6mwtGwKBSkEy5P8aU0lIPMZoKGjs9Se/+HJ2AsfyS15xLbg16aujDbURO6e7Kzsik8TpR354OdYysVn9+vQRqLLVl3Pt2RhJE316R4XU0pUkzdg8TNER5F7YXqp4kPq6DZdKD+IfTeEl0EB1UwF7GQVxJ3CoZptyLnBy6yE32IW9USsAnMI47zmgQoH4ozeDEwDFYPlko6MIYL+LtGie+k TcH4PdxG bb3x89vp+JPzOHYrM41tI0nWkj7MMYchpq1COLou/1FNDwa+JXWx493JKGYQV96Spzc3TeoSZfTMfSQUKDzCAEM4+X+RTw2zK2u+EsiLvHe0AAbSwJhSeIvpO91j3SRCAQBL3W+TesjVDH8g5sNHXVcfCEBtbWZDSih251CT/3r9i4Z+SY57kElESramis+Ry1W0tb+SlgHx3QZpQMzkjcps50qbkAMuTRUy3oCfuItYkwfJGCdz5MrWay3Rx4bnOC4ph X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use newfolio/folio for migrate_folio_extra()/migrate_folio() to save four compound_head() calls. Reviewed-by: Matthew Wilcox (Oracle) Signed-off-by: Kefeng Wang Reviewed-by: Vishal Moola (Oracle) Reviewed-by: Miaohe Lin --- mm/migrate_device.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index b6c27c76e1a0..ee4d60951670 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -694,6 +694,7 @@ static void __migrate_device_pages(unsigned long *src_pfns, struct page *newpage = migrate_pfn_to_page(dst_pfns[i]); struct page *page = migrate_pfn_to_page(src_pfns[i]); struct address_space *mapping; + struct folio *newfolio, *folio; int r; if (!newpage) { @@ -728,14 +729,13 @@ static void __migrate_device_pages(unsigned long *src_pfns, continue; } - mapping = page_mapping(page); + newfolio = page_folio(newpage); + folio = page_folio(page); + mapping = folio_mapping(folio); - if (is_device_private_page(newpage) || - is_device_coherent_page(newpage)) { + if (folio_is_device_private(newfolio) || + folio_is_device_coherent(newfolio)) { if (mapping) { - struct folio *folio; - - folio = page_folio(page); /* * For now only support anonymous memory migrating to @@ -749,7 +749,7 @@ static void __migrate_device_pages(unsigned long *src_pfns, continue; } } - } else if (is_zone_device_page(newpage)) { + } else if (folio_is_zone_device(newfolio)) { /* * Other types of ZONE_DEVICE page are not supported. */ @@ -758,12 +758,11 @@ static void __migrate_device_pages(unsigned long *src_pfns, } if (migrate && migrate->fault_page == page) - r = migrate_folio_extra(mapping, page_folio(newpage), - page_folio(page), + r = migrate_folio_extra(mapping, newfolio, folio, MIGRATE_SYNC_NO_COPY, 1); else - r = migrate_folio(mapping, page_folio(newpage), - page_folio(page), MIGRATE_SYNC_NO_COPY); + r = migrate_folio(mapping, newfolio, folio, + MIGRATE_SYNC_NO_COPY); if (r != MIGRATEPAGE_SUCCESS) src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; } From patchwork Thu Mar 21 03:27:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598363 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 159A7C54E68 for ; Thu, 21 Mar 2024 03:28:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA5E56B0098; Wed, 20 Mar 2024 23:28:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BEDCC6B008C; Wed, 20 Mar 2024 23:28:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 747416B009A; Wed, 20 Mar 2024 23:28:56 -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 4AEDD6B008C for ; Wed, 20 Mar 2024 23:28:56 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 26DF6121542 for ; Thu, 21 Mar 2024 03:28:56 +0000 (UTC) X-FDA: 81919614672.19.AF0D016 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf19.hostedemail.com (Postfix) with ESMTP id E04AC1A0003; Thu, 21 Mar 2024 03:28:52 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710991734; 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=5kHlQguiyY0NIsEqNK4PelI7nnqf6T638TpoAY/bxh0=; b=ykZ69BUxJL/oMhMHPS4GPNxYpUugdFKDzbdcX0G473MhUv+w44zcszEGqBgn9jyOSy/qrs su6iOsyBYNFKC82t4DbSdloH3aRDKWWqttzIG/T3OUGr7U6M1TxnO9InEALjXQNghfh3y9 nxhEku+kHwZbPseF41RSlxGZNuob0/s= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710991734; a=rsa-sha256; cv=none; b=o813MUWduU+rFBsa7EGthWvl5rofusficK/22GLuo6eSqCpVNRtoKjwhcfpiVpDSD3CLEe bRxl4XwZQ0OkVWu8y8PC60ldawj0VkbIz2Bkcf2YsyMYbXIZZXRbUFQ380nkBf+OaESJwU EmmB0J6hwIsvwMb7p25tcGwQPolsNJk= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4V0W875zfSz1h2YJ; Thu, 21 Mar 2024 11:26:15 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id A927E1A0172; Thu, 21 Mar 2024 11:28:49 +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_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 11:28:48 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 03/11] mm: migrate_device: unify migrate folio for MIGRATE_SYNC_NO_COPY Date: Thu, 21 Mar 2024 11:27:39 +0800 Message-ID: <20240321032747.87694-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: E04AC1A0003 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 7wqm64mfxa54eajz1pgbwoyw44rsipe7 X-HE-Tag: 1710991732-702554 X-HE-Meta: U2FsdGVkX1+RVYUAiMnVWFtGUbu61Wo+r0VHwRB2+eaGCoBuhGNPUdvzNlY8iJltnOkKN0A6ExMprLNzh2vpmRw0dMfIwHCTJi9BmIqZnHqRv+IFZ4YDBUJ9pfLtylOVDJmjmF6/c0W8ey0D/fIEcuge9sEnZOnq14GllI8WIEyXa7M8kLzYWAzR+bKd8xYwVc0kcI4Hdept0+f/NRRF71hWKutbpUbMp1FNvkrPvlG1QCr/93lktA1EBayEulyhoQQEBvsgj7oDlOe9frF0+Znc0DXCEJ1zWOiHyfqStiy+dVlCYPql6E0at2KKArxWNfEfFJ6mkuUjR8cmn4B5e/OKAujEbHZSap8Aen44vwHfB8IL/Umd/s13UKf2kOWL9END9WvxEOH7tnssjFwKTHSlDAhpgFuwAEyE06/Dw6depaif3sr0YjNTHgkV6lX/RphnbEZ1KGRXiIZ4L8bu1hPTPAVvn2iIOhpaOxNNGr/ej7O4uPfSxoUXCRqzOAWy+ye3iCInkR20CPbhdgRWUzV8YlYog0IWfY1LKQA3T5+ztfoH4uYEcsAZBDW01Y0IKhBy5u1QgZIlgRbpuf5YvS6Ttzjlrse3Xb5SP5sH0ld+3/cCLkf/7KTlXiTPpdPWs0IEvYGOTNAkaSf3KrrrUHbabeyNtEJ2tQPOVPuvU1Qe3S+UvZdAIjqYeQELqELYjW15ouDSFv6xaPFb90le+3op/u6R/CjnyxbrnheURtov5IzD1V8fPSZSLRjpN/ANp1FbgAz7S4YFxe0Ir9LjbBhTo7gdKKxQpJK4gXFiCXCyXCNil4SFRBnpufIXN6mKTu/1UPvInneYrpXCWRJXcbMbR4x6eFsPGwZd/8FA+XCqhZsTdL7+YvvwpS0lSO73tNgnGXtPZ/uPE7zaEH3Lr/EWX31QQSWCSbR4TYG8407bIjR5KdVxUuO+vCd9HAHJnpGrpPWPvCfVJ/j2giY rkePdwlD 71FPnOD2hGEcmV5MfDzrzpR/OMeHDDMFRs3AR0j73/HlVHszN1F9Gsw/hwcHEK6aBTf2rRBBG62AWATbgGRVH4ybke9J5GICN/mhrQ585wS1ogsxxLLp2yCqE/xAAbK+Fz+ivXqhwRu5NZi9mTuM6NthLajG4iBWFoXyIYpXjI/amtP0+R83NGCcEhfuFbZQYlEPn+THlaMHsJNk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The __migrate_device_pages() won't copy page so MIGRATE_SYNC_NO_COPY passed into migrate_folio()/migrate_folio_extra(), actually a easy way is just to call folio_migrate_mapping()/folio_migrate_flags(), converting it to unify and simplify the migrate device pages, which also remove the only call for MIGRATE_SYNC_NO_COPY. Signed-off-by: Kefeng Wang --- mm/migrate_device.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index ee4d60951670..c0547271eaaa 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -695,7 +695,7 @@ static void __migrate_device_pages(unsigned long *src_pfns, struct page *page = migrate_pfn_to_page(src_pfns[i]); struct address_space *mapping; struct folio *newfolio, *folio; - int r; + int r, extra_cnt = 0; if (!newpage) { src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; @@ -757,14 +757,15 @@ static void __migrate_device_pages(unsigned long *src_pfns, continue; } + BUG_ON(folio_test_writeback(folio)); + if (migrate && migrate->fault_page == page) - r = migrate_folio_extra(mapping, newfolio, folio, - MIGRATE_SYNC_NO_COPY, 1); - else - r = migrate_folio(mapping, newfolio, folio, - MIGRATE_SYNC_NO_COPY); + extra_cnt = 1; + r = folio_migrate_mapping(mapping, newfolio, folio, extra_cnt); if (r != MIGRATEPAGE_SUCCESS) src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; + else + folio_migrate_flags(newfolio, folio); } if (notified) From patchwork Thu Mar 21 03:27:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598366 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 BFE2CC54E58 for ; Thu, 21 Mar 2024 03:29:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D0EB6B0099; Wed, 20 Mar 2024 23:28:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 155096B0095; Wed, 20 Mar 2024 23:28:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDEA46B0096; Wed, 20 Mar 2024 23:28:57 -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 87C4D6B009E for ; Wed, 20 Mar 2024 23:28:57 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4DAAA814EB for ; Thu, 21 Mar 2024 03:28:57 +0000 (UTC) X-FDA: 81919614714.14.C117480 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf04.hostedemail.com (Postfix) with ESMTP id C9E4040009; Thu, 21 Mar 2024 03:28:53 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 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=1710991735; 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=neFvFD6XmKhwmSkGqIVMQMMsXjTLSUt4syOUTN94+tY=; b=0q1EI7/plzhzSHjPqdQVwtSNaFSevBzVZwpOq5a0bWixhlmbasy6T+og2xjwvJoaU3psbi 5Ss/8xt9oidGEVUvE8vkntuJpITLANTW+AsrBW2S0d8j8bVPdTiUHVdv5SRgtIhqtp1191 0PANLCryTdjTxqdud3GJfNmllKeqtuA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710991735; a=rsa-sha256; cv=none; b=5ji/VanlOGf3DQ9S7TwIayx/VPXQs2ugmm476Yh1gF3yKjJBHQ4F/pRmR2zdyJkYswy6am JYrhtukvY7RXmLEb4BNdRNAPCxj7w6krU7kJacedEK0uVXgveF/r2N8U4xKrSl6lxnPvEw WphqCJIZHR6brr3HT0msd0nsn87u3pU= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4V0WBC62zLz1vx7q; Thu, 21 Mar 2024 11:28:03 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 6B7D314037D; Thu, 21 Mar 2024 11:28:50 +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_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 11:28:49 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 04/11] mm: migrate: remove migrate_folio_extra() Date: Thu, 21 Mar 2024 11:27:40 +0800 Message-ID: <20240321032747.87694-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: C9E4040009 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: qde58hdeq7qwxupzoibymcdx74kyrbrw X-HE-Tag: 1710991733-633472 X-HE-Meta: U2FsdGVkX1/1N9N9rdF3gvvmYQryWeP4CStnC51LYhfBDmGsQDBxyo9kUJoHxeIg++qfslHz0QZhC714AT7h1BOIZwymWQOe3LWEwQND2xmmXqbV+6IXHAeLWr47+TWuitbR/vC4HuohMUgcOQXVHgKejBIeaDkA0giwGnnE0Cx2tsoqqpNQZV0EX1Q+EXpaGr+iTSgQsqFEB9JMTI+UzyYQGCjZcyDkYWf8hX+j9yvOjD6o6QGi7OWiaA9rKUPATAzSkHWfGlpAHaN/hO9qrDLK8sMrrFU48wYBV9JOHwcw3RaCh/Ylh6HarkNeuN+sZj5fC0t8fU7u8L3UcG8UDZH9Yo4NyBaQugGS2bufigveZjIuJbaH+eRGydGbvjS3wptKSFwUYp8ajXUx39QfNho9OIacCtMqEyPb9zinC62fLIZ2fNgWTvepwXd00WY9Jbvz/Nqtqs8rWMSvlSQlH3ounxxFStrd7r1ejFHsIJU1+rIVgUW2Yi0K0GRhsh8h1FAud9ywW906vjO7m9xdAt9qAELn18tC4Gmw58/16c1hpvMj7DD79UuWHUk4XLdC2VuNjIYJj/x8VCuh7W+IlQP1vevNyPZ7btAzPFaUMGUYqnQQw/qxy3uNpvjd4PjM8wc/SrFIci/zcBx6UGe6nrTL9sJZ0XI+cWYh8SsiB4/LtqeXbhwbahkHWGem+Jt8SvM5YUbcWOuh8jH+uyqyORFuvg7CxLhDi9XhT4HAum+vHQ1ZOQzUokM98fPUgD/xok7BCHcCZdTSmTay2eKwgj+RdgI6f4iMIDFbifbvhGSgCXjFZmerzTABieKd8MWK9tOZr2NeAFf5cjqm4IHJy9dow6azv9G7Zenqh8CVFtoRcA6hABfI24NmDa78K6M/qYHK1NcjkEjPqdEceyokchWAjhJ8NkH41Ko8CPua04AyhzG/N34HuzaX7i75qvGxH26S3q7o2mQKcE07BaG xj+1x134 PNc6YkM1bgF6v+bE9FVZPrTSYzC0DkAHiBsz6d5og7ujcN4AruyfafSFPalFJSCos2zPBlcKTw0SaPbo/BNfTvEeiU5vqCQu5biPKkiYqTlHwLR3VcLbCegJkmKFxa493e+aq1mhuOiHXsVy5CPsMP3ZuSLJ7pmrgd3QBVDCIFRGe1vs2fC4J5NJZkzgcJ+REmXPT X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The migrate_folio_extra() only called in migrate.c now, convert it a static function and take a new src_private argument which could be shared by migrate_folio() and filemap_migrate_folio() to simplify code a bit. Signed-off-by: Kefeng Wang --- include/linux/migrate.h | 2 -- mm/migrate.c | 33 +++++++++++---------------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 2ce13e8a309b..517f70b70620 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -63,8 +63,6 @@ extern const char *migrate_reason_names[MR_TYPES]; #ifdef CONFIG_MIGRATION void putback_movable_pages(struct list_head *l); -int migrate_folio_extra(struct address_space *mapping, struct folio *dst, - struct folio *src, enum migrate_mode mode, int extra_count); int migrate_folio(struct address_space *mapping, struct folio *dst, struct folio *src, enum migrate_mode mode); int migrate_pages(struct list_head *l, new_folio_t new, free_folio_t free, diff --git a/mm/migrate.c b/mm/migrate.c index cb4cbaa42a35..c006b0b44013 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -658,18 +658,19 @@ EXPORT_SYMBOL(folio_migrate_copy); * Migration functions ***********************************************************/ -int migrate_folio_extra(struct address_space *mapping, struct folio *dst, - struct folio *src, enum migrate_mode mode, int extra_count) +static int __migrate_folio(struct address_space *mapping, struct folio *dst, + struct folio *src, void *src_private, + enum migrate_mode mode) { int rc; - BUG_ON(folio_test_writeback(src)); /* Writeback must be complete */ - - rc = folio_migrate_mapping(mapping, dst, src, extra_count); - + rc = folio_migrate_mapping(mapping, dst, src, 0); if (rc != MIGRATEPAGE_SUCCESS) return rc; + if (src_private) + folio_attach_private(dst, folio_detach_private(src)); + if (mode != MIGRATE_SYNC_NO_COPY) folio_migrate_copy(dst, src); else @@ -690,9 +691,10 @@ int migrate_folio_extra(struct address_space *mapping, struct folio *dst, * Folios are locked upon entry and exit. */ int migrate_folio(struct address_space *mapping, struct folio *dst, - struct folio *src, enum migrate_mode mode) + struct folio *src, enum migrate_mode mode) { - return migrate_folio_extra(mapping, dst, src, mode, 0); + BUG_ON(folio_test_writeback(src)); /* Writeback must be complete */ + return __migrate_folio(mapping, dst, src, NULL, mode); } EXPORT_SYMBOL(migrate_folio); @@ -846,20 +848,7 @@ EXPORT_SYMBOL_GPL(buffer_migrate_folio_norefs); int filemap_migrate_folio(struct address_space *mapping, struct folio *dst, struct folio *src, enum migrate_mode mode) { - int ret; - - ret = folio_migrate_mapping(mapping, dst, src, 0); - if (ret != MIGRATEPAGE_SUCCESS) - return ret; - - if (folio_get_private(src)) - folio_attach_private(dst, folio_detach_private(src)); - - if (mode != MIGRATE_SYNC_NO_COPY) - folio_migrate_copy(dst, src); - else - folio_migrate_flags(dst, src); - return MIGRATEPAGE_SUCCESS; + return __migrate_folio(mapping, dst, src, folio_get_private(src), mode); } EXPORT_SYMBOL_GPL(filemap_migrate_folio); From patchwork Thu Mar 21 03:27:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598367 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 67ED7C54E68 for ; Thu, 21 Mar 2024 03:29:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 860076B0095; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 771436B00A4; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DB266B009B; Wed, 20 Mar 2024 23:28:59 -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 DFF596B009B for ; Wed, 20 Mar 2024 23:28:58 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BB3BD40B6A for ; Thu, 21 Mar 2024 03:28:58 +0000 (UTC) X-FDA: 81919614756.11.272DBF7 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf05.hostedemail.com (Postfix) with ESMTP id 4F0BC10000E; Thu, 21 Mar 2024 03:28:54 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.35 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=1710991736; 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=eDwDBqvuaLo0V3vwemwkd+OPbJ2RUKNKCE3IPdII2D8=; b=o82ET5GlNq6njvZjHSvJiEb44Lj7/soRJFthpkTtIBD+IoB63y3vMHviPuO24UxRuY0dyf ABMgDcM4f8VkDifaYg7eBHQjFrGAfaapDyvW73T5DB1T7B0GkGKX1z69S3A36D5ZmxXJ38 MrHXNwV1zgdxnL8A5uDK/TbfZ/gpPBE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.35 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=1710991736; a=rsa-sha256; cv=none; b=Pwu7L/ztWI0pnHF+OXcxbNdBRVS/B6mVT/hA7FdwxyCbVRmpxwC70Adj4Q6bmIA7hFu1i0 8oCzCqpsL208dP1XZzwPE75cnahKrP5LfPSieX2+d8E2KA/QWAPDZ4OcEPtchgr8CRevsM WjxtmrtjIrocMBZCK+ozzXGhrYqjAoo= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4V0W890Dv0z1R7C0; Thu, 21 Mar 2024 11:26:17 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 63E381A0172; Thu, 21 Mar 2024 11:28:51 +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_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 11:28:50 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 05/11] mm: remove MIGRATE_SYNC_NO_COPY mode Date: Thu, 21 Mar 2024 11:27:41 +0800 Message-ID: <20240321032747.87694-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 4F0BC10000E X-Rspam-User: X-Stat-Signature: d1s9tmw7e8fz4q16w8ecxaaigtkzamx9 X-Rspamd-Server: rspam01 X-HE-Tag: 1710991734-19917 X-HE-Meta: U2FsdGVkX19QyCN3YQd+u25fxHrhcG0waYmwRdqrhQEeZPsuV9N22Tmha4q7uy+HIfAC0cUm8LIBGFx5jbvDU2nL9cpRtpthMsdkgS0ObOVC/aeq9SeSuSjtnqYVKjFTzdlvtL6kgHwrsGXcg6Uljr5DTQPN61VUK4/fCIFVTF2MzwHOgPhZtVeXyXWAicxOKrPgGCpqsTJwH7Hzge5QF7WNIdRPXLkGR+oGB9gwBF1psIBnfWLljU0Ihs4JprOgUa2BYLYzItv1qTZRJCzMvtw/Gs6rR5WjS+EFUd6G/LnD3BgmPHfNfHvzSE6pa2/3f80n46JmfV3NR5vnlyF3OMgLZE/1XG+2SUOuQ0Sc39bCNPrRnchGcgpsBri+sBvtqSJ3QDVk4xWxce7843UYcBK5cfggIzTUDx7zDIG7I0sFfX52IQsKQl0HDMShNu+9Ywy9xsXQHu9wD64iOgZWwf9iwFU58Bszva0UbkvSEnrsVou2mfcL9NJNjaxSWEJYjTWsdDeXeTiNEgUtl3Ry0IchS7Q+2Q/Avv42aKVpyjyu98L3LnfSjPB58Kg4fk17OTAQD0HfdrhNusjsZ51CNWteTvlfzx5BDwzkhykvKR9jo2vP3xc5fwPQgJCHgdqnj+5pK6evYO31or0PHuw5Uec+1QNC/Z2EUCUU5FVGrWRMeLUsjz34zKtdUO4YKQwNmEsNirQNeWSm5O79LoZtcHj7u5mF+MoSRClpBX7Bk5xeYQMytmF+XniqDZ61ewhsfKOM0NTDlNNi1eDsbg1X/9GgjdBtbJlARy+zbqVIGWUyv0qpJ7T5J+Z9gik6wA9xyrlexmu3UEW/nENNoLeLvbtRdCUdnkM7zilH+581HhNW1hnXE3P7J59i+zPg7yJXNv9AzfUuZ3NDIyNgi2MOX8cWTvKH+ygT3n+mkeCFzOHisLA0p+FhDSrgozBivKS0q0VgTGZYWWZhUQ+wF/W UcMJdzXU Fo7nFWrCVQGOxZEN6Pkt9xjPNz+fXY2rA7RURPEiVQhnrvkYlqHe7TI6pl+8yRUsjeEVIgB1iIb9N2ZGj5n19mj1wLU6IOzE0hQLVzmdeSyvxDQnu2FZgav47ttU0O8pTdSkTWypnDmXZm+GcbqYwULhGbAzZGv8G7XoDLDBlmoRjf/2emYwR6VPPlUWPKxA6FW+w X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Commit 2916ecc0f9d4 ("mm/migrate: new migrate mode MIGRATE_SYNC_NO_COPY") introduce a new MIGRATE_SYNC_NO_COPY mode to allow to offload the copy to a device DMA engine, which is only used __migrate_device_pages() to decide whether or not copy the old page, and the MIGRATE_SYNC_NO_COPY mode only set in hmm, as the MIGRATE_SYNC_NO_COPY set is removed by previous cleanup, it seems that we could remove the unnecessary MIGRATE_SYNC_NO_COPY. Signed-off-by: Kefeng Wang --- fs/aio.c | 12 +----------- fs/hugetlbfs/inode.c | 5 +---- include/linux/migrate_mode.h | 5 ----- mm/balloon_compaction.c | 8 -------- mm/migrate.c | 8 +------- mm/zsmalloc.c | 8 -------- 6 files changed, 3 insertions(+), 43 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 9cdaa2faa536..e36849a38f13 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -409,17 +409,7 @@ static int aio_migrate_folio(struct address_space *mapping, struct folio *dst, struct kioctx *ctx; unsigned long flags; pgoff_t idx; - int rc; - - /* - * We cannot support the _NO_COPY case here, because copy needs to - * happen under the ctx->completion_lock. That does not work with the - * migration workflow of MIGRATE_SYNC_NO_COPY. - */ - if (mode == MIGRATE_SYNC_NO_COPY) - return -EINVAL; - - rc = 0; + int rc = 0; /* mapping->i_private_lock here protects against the kioctx teardown. */ spin_lock(&mapping->i_private_lock); diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 6502c7e776d1..d0c496af8d43 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1131,10 +1131,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping, hugetlb_set_folio_subpool(src, NULL); } - if (mode != MIGRATE_SYNC_NO_COPY) - folio_migrate_copy(dst, src); - else - folio_migrate_flags(dst, src); + folio_migrate_copy(dst, src); return MIGRATEPAGE_SUCCESS; } diff --git a/include/linux/migrate_mode.h b/include/linux/migrate_mode.h index f37cc03f9369..9fb482bb7323 100644 --- a/include/linux/migrate_mode.h +++ b/include/linux/migrate_mode.h @@ -7,16 +7,11 @@ * on most operations but not ->writepage as the potential stall time * is too significant * MIGRATE_SYNC will block when migrating pages - * MIGRATE_SYNC_NO_COPY will block when migrating pages but will not copy pages - * with the CPU. Instead, page copy happens outside the migratepage() - * callback and is likely using a DMA engine. See migrate_vma() and HMM - * (mm/hmm.c) for users of this mode. */ enum migrate_mode { MIGRATE_ASYNC, MIGRATE_SYNC_LIGHT, MIGRATE_SYNC, - MIGRATE_SYNC_NO_COPY, }; enum migrate_reason { diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 22c96fed70b5..6597ebea8ae2 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -234,14 +234,6 @@ static int balloon_page_migrate(struct page *newpage, struct page *page, { struct balloon_dev_info *balloon = balloon_page_device(page); - /* - * We can not easily support the no copy case here so ignore it as it - * is unlikely to be used with balloon pages. See include/linux/hmm.h - * for a user of the MIGRATE_SYNC_NO_COPY mode. - */ - if (mode == MIGRATE_SYNC_NO_COPY) - return -EINVAL; - VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(!PageLocked(newpage), newpage); diff --git a/mm/migrate.c b/mm/migrate.c index c006b0b44013..669c6c2a1868 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -671,10 +671,7 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst, if (src_private) folio_attach_private(dst, folio_detach_private(src)); - if (mode != MIGRATE_SYNC_NO_COPY) - folio_migrate_copy(dst, src); - else - folio_migrate_flags(dst, src); + folio_migrate_copy(dst, src); return MIGRATEPAGE_SUCCESS; } @@ -903,7 +900,6 @@ static int fallback_migrate_folio(struct address_space *mapping, /* Only writeback folios in full synchronous migration */ switch (mode) { case MIGRATE_SYNC: - case MIGRATE_SYNC_NO_COPY: break; default: return -EBUSY; @@ -1161,7 +1157,6 @@ static int migrate_folio_unmap(new_folio_t get_new_folio, */ switch (mode) { case MIGRATE_SYNC: - case MIGRATE_SYNC_NO_COPY: break; default: rc = -EBUSY; @@ -1372,7 +1367,6 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio, goto out; switch (mode) { case MIGRATE_SYNC: - case MIGRATE_SYNC_NO_COPY: break; default: goto out; diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 7d7cb3eaabe0..4467cdb1f565 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1752,14 +1752,6 @@ static int zs_page_migrate(struct page *newpage, struct page *page, unsigned long old_obj, new_obj; unsigned int obj_idx; - /* - * We cannot support the _NO_COPY case here, because copy needs to - * happen under the zs lock, which does not work with - * MIGRATE_SYNC_NO_COPY workflow. - */ - if (mode == MIGRATE_SYNC_NO_COPY) - return -EINVAL; - VM_BUG_ON_PAGE(!PageIsolated(page), page); /* The page is locked, so this pointer must remain valid */ From patchwork Thu Mar 21 03:27:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598369 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 6E402C54E68 for ; Thu, 21 Mar 2024 03:29:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15DB06B00A1; Wed, 20 Mar 2024 23:29:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB68C6B009B; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6ABE96B009B; Wed, 20 Mar 2024 23:28:59 -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 319586B00A3 for ; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E20DA12154A for ; Thu, 21 Mar 2024 03:28:58 +0000 (UTC) X-FDA: 81919614756.05.CBD312A Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf10.hostedemail.com (Postfix) with ESMTP id 51D4AC001C; Thu, 21 Mar 2024 03:28:54 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.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=1710991736; 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=5OqRxMEgnmfvIfvFYvfWsTNphKRXKVmHm/AtAv4Ye5c=; b=0iOgatXxKO8byuwkHkyQkFT0rKP0WgALGrymrbMLUTHYs/9/FEEvchAO0Ubi27tjkMaQQS wQvOSW3RZ+KWkn+OjMCDmNcCqK3Qfrd5pR13zwxLgr7Pg1jFOwFX2ocIGo3lDrFaJUXKo1 GNWARmI4/bgk1ILGyVX405Nz5np6TSc= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.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=1710991736; a=rsa-sha256; cv=none; b=gNSaZh9dOjPUKyGjP15wyQ/Z2Q+tsLVSpLeDwHXuoXl/vJB27XIyIJ5dypG7aZU7Z6oFWv jbK+pGhWupPRYx6vQzQgIyhdqMSgODsffIUzOUZH7OH432nf5DUq+06xj7yvP8LxqgAqTN bgHYhF+q39OiNWEkr+hauUqsc9yjN+0= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4V0W8W07vkztQWk; Thu, 21 Mar 2024 11:26:35 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 22A3714011F; Thu, 21 Mar 2024 11:28:52 +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_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 11:28:51 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 06/11] mm: migrate: split folio_migrate_mapping() Date: Thu, 21 Mar 2024 11:27:42 +0800 Message-ID: <20240321032747.87694-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 51D4AC001C X-Stat-Signature: 4bkj9rekazwq9395pbjx81imighgn9ub X-HE-Tag: 1710991734-319350 X-HE-Meta: U2FsdGVkX19M/mxAkp5YTjpY1oSpcuJpIiybXpL/SiHCvWQt18S4pJkiF45cH2sCj+fHGtsVYhqxdSf+uy3uq02FTH09Mpf+KPEEWv9hCwZiYwhUajimGJAY/xhlz6FG1Tm7t1z5RvPAICH+mpRwl62Hhr74lJs/v8ZPAhiatLWtARzGiEQk1aM3JRPPizJ5w6qrvUYFJ3TF5xQVfHLpz6MYnmJMQtdgk52UgTahSzSS3U+d1Jvx/R96h5pmNU0qleoFf39oggrPOx+Cek23qhMDudInh2RW4Xr2yCYO8acOylSL1hF4jLwW4XObLx2ZAyGv9dqTlcRR3AyQFRZYRLZFmS+JTT+qszxZUkfyDCOAifJjtfBEnZcShppbStcHrgwXg+Slu65GyAoPLEeBqD+AeO3Ijb4PoACY1sejPUfeZocm6P+oZWSbswTryVgv0pYS3A+xcX0r+co8iiRtSrT6EkRCUB0EBFeFutOd7dsp5SjrlCVTba+SP0k07u8hwxygNwqVB7eUjY3ZxggtABmB0Itz6Uk/F84/MDXAgjXmKPG90nEh1F0uiz9l9LVKEMxzLWlocybRyHYmKXM/JnuZrUKYS3LebKdSESCyRSC3llbhHDYKbFDlJ6NUakCz4TVHppfjni5232Jkq190H8lSI7NDYHqOQC216sXNCIoH2w0zRDVNNQfbGolge7WqPco1rfBY3+2MxIOoObObAg0A8X2WQfNP5O7iphfJml+iSVfyxDRhtqrBFkvPaNx0Ubn/TmeBv8zY+KQehPq9I+RkNc5orpHfN8aOQfa9MbFZYccWrT1re5yGrxp51Xk2b0Pmv/yabPRv2WnmQQZzaeqVgZTRGJRVbCNs9Y57VCAuYutOfXcUhkBwHRWwcwDoL0SFU56AIAoViJmrTWSuRzpajN+OVYzRYY6bWry/Vq3W0E7Ia+lMKnQV72q4PHWspOHUja3Kb1IFYOqSxSa cgqZTcWe vLk131lNRK6jLSACs3rvXxuxscl3aLsb7BKnBvtiESdFHpNZgmHi+SDa8wiOH/Tq2c9DTSXpOZchFqcBb5vWhgBjyjZIfBAFF7kiYMVUaxHhpuZZgMXZpLV2zaNzrw1l8knAQBUWEmsEEpyui2oMDg+BxFAZ8AozP7QyM6KNLQaXyVMAbhn4FmElULFwZ0rJC1YBuTkw1bzM5PpM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The folio_migrate_mapping() function is splitted into two parts, folio_refs_check_and_freeze() and folio_replace_mapping_and_unfreeze(), also update comment from page to folio. Note, the folio_ref_freeze() is moved out of xas_lock_irq(), since the folio is already isolated and locked during migration, so suppose that there is no functional change. Signed-off-by: Kefeng Wang --- mm/migrate.c | 74 +++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 669c6c2a1868..59c7d66aacba 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -393,50 +393,49 @@ static int folio_expected_refs(struct address_space *mapping, } /* - * Replace the page in the mapping. - * * The number of remaining references must be: - * 1 for anonymous pages without a mapping - * 2 for pages with a mapping - * 3 for pages with a mapping and PagePrivate/PagePrivate2 set. + * 1 for anonymous folios without a mapping + * 2 for folios with a mapping + * 3 for folios with a mapping and PagePrivate/PagePrivate2 set. */ -int folio_migrate_mapping(struct address_space *mapping, - struct folio *newfolio, struct folio *folio, int extra_count) +static int folio_refs_check_and_freeze(struct address_space *mapping, + struct folio *folio, int expected_cnt) +{ + if (!mapping) { + if (folio_ref_count(folio) != expected_cnt) + return -EAGAIN; + } else { + if (!folio_ref_freeze(folio, expected_cnt)) + return -EAGAIN; + } + + return 0; +} + +/* The folio refcount must be freezed if folio with a mapping */ +static void folio_replace_mapping_and_unfreeze(struct address_space *mapping, + struct folio *newfolio, struct folio *folio, int expected_cnt) { XA_STATE(xas, &mapping->i_pages, folio_index(folio)); struct zone *oldzone, *newzone; - int dirty; - int expected_count = folio_expected_refs(mapping, folio) + extra_count; long nr = folio_nr_pages(folio); long entries, i; + int dirty; if (!mapping) { - /* Anonymous page without mapping */ - if (folio_ref_count(folio) != expected_count) - return -EAGAIN; - - /* No turning back from here */ + /* Anonymous folio without mapping */ newfolio->index = folio->index; newfolio->mapping = folio->mapping; if (folio_test_swapbacked(folio)) __folio_set_swapbacked(newfolio); - - return MIGRATEPAGE_SUCCESS; + return; } oldzone = folio_zone(folio); newzone = folio_zone(newfolio); + /* Now we know that no one else is looking at the folio */ xas_lock_irq(&xas); - if (!folio_ref_freeze(folio, expected_count)) { - xas_unlock_irq(&xas); - return -EAGAIN; - } - - /* - * Now we know that no one else is looking at the folio: - * no turning back from here. - */ newfolio->index = folio->index; newfolio->mapping = folio->mapping; folio_ref_add(newfolio, nr); /* add cache reference */ @@ -452,7 +451,7 @@ int folio_migrate_mapping(struct address_space *mapping, entries = 1; } - /* Move dirty while page refs frozen and newpage not yet exposed */ + /* Move dirty while folio refs frozen and newfolio not yet exposed */ dirty = folio_test_dirty(folio); if (dirty) { folio_clear_dirty(folio); @@ -466,22 +465,22 @@ int folio_migrate_mapping(struct address_space *mapping, } /* - * Drop cache reference from old page by unfreezing - * to one less reference. + * Since old folio's refcount freezed, now drop cache reference from + * old folio by unfreezing to one less reference. * We know this isn't the last reference. */ - folio_ref_unfreeze(folio, expected_count - nr); + folio_ref_unfreeze(folio, expected_cnt - nr); xas_unlock(&xas); /* Leave irq disabled to prevent preemption while updating stats */ /* * If moved to a different zone then also account - * the page for that zone. Other VM counters will be + * the folio for that zone. Other VM counters will be * taken care of when we establish references to the - * new page and drop references to the old page. + * new folio and drop references to the old folio. * - * Note that anonymous pages are accounted for + * Note that anonymous folios are accounted for * via NR_FILE_PAGES and NR_ANON_MAPPED if they * are mapped to swap space. */ @@ -518,7 +517,18 @@ int folio_migrate_mapping(struct address_space *mapping, } } local_irq_enable(); +} + +int folio_migrate_mapping(struct address_space *mapping, struct folio *newfolio, + struct folio *folio, int extra_count) +{ + int ret, expected = folio_expected_refs(mapping, folio) + extra_count; + + ret = folio_refs_check_and_freeze(mapping, folio, expected); + if (ret) + return ret; + folio_replace_mapping_and_unfreeze(mapping, newfolio, folio, expected); return MIGRATEPAGE_SUCCESS; } EXPORT_SYMBOL(folio_migrate_mapping); From patchwork Thu Mar 21 03:27:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598368 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 284CCC54E58 for ; Thu, 21 Mar 2024 03:29:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB8BE6B009E; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C27A66B00A3; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F1D46B009E; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4C8496B00A2 for ; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id ECF75121542 for ; Thu, 21 Mar 2024 03:28:58 +0000 (UTC) X-FDA: 81919614756.07.0AD7472 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf05.hostedemail.com (Postfix) with ESMTP id D4E04100009; Thu, 21 Mar 2024 03:28:55 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1710991737; 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=WAp9l1SynGAVFxR2Mu9+GL/AxCEm7zrX917MWkYFaNA=; b=KlRC7++wmXj+sIIGy8RGHsHVeQGLIwQAZxVhEzF6y/1JX1Av+Nj499R6ADvZs7lhyUsh2S LJDjfHkBVZpT3WgNMdib8TLqzJfGKBZMPuiTmv212p6s8Y6xQAnwrLE/5Blg3qOyeIfnnr QqUMRJkyooKVMT7R623LHd8w7fx1J4g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710991737; a=rsa-sha256; cv=none; b=hyHXE3MTbdoglJeb4eNyPsE/SjLMwCJX4cmJS/VT+OgxNyfwl0IDOFYw8Xm2E/ruXYThMg eSNT8ZKiJxhKhO4P20ca8TqTR2Z39WqKcu42hk+gXAR0r40yIMI/J6gUD+ZR2SgAaYMJsP HWrMr5EkdyiD+YQP4/aTXlY0VQo3Drs= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4V0W8z1R7Qz1xs0W; Thu, 21 Mar 2024 11:26:59 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id CCADA1400CB; Thu, 21 Mar 2024 11:28:52 +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_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 11:28:52 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 07/11] mm: add folio_mc_copy() Date: Thu, 21 Mar 2024 11:27:43 +0800 Message-ID: <20240321032747.87694-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Stat-Signature: ggtisbex1h7myo7ickmckcf6iorwie57 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: D4E04100009 X-Rspam-User: X-HE-Tag: 1710991735-610360 X-HE-Meta: U2FsdGVkX18jnarXEQA0boFK5hWAUz6YNRkjlIONkZr8aCgf8MQlUJ+f6JlSxj19Blp512kqeIIVrZOzcD+wD+URBOloR5rH3S5ZvMLRsZiPzPEzIqZoJ5bH8uzU2R27xbwdgPSkz22ouM0HTIVcGtp5rNkXe2CrCQKjgn3ZmWCkK5lW/WkFajrEBz0SbnmDFej93tSUqwiLXCN1Trhg+v5mC6k2rBFAsfI2pcWZAclft57fRXjK4W8Qii6KPMx7RMDN5UyXjpKrIQlQFPgkLs3oXyTJPyUrZ4AUaDi6zMu+qAhgs4BO8Bu4qONu8jovtgVibkHKY7e+1C+j8uAUyWWjg8YhcqxhGJzZ62lpNwyGfYjKrTvgONR3jRtW3DlPgkogBc0h6cKClIaErAtGpYuSLUJZXzLWE95B+Sin4db82LBull3SPCFBuEkTM1lkgNd00KS//dUeMA03waObsz4rOTx35scuJ3A7gwf0XWwN6iyzmDcv7CTC/lHW81/BOkQNO/twtJMr2VzLXTHH7y3Fa6GiidEt2+QNyJdKkqhk67S2ecW+md/0/vpO9S7lNt21G7ko+vAZ6tPzWmMdkasY6jKdYx9oLL2+IDffTKGiKA2xYbEkvnulrMedB83PicHksxaKOnjhC2ZVtF5SQwQJlXP5evE4D131N7pYBE2b5fsbhYhFwzZwbb9MVsPlqCfHBJrCf5My5DTTJ72xjgskEnJS5wDBNf6GHodKdiwnORl1Nqs9DhiuSt0rAZ/IsphoE5ICXez77V3Oy4cV5B1iFpUH95CbKXzVuc6Xmcc1nVwQFv552R2bdzbpefhGXVHnh+3EkKGaNWNQ9d+goeD77r8zdDQdtXAG7V9teX4sim0J8hEPSKWyTp8b+ctr1PEgywfpJd8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add a variant of folio_copy() which use copy_mc_highpage() to support machine check safe copy when folio copy. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 1 + mm/util.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 0436b919f1c7..bd1bc29c38e2 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1312,6 +1312,7 @@ void put_pages_list(struct list_head *pages); void split_page(struct page *page, unsigned int order); void folio_copy(struct folio *dst, struct folio *src); +int folio_mc_copy(struct folio *dst, struct folio *src); unsigned long nr_free_buffer_pages(void); diff --git a/mm/util.c b/mm/util.c index 669397235787..b186d84b28b6 100644 --- a/mm/util.c +++ b/mm/util.c @@ -828,6 +828,26 @@ void folio_copy(struct folio *dst, struct folio *src) } EXPORT_SYMBOL(folio_copy); +int folio_mc_copy(struct folio *dst, struct folio *src) +{ + long nr = folio_nr_pages(src); + long i = 0; + int ret = 0; + + for (;;) { + if (copy_mc_highpage(folio_page(dst, i), folio_page(src, i))) { + ret = -EFAULT; + break; + } + if (++i == nr) + break; + cond_resched(); + } + + return ret; +} +EXPORT_SYMBOL(folio_mc_copy); + int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; int sysctl_overcommit_ratio __read_mostly = 50; unsigned long sysctl_overcommit_kbytes __read_mostly; From patchwork Thu Mar 21 03:27:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598370 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 98F63CD11BF for ; Thu, 21 Mar 2024 03:29:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BFB66B009B; Wed, 20 Mar 2024 23:29:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 721786B00A3; Wed, 20 Mar 2024 23:29:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 526796B009C; Wed, 20 Mar 2024 23:29:00 -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 3423E6B00A3 for ; Wed, 20 Mar 2024 23:29:00 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 12630121542 for ; Thu, 21 Mar 2024 03:29:00 +0000 (UTC) X-FDA: 81919614840.06.D39A0C2 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf15.hostedemail.com (Postfix) with ESMTP id 8F5DFA0005; Thu, 21 Mar 2024 03:28:56 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 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=1710991738; a=rsa-sha256; cv=none; b=4szQvPPbXdIwopEjGzR/LjQiaN7an8/d4NemxCJpjEx1z+dT8vWykOSAjEZvglqocbGYRX TQhORz9mxxkBnp6FShrKp/6XVtWzSPpTu8/YQnUdjmUz9rI/mQaUm+5MKItj8+TBmjr+7V 7SvBXZt0vpvi2uQnme+7+dimGKdGix0= 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.191 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=1710991738; 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=uU0wCRSDtpiRD3wqvB/V+4kSM9hSK9pmnRHpR6N/xFM=; b=AyNUzQvh7/xu5Cw13ule7A8HuZvuB5vIfxDfM9rA6LPLxkwqgIZUv9KOhzaESdUUnn2Xz3 9SJCNZOje5mG9uLYPvFP7t+DwSAgdMhRfcLpYHKLuDHny8qlrY99hCdUJuSxjr/X8Lhg9I TwKNVU2J0cXMzkJnip5QhaFmv5ChEi4= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4V0W8C5CFkz1h2Sq; Thu, 21 Mar 2024 11:26:19 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 8DB961400CB; Thu, 21 Mar 2024 11:28:53 +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_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 11:28:52 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 08/11] mm: migrate: support poisoned recover from migrate folio Date: Thu, 21 Mar 2024 11:27:44 +0800 Message-ID: <20240321032747.87694-9-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8F5DFA0005 X-Stat-Signature: 5oeqy8kg94znfxpbqwzztnx54ftt3hu9 X-HE-Tag: 1710991736-265138 X-HE-Meta: U2FsdGVkX1/5VPOPgI9gDrvGwIRdHEUwjKxlKLVpHWSXLntphVIZxfSiGpZAoSAQKm1LKFnSHL8CbDpHHUKQJUcmh8KF0MFCoFAMz59GQ4/l20JOqSgWO9Y/BoSBQ+xfL5qOFehymo0BIUwK7ZHeFMzcFCCCDUH3dFB7fvCpKmZaFE243rqfwYQNLnOBPAHnWuNZgCarmHOa0a5CoX5p60H7ZUUvMtcROJqB3wYAMDbMSJw5vdsI6HGCRLBWpUbehh7c409Avz019hBWOKYUzzoE+ZXoj0nwC4DcvM/IRDUvQhv1KExotfFXIPIdSS5KzsnGpBuc+urSvN4R/tuJ8PZH1IHD0EHvnwLvAoxcFjGciD4lPBjAdwDB9ENXwAPDqAbZr+2pDLnaosKmq+/fc8y8pCbs6/aovCOXMjVGH3GWpGR/g4auSDjYlQt8Oj7avVsb+Mu4JC8Lgs3FTgJoKLSc8TUeyTTPqoQV463RQC2qJV+Oi33ywtbbPiUdpl+N+KYcidEM6xyd0HD0gP12cZpAJVbJWbIgCnIAnI7w0DA1F3KQKjl8ObrIv77+mQRjbuZVLK8NtcfC8kW6tov3QZuFh7qUDyKRVrtWjA50/YNYXkKnbSSxGPbRUDEFSeci49pM1C2aRUXn+sg7/cqSZdd1t4+APvEAYX87ouJZHiM5MZpEH8ZDzqyng5aLAom1FSUrA1lmdXbi6QhKhO0v49DTJL6IOVN5M9kHP/VpS6KtKNIqOMMcNmJu3aVmGgz9QOkyPnO/WHm708bQ6JRIkDr0K3qWDB6UbjYRwKwgF7+QlChV0SoSDClegSuSqd1cJ/lf1fut9+j8cDgB+jESOTKC27lA3KwgYkr4r5ekFLzWRgqn152ChXKiak/15U6OdkYTCkoQq4IkJdHxlW1q+M5hbE2EyQw+QJiWzb9bcCRUb91+KQp8lxVT0nS4ZyIL6oS8B1sXwKXJ/Cjb7YV /sBbxli6 9kwaPRVQzXeo45yKnpPFyUNbHkBRpw1dfllAYhabFCa5pFV322ttTnu0hecrKC0YFMk5s5BedlAV6GKCxZBZZ2aSLywgTEOW73v0FQ5nvXyt+I2W4Ptz4V3MgsI0lTf89POlvzFo+osK6JiE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The folio migration is widely used in kernel, memory compaction, memory hotplug, soft offline page, numa balance, memory demote/promotion, etc, but once access a poisoned source folio when migrating, the kerenl will panic. There is a mechanism in the kernel to recover from uncorrectable memory errors, ARCH_HAS_COPY_MC, which is already used in other core-mm paths, eg, CoW, khugepaged, coredump, ksm copy, see copy_mc_to_{user,kernel}, copy_mc_{user_}highpage callers. In order to support poisoned folio copy recover from migrate folio, we chose to make folio migration tolerant of memory failures and return error for folio migration, because folio migration is no guarantee of success, this could avoid the similar panic shown below. CPU: 1 PID: 88343 Comm: test_softofflin Kdump: loaded Not tainted 6.6.0 pc : copy_page+0x10/0xc0 lr : copy_highpage+0x38/0x50 ... Call trace: copy_page+0x10/0xc0 folio_copy+0x78/0x90 migrate_folio_extra+0x54/0xa0 move_to_new_folio+0xd8/0x1f0 migrate_folio_move+0xb8/0x300 migrate_pages_batch+0x528/0x788 migrate_pages_sync+0x8c/0x258 migrate_pages+0x440/0x528 soft_offline_in_use_page+0x2ec/0x3c0 soft_offline_page+0x238/0x310 soft_offline_page_store+0x6c/0xc0 dev_attr_store+0x20/0x40 sysfs_kf_write+0x4c/0x68 kernfs_fop_write_iter+0x130/0x1c8 new_sync_write+0xa4/0x138 vfs_write+0x238/0x2d8 ksys_write+0x74/0x110 Signed-off-by: Kefeng Wang --- mm/migrate.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 59c7d66aacba..a31dd2cfc646 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -672,16 +672,25 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst, struct folio *src, void *src_private, enum migrate_mode mode) { - int rc; + int rc, expected_cnt = folio_expected_refs(mapping, src); - rc = folio_migrate_mapping(mapping, dst, src, 0); - if (rc != MIGRATEPAGE_SUCCESS) + rc = folio_refs_check_and_freeze(mapping, src, expected_cnt); + if (rc) return rc; + rc = folio_mc_copy(dst, src); + if (rc) { + if (mapping) + folio_ref_unfreeze(src, expected_cnt); + return rc; + } + + folio_replace_mapping_and_unfreeze(mapping, dst, src, expected_cnt); + if (src_private) folio_attach_private(dst, folio_detach_private(src)); - folio_migrate_copy(dst, src); + folio_migrate_flags(dst, src); return MIGRATEPAGE_SUCCESS; } From patchwork Thu Mar 21 03:27:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598371 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 DFC90C54E68 for ; Thu, 21 Mar 2024 03:29:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26B236B00A7; Wed, 20 Mar 2024 23:29:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A38B6B00A5; Wed, 20 Mar 2024 23:29:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D62F86B00AA; Wed, 20 Mar 2024 23:29:01 -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 A2B0C6B00A3 for ; Wed, 20 Mar 2024 23:29:01 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7DCBF801BA for ; Thu, 21 Mar 2024 03:29:01 +0000 (UTC) X-FDA: 81919614882.25.251E732 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf26.hostedemail.com (Postfix) with ESMTP id 71AA8140010; Thu, 21 Mar 2024 03:28:58 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 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=1710991739; 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=X2GHRlhH8aTEuDCq0p42W7jHL6giIDhZ77iNZJwmisI=; b=jTc3zik17AKWidARNlKqVM8Y6naJPFbVSy1Q0yWNOtpx7uix3+foCczsYWw1J0EO3FBXhO xp0TRnfvIBsbLzosz8G4TtWr+X+DGZi4eLAmgx0jmcXX7u+tjAtKDjhUrF89wOekGlSNUk 6rsSyph96OVkEOo90DgiBUvbWV/sCoQ= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710991739; a=rsa-sha256; cv=none; b=rjk6ZbD4nqOrOdzISvdDSPadgWn+TAr4xy2qcnOn84F7bXObl33omplsde4d4dl65f98po tGgrfdYUslXdvqxMVguobL7Y+2BrdHhABwFoxjDAbfmwM8ZG14SxcACWdAK2AMSl6yyufa F4apIj0uPzCs94n0T9wruQSuR1On3Yc= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4V0WBH50m5z1vxCr; Thu, 21 Mar 2024 11:28:07 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 481061400CA; Thu, 21 Mar 2024 11:28:54 +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_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 11:28:53 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 09/11] fs: hugetlbfs: support poison recover from hugetlbfs_migrate_folio() Date: Thu, 21 Mar 2024 11:27:45 +0800 Message-ID: <20240321032747.87694-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 71AA8140010 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ak3ku6uh48stuhawas7eeox9mf1gqhz8 X-HE-Tag: 1710991738-167976 X-HE-Meta: U2FsdGVkX19HatC5EwvtVOQA72eebUzlKgSbyQn1JGq0FxFtp9+MvgJEPQeU6BJPQVHffDJwBVIPFEfthT1DUDT1QPldcmzMOCxQMRV+Y8286p+kXY2ADdYcka6JXbR/bfyFr9i68ekuRVomka0PJah18UpVwDVAWIR90kQ2ltEV+AFlF+k0rrxVjxuTeYBGqXCZ+lk1dJPL/iBtwectWMlPE4lWmsbNxaM2qag1zh3P4NSO6JyYUyxwY1YgvvKQo7gNlgchCYEa3u3NNqhjKDsqIHHL8PLq/yG6qCXjpAH/4TOCbLasbm/exOvcUPL+0DsTDGUcZlcCU917Ex5J2azDC417pEDetxmfXHHzQ3BtfQsq8jLueC+9ibVB/+i4Bp887VumJRsAFVYH+uO8rx/rSCJU5HdKoQkfzhq78e2IoyvH0rE3d3LCiBfsNWX64JpZCNWFkff5zWD/zu/WqIzUhhI1eegC/Tu7HlBm2L9EBzDxoBFztVx8SWGHPIhKKjWzAyl+6sbfFoz7YIhJKOcqCNmtWRhhoxgjmb0XwD5dBifgm3kUj5h1srRq/HbbXt5Sp32UmU3tTRSO+s/JuqX6zAbV6dSEWmdekk2Pv4m+al6usfFO50zzN6Cj7kx+UdI1K573JupqOaFS8OzeA7uV4isjbCAPGj+8Rqud2p0gCpzLG8Tz7zUDUDIS3oN6tL6VGBBcf5RSbdWVtBFOw6LLnh5KROntMKUS06PCmDYuKNsopVyAWKaSteEn1irA9zyUlPni5Y7ihy96CMZ8VolmLAnSIsmAWC6jcpAu93Zv2hmJEZBrOlWuKICRIkC8bLybNg1cv9JZQWacMY8+B9Ly9Pz0rGgyzkptHz+VGeqznKKSCxMIyI0Dq5daoeD1PQAYxgJJdkU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This is similar to __migrate_folio(), use folio_mc_copy() in HugeTLB folio migration to avoid panic when copy from poisoned folio. Signed-off-by: Kefeng Wang --- fs/hugetlbfs/inode.c | 2 +- mm/migrate.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index d0c496af8d43..e6733f3b6bf1 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1131,7 +1131,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping, hugetlb_set_folio_subpool(src, NULL); } - folio_migrate_copy(dst, src); + folio_migrate_flags(dst, src); return MIGRATEPAGE_SUCCESS; } diff --git a/mm/migrate.c b/mm/migrate.c index a31dd2cfc646..c0e2a26df30b 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -541,15 +541,19 @@ int migrate_huge_page_move_mapping(struct address_space *mapping, struct folio *dst, struct folio *src) { XA_STATE(xas, &mapping->i_pages, folio_index(src)); - int expected_count; + int rc, expected_count = folio_expected_refs(mapping, src); - xas_lock_irq(&xas); - expected_count = folio_expected_refs(mapping, src); - if (!folio_ref_freeze(src, expected_count)) { - xas_unlock_irq(&xas); + if (!folio_ref_freeze(src, expected_count)) return -EAGAIN; + + rc = folio_mc_copy(dst, src); + if (rc) { + folio_ref_unfreeze(src, expected_count); + return rc; } + xas_lock_irq(&xas); + dst->index = src->index; dst->mapping = src->mapping; From patchwork Thu Mar 21 03:27:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598372 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 7E21EC54E68 for ; Thu, 21 Mar 2024 03:29:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 681EB6B00A3; Wed, 20 Mar 2024 23:29:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C2B86B00A6; Wed, 20 Mar 2024 23:29:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 042CD6B00A6; Wed, 20 Mar 2024 23:29:01 -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 C37C86B00A6 for ; Wed, 20 Mar 2024 23:29:01 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A262D80963 for ; Thu, 21 Mar 2024 03:29:01 +0000 (UTC) X-FDA: 81919614882.27.66F3080 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf05.hostedemail.com (Postfix) with ESMTP id 62BDE100005; Thu, 21 Mar 2024 03:28:57 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.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=1710991739; 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=h6Tg1jssGnEQEtsC+7/Br4Zf26AraPHqNWoI9Ccn610=; b=8qAenkns6qGMS3CNIOhpkReKEWDMegIVCeczjrToKDJfkx//I1UtF50cXTL1o+pZaezP8P fFT39zpv5ZSEuaOheIQ8yaBA9h5r8kIMpO8exW+fJejzs9U8/2sMqcEZ3qen3SwHZUq1uw xeyiX8aDwzBEeym1G+KGypK1GD3xYZA= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.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=1710991739; a=rsa-sha256; cv=none; b=Ekh7Rpr5fR0s3A0R34YrZR/8hB6JvAXPC7ngtIuRHDW8IQWFmQEwkhpIfd1mQ/yMaAT8BW dboAkwyptPsp7cWN2V4XoJDgBevlnrLxl/Ei4/mB5QOownLK/qMy8sfFxrTTIaKaqHeMHu t19Pba84oo1OtXBnadJOPLHxGzBahZw= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4V0W8Z226Xz1Q9rf; Thu, 21 Mar 2024 11:26:38 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 3911E14011F; Thu, 21 Mar 2024 11:28:55 +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_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 11:28:54 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 10/11] mm: migrate: remove folio_migrate_copy() Date: Thu, 21 Mar 2024 11:27:46 +0800 Message-ID: <20240321032747.87694-11-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 62BDE100005 X-Rspam-User: X-Stat-Signature: 3e911y3u7zju3u9h5ztx13gay6466wi6 X-Rspamd-Server: rspam01 X-HE-Tag: 1710991737-511761 X-HE-Meta: U2FsdGVkX187W8bsx+G/kUHEwJpJSpJTEkJ+TlEQSOD+StdG+aDzX61LuUTeHe9hK6lrusS6jhnCdkkKZcgxH//nPrxiyFoLGSYeIaGnIKBBsoux1WaD8S1wBtBCjOK4qOjYQpyldADzuC6YqlkXRkB72wUgKxJO9/fCnPGo6jGkLZCj/xNVbdrp6NgZE083dVJxL3GCy3RZMOkJmvu2ldJSKyyb++UqyyM4ilmBGkiDUmGPUMkaiedpkfJoTrS1bkM98qMDbgFuLqakBrVtRVqMPaIAUHv3A/5M6QCzk+65jh0uputTdLdZcw7OVr4QG42JIGvj8bQLVm3+ozUfNGIsoT6IUl+6YPYZ8JF6hYKNiB86zVYf4gtgO4jSRrUZzVuRGBZTSXNB+IThBqCw9lbYiWRbZ9YXdtVFzoTDRh8SMhdMhfVT5qAlR9ek1BygtX1S087TuxzWhYfJCI0OaWoGCwaMu2qD569LaiVVX3UryYxEwrI6XBP8g5MYBYD/mYd+lDVLHVdKIlTv8N5HhKxPTKwzhGIYQsZKS0ff3E804rqUbtAzFGrwxhJBiHouxLG7BU0kBrx2bg78t0afbFnHjBdiO8AQ8ViAQN+agIGTGM1ByMWCPlEb6NpoVyeLPHRNzvmAnwRWnA0coBXY7bw9crv2s/nm8qoLdpzsTP+teWqzDc1d6pLoe7KFB+a/OlkrLwPPaxlHhjmWQ8hrCMKhv4a2UxsEISE6l6OtwfPbcw5rTl9XtH6DxGEVxF7ggxcNw4SZV1hZZGlMa00UPgKaa7CovNFUT6rgVuc7his9o/2a/dmDZMAMBq1u0M+RnqTw/zd19/Cg2qtcK+rgZcQjqDrUQvaQL6y2wZXV4+jhpTfM4zQMkYQSf/EZBNXzLDO+l1WG3yyIUUMJfSP6i1R8coC7g4K5a38SKQBjMyRe9AcSvwY/o+CclBburxtOibeQtM8pN6Ddz0pQKN/ 67WP/aEa 9csVA0ew5XFcDrwwQ5HpGv4Y7c+E6cIyit1RqBsWXG6/zxL4fjYCZsyqlvdB/yqoItPJdcXebWHXb+syqCdTXNbf3DCl/g/Dlej+tSXkZq2c1ayR5bPnZ5MMUgzI2GpDE253bx3b1is9wGGL6UEAId3sFfoL6kXPYpaTBMyy6dqI1+OuG6Fboz77s6nfxniirCXde X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The folio_migrate_copy() is just a wrapper of folio_copy() and folio_migrate_flags(), it is simple and only aio use it for now, unfold it and remove folio_migrate_copy(). Signed-off-by: Kefeng Wang --- fs/aio.c | 3 ++- include/linux/migrate.h | 1 - mm/migrate.c | 7 ------- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index e36849a38f13..9783bb5d81e7 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -454,7 +454,8 @@ static int aio_migrate_folio(struct address_space *mapping, struct folio *dst, * events from being lost. */ spin_lock_irqsave(&ctx->completion_lock, flags); - folio_migrate_copy(dst, src); + folio_copy(dst, src); + folio_migrate_flags(dst, src); BUG_ON(ctx->ring_pages[idx] != &src->page); ctx->ring_pages[idx] = &dst->page; spin_unlock_irqrestore(&ctx->completion_lock, flags); diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 517f70b70620..f9d92482d117 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -76,7 +76,6 @@ int migrate_huge_page_move_mapping(struct address_space *mapping, void migration_entry_wait_on_locked(swp_entry_t entry, spinlock_t *ptl) __releases(ptl); void folio_migrate_flags(struct folio *newfolio, struct folio *folio); -void folio_migrate_copy(struct folio *newfolio, struct folio *folio); int folio_migrate_mapping(struct address_space *mapping, struct folio *newfolio, struct folio *folio, int extra_count); diff --git a/mm/migrate.c b/mm/migrate.c index c0e2a26df30b..2228ca681afb 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -661,13 +661,6 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio) } EXPORT_SYMBOL(folio_migrate_flags); -void folio_migrate_copy(struct folio *newfolio, struct folio *folio) -{ - folio_copy(newfolio, folio); - folio_migrate_flags(newfolio, folio); -} -EXPORT_SYMBOL(folio_migrate_copy); - /************************************************************ * Migration functions ***********************************************************/ From patchwork Thu Mar 21 03:27:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598373 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 DE91EC54E68 for ; Thu, 21 Mar 2024 03:29:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5ED3F6B00A8; Wed, 20 Mar 2024 23:29:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54D306B00AC; Wed, 20 Mar 2024 23:29:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3034A6B00A8; Wed, 20 Mar 2024 23:29:03 -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 E08356B00A8 for ; Wed, 20 Mar 2024 23:29:02 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BB19A141452 for ; Thu, 21 Mar 2024 03:29:02 +0000 (UTC) X-FDA: 81919614924.20.2F4A60E Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf26.hostedemail.com (Postfix) with ESMTP id 7828714000D; Thu, 21 Mar 2024 03:28:59 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710991740; a=rsa-sha256; cv=none; b=bVG0JbWZbS6ohDEjMXv8PZAoEt5f/9lAvCB+Q4RaOlNEOUSHzoUpgCTHVMPTxmQEZOhUQQ Qmy759okbQnscg3bGz+SFDL6Vwddk1z6ce/DcTdgZCXUeX7+8JB2NYh1Q5eWeDULMBSPbC 49WeWQOlT4ZI2rp7SMlGGg0A6TGGZMo= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1710991740; 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=oXxtMGODfvoj7ThNvhj1YnT4i8TnXm3uEl62VQwLTjM=; b=YuYGxpYtrJZsh4eVZeEJEvuU1GGIB1RUeEuC9wafDLKVR12zB8pDrgIUF4DnEmdvhNMdGL yMcmAMA+hjjfsY/Xwhcz5TKjztMU8IDN+Vnz/hE5VZhQha1x+OeXSupZW5Df7liBasWa6d QU8s6hvEJR6XmMJfaCvK/rzl5HVq9TU= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4V0W922JF8z1xsC2; Thu, 21 Mar 2024 11:27:02 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id EA6431A0172; Thu, 21 Mar 2024 11:28:55 +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_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 11:28:55 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 11/11] fs: aio: add explicit check for large folio in aio_migrate_folio() Date: Thu, 21 Mar 2024 11:27:47 +0800 Message-ID: <20240321032747.87694-12-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 7828714000D X-Stat-Signature: e5gi5t7zwh9sfng4qewjp7zwej3cmoqo X-Rspam-User: X-HE-Tag: 1710991739-401551 X-HE-Meta: U2FsdGVkX19R+Cxp4vyUCLPbrfIqqNDPbqjZhNso2jRJXQKoA5qrEEizZ1HdKrPWlWKIItVEje5EdPugpc1i+KhCJoDgrApjggN/Mavrmd2GvFHOR4l9rNAjr2iBp/ca03LmSV/tsPQ8UULf80rPmzt5yXrvDvgNygqow6ph4uoAXMt0FLKTzl4UlEbEMwN9IuK8/7NbJgTduUik6rzGmEPtk2hFT8mYD0FpEuUMynXFDRVCoy70sQBzrmnORRjQjBgaqOZAwki6oykTyYQxGaWdbyavPiePT44tkeoE3ULcJwP/8C8xVSjUOcAUGe50+Lj2Nh+aoOM8sbsniLa4RLXEOPHEAh3cifa5vidT5U/lDj0QHTyNdu9/IdoxFVlXp7C9lkpfH75ViP83e/HBMhmjyz+HutlhQY1PtwZOyZhx5V0rDFGwyGHutLUxcjruYulLQTU5tYhFvHc87RIGpbGGXM2gKGIjbnzrOEOFLjcsTcxfk8osidOr0dMrLusBqP5H5081sFQ/3tOdeFW9zHl33sNA4i49yeS76bARM/ieIgnsXuPnJ2uun6BU/FhyPHt1EDk+x8Zx4/qasKP61Qm6QjIuM9fkWMdOGOl/syiLfWckq8REWshUDckqe8PO08Zc0g9EX03VI3XV1+ntPvexvUi6V/jfnn89dXBfPkQioOEQv7kAI64PatSRBb9MqATT+jsput0e1qqRfL4pb1Nruv6DEuRJW6hSPyerY+BWrZ3cs/6lFDqs+mSA0pLTqnLNnLGsqw2yllnFkPDZqNetmqI/TYTrnkpGiFKXzH5e5tyAZRjyuW4WkM4uWjye9fRyy6QEu2wuq+B4UxC1rL0wLuMZx/nqMLM+rBXxb5xcgcmtju7rAoUSVtgks5QVv0pzaTvFbZf+qBi4Man6wG6WNbkdeK+vwoz1CUJkdL7SrTPo2HgAwShQSD78ZIHYgOGuQD4fzxrUvuU78gW z7GV/uUq bhtYUSoyxS9W43QtY4q/37aO6HhxjeemT0pSdCCAXCsYGCbIgKHrlZ+s9IcCGcEJkTsgKjTcvrBo+DZOiN2bLRKxBxVMAGw+k4AoqpSlen2edLNzdbZfbRHtQbO1DlJGD/SoAmia0wLfPtEXDSpVmHH4f0AHl46OQIcCqZv3Mvc74MxLzxz+0IV+xJroRm0Ue5stT X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Since large folio copy could spend lots of time and it is involved with a cond_resched(), the aio couldn't support migrate large folio as it takes a spin lock when folio copy, add explicit check for large folio and return err directly. Signed-off-by: Kefeng Wang --- fs/aio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/aio.c b/fs/aio.c index 9783bb5d81e7..0391ef58c564 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -411,6 +411,10 @@ static int aio_migrate_folio(struct address_space *mapping, struct folio *dst, pgoff_t idx; int rc = 0; + /* Large folios aren't supported */ + if (folio_test_large(src)) + return -EINVAL; + /* mapping->i_private_lock here protects against the kioctx teardown. */ spin_lock(&mapping->i_private_lock); ctx = mapping->i_private_data;