From patchwork Fri May 24 05:28: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: 13672720 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 46123C25B7D for ; Fri, 24 May 2024 05:29:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC4246B0088; Fri, 24 May 2024 01:29:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D58A86B008A; Fri, 24 May 2024 01:29:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B58486B008C; Fri, 24 May 2024 01:29:22 -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 95D766B0089 for ; Fri, 24 May 2024 01:29:22 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 475A580884 for ; Fri, 24 May 2024 05:29:22 +0000 (UTC) X-FDA: 82152161364.17.BFDBC26 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf23.hostedemail.com (Postfix) with ESMTP id A6E77140013; Fri, 24 May 2024 05:29:18 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.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=1716528560; 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=kSpveyLV3EbSeZx4zQOd0tiQD0sHw6XYtVTvi3tA16U=; b=2pNW7XIyCJIUawTgOBDPfNgS3z5wqHWx5dEU4Hw115lDxRwyiDzgtez49Oia5RBzX95Lt3 MOYsfahBM9FXS/ZmvzVDj731x/sKOc8qpYGMIffTistSDti1zCXhCU9auRyTG2zb5w7nRX F8Hy2wrYzlUGo0wpDh3U6MQoehsa7rY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.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=1716528560; a=rsa-sha256; cv=none; b=zHs0mGSXTO2buckrblo6eaYPq5mKf+OjyROmMBLaOduy1P6JwGa2BjFpgZgMX0lJTz72qU aUqLC7cPVi2cCexY0nBn5D5GaxLYTozt66r3XxaoqHauGNtifww53f84BnPTby5l271mm9 MRjGrCBgvok0N+9uLh0JzqZFmejDSIk= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Vltq02m8BzcjWl; Fri, 24 May 2024 13:27:56 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id C8C2F18007E; Fri, 24 May 2024 13:29:14 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 24 May 2024 13:29:14 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Kefeng Wang Subject: [PATCH 1/5] mm: migrate: simplify __buffer_migrate_folio() Date: Fri, 24 May 2024 13:28:39 +0800 Message-ID: <20240524052843.182275-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240524052843.182275-1-wangkefeng.wang@huawei.com> References: <20240524052843.182275-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A6E77140013 X-Stat-Signature: d3uw3qysi7a1enhswhpiyqaaf89aoaep X-Rspam-User: X-HE-Tag: 1716528558-937546 X-HE-Meta: U2FsdGVkX1/kbgOUEY5orhhD70MgrJGVt0KaBWRuf1csUxnRpGFAJrPwBhMl8I+786Ltby5jOkvH5qWov4qoOc3qf64VddFmQT1DFiCX3jGnZRpKipJ7ehuDTVNGcDvyy3Q3MyQQU3KLLLGHBsnEW1ThlW5Mgf6ICRGEnomt7KUWoJNa+XIXlX2+Van8AetN4/uy9rsSAlqbjlfoqBtSOXlM3UrHvf/DCFdmznVA5+F5MJKU81l5yv1gmKSXpN7uimaUCte6xTj5P4NdHdaCWmpGmUy04fnTz8MmJf6JxeUQZum9GOGxhkQ6v8rPgIvO3Rach2lrmq03X5roznN0TaEpM/mkL938Ux3orDpLhL2fDyHx/swmisWrwahUgiQEd0yUYVL3ySdXcXaP0upGs97V9B8Gbas7OICEOIhq5iR5HkkcTzf+KLvRQhKKXCZh0umSIp4tdEBUs2gQY5ZXe6fUJKYxFObtU+J6s3l65OK8Y2kSeMABFvoSacjwmk+Tys1WxUKo0W/KPAvlotVm6f4r3TIp+BJ0OoEjdk7O/iur1O/Kp0f3wApyOddNAY0uDUOm4Ev/jqro0pnP/aJz8Bv1Qdm3qLQLYz4o7FvsM/JaRZVZu+FeacdRIaDdMSLFZeRpJza2vhuGs6AP6tiMJCJlRkoWebTcGMUCj5enDMWXxS6PLyYDBYLzf8pjW2Q2LPzAiORFriBq82JM0oRw5kES5Wm509lmmw/+xDwcBi0fzwV38uVHZc++t+Sdnu3W1vcAlfusVzMFOzIqq6RSDOCqhYsb6VMmbF9rxQzZqPyP30ZEbSTKaK/qfKXm/eYEFRD0Pj2s9X16hJAJZTyNsZ/2cqpiS7os0gcrq7OvMgcakaEAczy/BRYyKDXYVzZx1SiQCvXJQm4XuMmUp9i0uQeymOvIZzzMjA/F2xFh9WWLUtqvj4SC8OSEUJCPxsUqUeMWaB/h3RrDUP9FBYW +X6Uf9+X HX/Tns0CXSqB3C4j20Z1Oxzcrk52Itrb6GQh0aO67Ve2eSXZdEkqsNtIFnr6G8ZoQFqvghXFNO76FD/8+UqxPSakztkbdNqk2H6zuQ63jVTM2waBBHHB2vkOFTsPwwkT9RQTTCmbwER7Ows0wZmJFYZdxhwHBTkbzwX/PkdantPLQ+8DugHu4v3atzFN4w18obARCIwNaECsxodN7wSy0QoGNU+DBiurE/CaF0JBJRJAFBf+t8BmHvPE1BAgwMjI5kIzyWzIr/E2o4v/dMRtKuY37EjrDViRgCUPDruwLl0e0zfX3YwAEVRS3z2FmdQN3WzzNjqlFmorlM4kjk0GJ7pHNwv0xYLOAEKy8 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) Reviewed-by: Vishal Moola (Oracle) Reviewed-by: Miaohe Lin Signed-off-by: Kefeng Wang --- mm/migrate.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index dd04f578c19c..159f737501e1 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 Fri May 24 05:28: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: 13672721 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 7029EC25B7A for ; Fri, 24 May 2024 05:29:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E17A66B008A; Fri, 24 May 2024 01:29:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC4B36B008C; Fri, 24 May 2024 01:29:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C17C16B0092; Fri, 24 May 2024 01:29:23 -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 9CC7E6B008C for ; Fri, 24 May 2024 01:29:23 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 53AADC087D for ; Fri, 24 May 2024 05:29:23 +0000 (UTC) X-FDA: 82152161406.09.3657A9F Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf01.hostedemail.com (Postfix) with ESMTP id AF4104001F; Fri, 24 May 2024 05:29:20 +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.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=1716528561; 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=MRKLb1JgakbWd7i8F4UuBmHSAShxsfei2gxNvpAs8ME=; b=7Umy7xnOyx/Anq4uqi5QfuT+KopmNCb+6QerG7wWL/Lc44VBgWUojPcGwdRC2SMG6pTpKR zP2/JhoYczaEFWhFpVYYPw6keVs4Hv52icW2brcdaDZZuOAEFzGU31XjdlruY+9XUzHtUY +n4rstSfzK9dUyY6AG60btRF+ooyi70= 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.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716528561; a=rsa-sha256; cv=none; b=WDOe6nuWFhU4IwLH5jPWGwqCHZlsZhvXjs0Hc+N8vWZEAC8ChnTCxCpFMmeW74sImmbo7Y Ye9kebzD4tYTSDNljBkcu9u3uLYt4lNZs7pk8HYbf+TC26iePjknGvOxj4xWmwpJg4F6Pc p45qU7YDfgqNllDC4fTra0ORuMv1pk8= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Vltq10YmYzcjWn; Fri, 24 May 2024 13:27:57 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 7E19218007E; Fri, 24 May 2024 13:29:15 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 24 May 2024 13:29:14 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Kefeng Wang Subject: [PATCH 2/5] mm: migrate_device: use a newfolio in __migrate_device_pages() Date: Fri, 24 May 2024 13:28:40 +0800 Message-ID: <20240524052843.182275-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240524052843.182275-1-wangkefeng.wang@huawei.com> References: <20240524052843.182275-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: AF4104001F X-Stat-Signature: e6u1tzempou3cgrpqr3jiwemb1ia9a7e X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1716528560-36843 X-HE-Meta: U2FsdGVkX1+4BhYcVju9XyK+KPOJG5yL9kQFw4lBcLF6TM7T/NLftpDfEVCxBd4r7WUWYRR5QsKo/PZEMyWN7HGXm1LoBspfL7zCHOfAHAkmRX26tc1yKKKe7C5D51ePGKCHJC0aKl2HGKBeVD/BQaDp1lDXZ5sIPHaEQI551aqvp0CDb2A2OU9EnNGS+PRr96NeRXPu44FEU+wZ6+vQPSS1zdBsAdNkaluWQlLo/vnT4/ZVMCZejGI85iXtl8VEQTFYvSTsHpTw1jMlwHn2+wOdSpW1pZUujvJ4Uv5MsEqNowgwnUkV10cLeN0ZzVR8cqtK7gKPrxcxF0G+I4ake/ygNN1BERTFtNemXm6QJNXi7MlYRKlTzJGn0YgaFJbTeMQ9KOGu9eXy21y/cwmCmiLIJG8FHS7N7u0ZFYHtS26G43nfSR/fpckpjzTGFEuN6SVP4cgQ1LJ4TRJvknMc/Ipc11pt4JGxHYz8VHILFPQSu1Sq/3HnwaoSTFqVzoivEMlOEDSl/LDCzxtSXSB3fBLBf7VFID6r9qAhAT3oe9DPMef8xsUwmXOXZmZ6J6wKAI2fgEuuz+cQ+f49tUOfyl8hjb856Xg6VGc4czaFGHzspWYV+1gXHIlrFYLeuLGRlF8gIAhMJOsMDDdyN3+T17ZkVkjJ9/Z1QzzX4Vk3hUUC3Omycxk9sDdxMWzCIcOvSa5Llbi7A1H6XjXglfOWVuKK/VpirbTZncXQsgFoRV5TdUYVwywvZyvCOFM2K8soAEvva1o3xVeGSpzDI3uWP+JO14jvm10eKx/U0ntvCPmdY0YpGe6/eG9OAgRq9mkyebpV/NSM4CfrxqhB8NHk5zYCpHaLPd4r+WpUK96jXyKDZZqdf52A4FGdKAH26HNna+DV1TPPrZhgXktA7WgGlAInFQbQEDuXm9ppByPJJZjLfxKpgZPNkvf9wLOZySJq2/3HTW/T9nzmS2bAS4P m2DhpE21 0FNN/KxZNtgiaBoI/Sp3ukDfJZeNcg5ad3zdvZ/c98geLoulse2qj2rCptfbw5+nQJWXbmEUG9nSzlfnWv9QIKPO4+qLT21xmaU9BS9QHv+gozUW7ZbKrXW9HwLKvJJs0siaIZEO37csbEuqLm+A5k29RjMaVcijNIh6OJ8Y98m+bqPPT6ncHGOvvu8VkMH9OdOci0hXgEceBJz76fPbJeP7HzDj75wUFHeob2Wq7753OEcKRrfmQ3GLFRfj9tE2nHAL3hLcQjhPCP/MfyQdSwCzUgrZdUZqMmFZUaXQYmVtvuLuXyL8CppPO6Jdhff4KAdP+lcCafmmo7mp5ixmMzQrjElmzYTpcT1/c 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 a newfolio instead of newpage and convert to more folio api in __migrate_device_pages(). Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Vishal Moola (Oracle) Reviewed-by: Miaohe Lin Signed-off-by: Kefeng Wang --- mm/migrate_device.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index aecc71972a87..f5e034de718a 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -692,7 +692,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 *folio; + struct folio *newfolio, *folio; int r; if (!newpage) { @@ -727,11 +727,12 @@ static void __migrate_device_pages(unsigned long *src_pfns, continue; } + 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) { /* * For now only support anonymous memory migrating to @@ -745,7 +746,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. */ @@ -754,11 +755,11 @@ static void __migrate_device_pages(unsigned long *src_pfns, } if (migrate && migrate->fault_page == page) - r = migrate_folio_extra(mapping, page_folio(newpage), - folio, MIGRATE_SYNC_NO_COPY, 1); + r = migrate_folio_extra(mapping, newfolio, folio, + MIGRATE_SYNC_NO_COPY, 1); else - r = migrate_folio(mapping, page_folio(newpage), - folio, 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 Fri May 24 05:28:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13672722 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 700F1C25B7A for ; Fri, 24 May 2024 05:29:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0593E6B0093; Fri, 24 May 2024 01:29:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 009036B0095; Fri, 24 May 2024 01:29:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E39C76B0096; Fri, 24 May 2024 01:29:37 -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 C72B26B0093 for ; Fri, 24 May 2024 01:29:37 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 473DC1A0897 for ; Fri, 24 May 2024 05:29:37 +0000 (UTC) X-FDA: 82152161994.29.73B6E0E Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf10.hostedemail.com (Postfix) with ESMTP id 8C57DC0004; Fri, 24 May 2024 05:29:34 +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.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716528575; 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=EXbpickgsmubOLau9igLhNAjj/mdYTEFDnBj3Q/gvE8=; b=dqkwLxQt44RlJw8UsaZPbExEhLFl7XPUKoBMbRxmqgO7oZkYmofaHHzkzXiMQueRdBaYwV 10aCfXPusMeRWTc7SPLwe+VKtEehYbuXWuoJ6qYrM5uYR7f5i8s/c+cwyzgWgd95KQ9I/w QHQNIj0RNmtDvAH5Mv8VGLDfh1RaVXw= 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.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716528575; a=rsa-sha256; cv=none; b=VfB3kw0NTcn8YM2TkVyFehW1Stvfp48bk8WrFm5Lbik6CBTC1jDK9xn57jNVXPbBDjPnYl XKAAnVYzB9/DEgar2XcbjFklo8KSgMtOuRMHDJey5UPHoKngeXe6wCZThyYUprh0rTvSe0 5McoeSxRWmmSKko5vZkIcnZJcibFcFw= Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4VltnH12HbzPmcq; Fri, 24 May 2024 13:26:27 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 2B9561800CB; Fri, 24 May 2024 13:29:16 +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; Fri, 24 May 2024 13:29:15 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Kefeng Wang Subject: [PATCH 3/5] mm: migrate_device: unify migrate folio for MIGRATE_SYNC_NO_COPY Date: Fri, 24 May 2024 13:28:41 +0800 Message-ID: <20240524052843.182275-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240524052843.182275-1-wangkefeng.wang@huawei.com> References: <20240524052843.182275-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 8C57DC0004 X-Stat-Signature: 84a7q7hzgzn5z8hb9fied5cdue1ra3rx X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1716528574-381248 X-HE-Meta: U2FsdGVkX1/YESsVdOdqewO7ZAOULskszspYjMfcXlb0AKAj9XjqptPK4rpqoTUH9LXu+grrh70nykrQMsC1RKtJ+9tWwAj40eI/k74wp5SzuJcZHTmLdiop8XtIPmzEG6wpdBCfaKE92jxjJlBWdhuAMPBITC7QC+HUkjDBEGW4vM5EDP+8hLld95YwCs6IlzfdxDv4N1OS60nbGDLWghtx3mj2Mwb0M+wLxN0l/bMzqbF0e8HSkTDcy8SD+eitClH8bZ06pnVWkEvxNR6bqN+iDR3qrV23dxlGWgEk44r0Mog4tf4pBVOgpga/QC4HGHvOg7tDgNJEBTIfGw6qnQGFv6kSKbU61Kv/qw6rwRchiv8wps/g1/VSsClOE14zj27ejj74sKDaRLTxapc+t7k4cq2xnAl6dwYja5RmP2HGOfNfwTrsGGbufnjl7d8Lr01uRLnjrDK7i2f72RAV/kAsfl3GgU59Cn0bRtLiPOxqY9O+nTOzv1mIQXI939biskpg1VxiO0P2vJhf2iB4c/NkAz4/bnrStl3E/0Mhl4CBl5+3ojxJA2WZwU1MjaKzddoDetDyg2iJLrYAJGqM3iYAzxYcnf3dwZ3Lu52P6tCA4Dpfx9XDIJB7ir5W/udMzx//PE/lJgKpJDPO5IUy1F7O+5YVschdGAtZkPYqgTVPYOM6n+29XDIrMrEnVdnTEh6nu8omeF7vqgGfYQq+oJnDSz8Xp9bbiuopg/HmqXMA1ScnmRY0hC3DlkPpuueUkwzleGPrFQuJCIlsS/hRwDi+Ioy9w8EywohMyVO+9Ap6bebOX10vbbtPl88xWtO+nWjTj7Tz4YQDd20q32PpoS97T1lvpKDknvmL2X/H5ViTdEO7vuiagz5BcCsRzitVpsjgoEHtPsHWQKa3qX5eyTKT/K54CQp7e1aptr8BJisvp399VCx0bVR7dIOrMF4Y7xx7GdqeP1dut/8yZKn eD4KQbzp U9eVZ9WgTprjuntPDajq4dmxoL545Imqp1RlHGgwQUdxyKEpMHoiFmNVm61FPBhNU9M/iTWTHumBKAQy5QTb+4j5d0JwqgPWQibeU2uotn07VIpJyW+yzCkrjJZGE6Y8hsnKvuXBKM5Tt9ydnJ6c27JVO6ASnS3O/ktiCbg7D+3Rn717/Zp9KnPxoF8R2JHhZbr7QZod5EagLZKIlm9OK4aPmWmS9+2o7AH5ZlFnhhR5eGvFjgkwEPWEmqUS1a28/a6AxYDkEh3g8d0g= 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 Reviewed-by:  Jane Chu --- 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 f5e034de718a..051d0a3ccbee 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -693,7 +693,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; @@ -754,14 +754,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 Fri May 24 05:28: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: 13672723 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 8ACAFC25B7A for ; Fri, 24 May 2024 05:29:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 207296B0096; Fri, 24 May 2024 01:29:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B6756B0099; Fri, 24 May 2024 01:29:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D2376B0096; Fri, 24 May 2024 01:29:53 -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 E088F6B0096 for ; Fri, 24 May 2024 01:29:52 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9DA9B1608BD for ; Fri, 24 May 2024 05:29:52 +0000 (UTC) X-FDA: 82152162624.20.ADA4500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf28.hostedemail.com (Postfix) with ESMTP id BCD06C0008; Fri, 24 May 2024 05:29:49 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716528590; 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=7LINns6u6XINepRudvhCLzjVAhVYTKUd8WDvD2mfO8E=; b=gXd/IK4NFbk5sAFejw+L2r9huZHXR3HbBSo6LxSY0mP8pUhVrD5SB96S5rgfo9MKSoeo9d lMHUqVXwOfz42Fx1sfbSxrxwppDei62Zzlu2SbqD+Zvi3xQ+rW+LEnmVe809AcXKt/MaM8 /0WPhU932X9des0kOmyhTeTv/EymFUE= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716528590; a=rsa-sha256; cv=none; b=oCSRGI1RizK/4N7sO7UbU/MAGsBe1yomaT05/rnlD+6L4i9Lw+NhtDLqoHD/wblZ5JYf3T y4g4uNzp1l+P6NdbDPSFw6+Iaex0r5Grr71lW0Y6Fmg5YunXF29WNiZcUtv+jyJibnLKe+ ny4sPZs/W3FAB5A0Fu3YgN9czW4hCPM= Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4VltnZ18qbzPmcb; Fri, 24 May 2024 13:26:42 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 306671800BC; Fri, 24 May 2024 13:29:31 +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; Fri, 24 May 2024 13:29:16 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Kefeng Wang Subject: [PATCH 4/5] mm: migrate: remove migrate_folio_extra() Date: Fri, 24 May 2024 13:28:42 +0800 Message-ID: <20240524052843.182275-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240524052843.182275-1-wangkefeng.wang@huawei.com> References: <20240524052843.182275-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: BCD06C0008 X-Stat-Signature: rtso1zegxqws9dctsskeitn6z4nf65ze X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1716528589-994116 X-HE-Meta: U2FsdGVkX1/GvGEycC3b4U3+XG1Emht2zI83kvePLsiJbGkH+Ek46sKrUZnPDiCYTf+HD9hFQJhLNEMRGpYB2kGRNvpjco93sZqDdvIFxNbUnfX73rUuPvCKy8SLcMWX4We9msI2DvRZquX5+dOLpckYf0TXhPMW9RkeA6KI7gldk2tpljhZufB5S2SvNhGiAy0BAUP1otLPF1CUj8OKwc2IrKPCcTQEmZAckMMYs0743BeQDJpvc82hu0ITr6u4zZhzyWpgqz1K7lvdIStXwTr8uNL3ScP8B+nRHdTqYHqHThmEMh8XrahyfZWvgIE8j2aIDYB1ukwYDCngeUC10m/uX+WqZJ/E/CuCol4Os4bm5E280cUKwNbhLj53PXyitAcHDYBxlP3nyex+X9RTPeC3gp696BpXPKKQBF7zHx6JKqSiq1etmIAg40/qLzPBiVv1yc370PCrMSumJOm2mMBGi0Stosh1LLlHfiXfKuvpcWIICjjFyJlH719EQ1cc8JwcBeWfnvWFpkQsjQrJ1PM8FAgx/uifcbFQ24KtXrxJRkCIt0aZ3GvVDxWsRKev9MD1OiK7l07EGnsJg0axeQFAhhFWosCXSte+QpyQo8CDJ46xyXQ3SNdrh5UQ7qdKi/h766WGi64e5mJXhxCxODeVO9n3wUgcbxQBX8yDhI3hi91YdHzFzRMDb/OqReO9Rf0IWyPwdp95yuLXvy1ADthkEiWVkiDas039Qr40+QuMIJAyL5wX/dGU9xcsr84x6ux0e6nH4gKcKwwmU7X9FMNRyNPC0IieoR2T5zBguuXGh/s8QS6Km8IvofQEwgss1zl8wF+YheCMNVy+Q+OabeXoPbj+C5jeILRf+NXBR/APHfe6gkJhJvapiqbmur7u6RdxVDx2WCQLEy+YwHZNW1IVfAsT70wRQYP4gdi+yFLjnuvB1B/WmvO6hOqysNoj8lIw/yM8MP0/PrQ9jIo 1hJXOCMr VXDYHNqk9lS/6wt7tvBRLDQzrajIDTPQ9gSE0ng4L4MCT7rYiLvxYKY1PguvS3H7CCliEK1uLKt8lCv/qPpWfkv8+1V6vRpTBZn3srvyhgukj25aUQrUiFCtPnvF4tqaqqD+p+j30zLyB+W1002FHCxqWk96f3/VX/FA4PO4AqfiXkTx3DjX9rcLITqa261AQlVSDXFy7+9Xr79QzP7iU7x2FnBq0scw+CK46e55K9YTkbBKPfFFkKBgR+HxXI9R2YlCOOQujx0PytxQ= 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 Reviewed-by: Jane Chu --- 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 159f737501e1..1d1cb832fdb4 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 Fri May 24 05:28: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: 13672724 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 B9538C25B74 for ; Fri, 24 May 2024 05:30:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 562EF6B0099; Fri, 24 May 2024 01:30:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5397F6B009A; Fri, 24 May 2024 01:30:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4283F6B009B; Fri, 24 May 2024 01:30:08 -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 1E1EB6B009A for ; Fri, 24 May 2024 01:30:08 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D3D9F808B4 for ; Fri, 24 May 2024 05:30:07 +0000 (UTC) X-FDA: 82152163254.12.394160F Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf30.hostedemail.com (Postfix) with ESMTP id C17F380009; Fri, 24 May 2024 05:30:03 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1716528605; 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=T5BiIzIIz1wtJN57DSaYLDfgSQQ5eTYgwL5ZIhnbx+I=; b=PBjYL8BeS0fhhd4exBPT8KfdGGJTll89ZVg9Knb8rzE6D9tRcZVG/XgMKNVq6QuhAgupWg PQCyRpbF9eyA7P/Nr7wFb1FSqtM42G7ZweqP3RY4cw9pOatUc/zxaEx8BumZpDqqpLoGLF cgahCaHx/oA3U1jF/rQZlxcvcJkttw4= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716528605; a=rsa-sha256; cv=none; b=boMc/GnP3X6RLe9yyVP7ISwr8LA4K9RHEZxAra2j2nB7DKpghfRrHfhIisZLqV2OfaL7kh fJe2ALtGmwGEcsvVDFZLnpEQuMm6XbK/oHOPCQ6DJowpBHBvGNiWZK7PLJlEzJgE5U2puF xbBsqazVZheCEM/BgpfxNaS3nuCOqEE= Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Vltn85kvkz1S7BD; Fri, 24 May 2024 13:26:20 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 356FA1800B8; Fri, 24 May 2024 13:29:46 +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; Fri, 24 May 2024 13:29:16 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Kefeng Wang Subject: [PATCH 5/5] mm: remove MIGRATE_SYNC_NO_COPY mode Date: Fri, 24 May 2024 13:28:43 +0800 Message-ID: <20240524052843.182275-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240524052843.182275-1-wangkefeng.wang@huawei.com> References: <20240524052843.182275-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: C17F380009 X-Stat-Signature: rfj97pz9ittbuu845nj13i5cuhinn3u5 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1716528603-898236 X-HE-Meta: U2FsdGVkX182faOAa2N42KYQ90e6EvBJ7MvEyoaNFewNYCMRXBm6iCm2/ySevtrFYmrQl14NsOAFy+O7N/Y2lFLOUxiq/jWD2ICrurziD8dkz2kYa2sF+Mwaa3aGlF1MdcZaHCRWKZzth7jz8RbhnDBk16ckzT9v/tSPH1D7NKtkg4sqo158dMIet0YDKcbnl1tHItj1JlPM+LnXYgGF+FBrJpIopgatdiiCdVJzOCCLf0DwVPl92vJ10F+hoowlbl+frvNBx1mAirR17yc2kLXatBNqUaodWbDNv94zSgXrD0lPu+M0chTPCF8Bwvn5d/kqTlk6i37Bs9Eysw8HK5vxJRd1FfmY6Ag409kK7B3E8XjxvhCb3U8RKyHSDNvAjRolfHS30HriH6CNqN7wWcFEKwGIHQNMnxowdNoU01tOtiX4JUObvKvi7ojmoJLNPsXwQ2g+7Cs6Q0JGMKekrLY4KhYhzV9pOsydmTOhFcbpdXygWWWCAyth1uVGb4EX+WjJFMU4BJ11UAdWgSDhuPk0GKuzq1VUcfozzBdnNeuADZyGn7srML0WPhkiv5ieMUAiGOoIU4FlGqlUNKZzWrQxA5yXYiRbdZDjKsM5E5fr7XtGYH8EBWqiY3ElOcVCLGhn5Uo5Iam4SIU7aE9XubmwVwE64oeNzqPa5GvTweruUWRFHZuGDah+UACHL+mKOu1eBZGRao97I/ufev3nknFPt4NuCQzrE0Xc6UnyurbUK88lKSz9rmMGHJeuSJ5tYkm5ZjJcqYm47a+0h+wRPt6eRvtytimo5++lvxRh1SvcWHM94sLGNtVQtLF4ky3+WV55/zTNEiLksb35xUZYwBIj1jrySutnbqaLAVuFcNUb9+vsCPp8RMkUtDDqh1de8OlnvKc70iB2vdOq0lWyjzYT1YLbtXPyRzRQaVlvyUP4Xm8A6UKY27vxfmp/o1mxewv801kyA6PjZNTCr/A CM6NwyvJ 0R3lqU6uxLUmrF9zh9b1kk5JRm5XCNICjnlYVO53lpsNY2IIRLfLYybiLDXUMwp48t874C6U6OXiI0IATegV+TTUbWQhsFxKvC5hu4Qqr2gJQeVBM5WTcbJdyFi9FaWqd87a8a2/RYc9edS7QBBRATGjCLlCIsQ0Q1KGFpxUrM/MEtQAlMg3kFQqkuUO5P2C600agYMqljCy7SFmMfFt36dZhg4Zb19TwFHBliVZURXX+ik1e63OpPpUQkhGKza/AIhoZ47riqf2WouY= 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 Reviewed-by: Jane Chu --- 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 57c9f7c077e6..07ff8bbdcd2a 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -410,17 +410,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 412f295acebe..6df794ed4066 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1128,10 +1128,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 1d1cb832fdb4..e04b451c4289 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 b42d3545ca85..6e7967853477 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 */