From patchwork Thu Jul 25 01:16: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: 13741490 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 AA21AC3DA70 for ; Thu, 25 Jul 2024 01:17:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A29F6B0088; Wed, 24 Jul 2024 21:16:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F31086B0095; Wed, 24 Jul 2024 21:16:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CBF896B0088; Wed, 24 Jul 2024 21:16:58 -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 768256B0088 for ; Wed, 24 Jul 2024 21:16:58 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2BEEC140D0C for ; Thu, 25 Jul 2024 01:16:58 +0000 (UTC) X-FDA: 82376510916.04.2BF3B37 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf16.hostedemail.com (Postfix) with ESMTP id EF646180005 for ; Thu, 25 Jul 2024 01:16:54 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721870193; 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=qv7aaZRlHNMD4k1nOC3+xDOa/W10CgNBt7BHj9IogfA=; b=DJz7fQAo6rMOCwFls0bZ049cqGJpSQMRgRDm5WiI0u5SoTIUc8yP1vX1FfwQgaNif3b9qZ buUlX3tXJ7WEz1hoyR/GJ0AMtbv1HvQEzrywChobrHMs/RmFEYgXHG7MK+ftaPyfniOu5z pOtd87Kl3J460jO9EWx0MU58Nl55Vlg= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721870193; a=rsa-sha256; cv=none; b=mImeKlw08sxmYvwS5w/Gm3t6gQhAEZfhmTVy3sPeuV8BGKlQq8ZzU3PiOsKIIi76RH8LhN 4Z0LgJ/jTJNxZco6GGUKQSfFtbl7yjyTOpT7aIXVNCKRnHJLy6x/OLsSL7XtLHfi9sXX8p AWV3cTW4wDmN57y3AFDHlmk5c0ok87c= Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WTtGb63JfzMr5s; Thu, 25 Jul 2024 09:15:03 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 46A9F140444; Thu, 25 Jul 2024 09:16:51 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 25 Jul 2024 09:16:50 +0800 From: Kefeng Wang To: Andrew Morton CC: David Hildenbrand , Oscar Salvador , Miaohe Lin , Naoya Horiguchi , , Kefeng Wang Subject: [PATCH 1/4] mm: memory-failure: add unmap_posioned_folio() Date: Thu, 25 Jul 2024 09:16:44 +0800 Message-ID: <20240725011647.1306045-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240725011647.1306045-1-wangkefeng.wang@huawei.com> References: <20240725011647.1306045-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 dggpemf100008.china.huawei.com (7.185.36.138) X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: EF646180005 X-Stat-Signature: jesm59g4ttanar44hqrifce8qnpdu4rc X-HE-Tag: 1721870214-854607 X-HE-Meta: U2FsdGVkX1+YvhH66BM3oN67wFHS4PuExvlKIFaxeAT0MI87/95iIvTvwFvABbgaXOb9jLczaVLifjTTl2gOt/p5lV8lbED6eWZeDOH4es/gyFXL0/XAIOBrJH8eN25WLofzHNgzNwbtOEIobsqZgdQjfEhB4LPlw3YyHBzktTbTOnUjfvHQVU+C0BVDqHIttNzDZV6luOkD7vSAZQ0RtJ69pMSlMJKG8U4kMYMbiQpG3KrIOYqPWZ7GvgJW4AcZnN9PONju+VJ9nOPqYmTsKhKYjsdsXfskuu8FLe8QsPd4kccFy22exDRGp2v0vYNDhYXZSI3ODZL2/f1qDnabncP/urhCpC/eAyqdnBr68aqVR5vYy4r2oZV0naYdQwUWGwz73JFopvTnuZ6nzHQH8t5+V8bJhEFCMVO/fHaXlrKp33OLP5sfgl+3C5T4LJrY2fHTVEZ1ZveQ0UKzCEkq2BSLRwQ06s6mrPIuXEZaufsg4wz8QcyYcBbIfO2R+pZHvcHzmt/DW/o3mxEleevLtveGq9+C1I7UEd3gf1fHBczTm2S631cfO5K7UZHHKrkbnr5dh5/B9YD8ZAF66AR/fAlwf/4JgvMqKT9/Fp2J05P7j+s6OZXzSnge9kgVC/Z5txHnMWfUgaJ1AYE+/fITq262ESKpnyN1jdP5SJRtBO/RP8+SjJ2zRswhFDWiGoQBy/0ZNl+pgB/uYR50lUStibuNdiUPpLWA1X8LC4cnqLkjl6Skg0E/VyheyH9jkTLpwBTVwGw3jae0tlkSH8pmuVjgKvxkm7t0BXmDjPAvXFkQcuGF65I3Aaj+2YPohd3yu9k1DjskPDmAxpcUZpwTiBpseDe8XVWp2GhHiw7qIGpODqjQk7GMd3ceIkZ0oUT9f9u59tYBl0tMRdVUWuknTZedUJTw0knJ/HAsRbu0VmGOaCDHsktrATA8qtjBJW/nlbnIv0tRi/kPYXIN0zD BwtBx0Y3 MPbhFC3YZHM2STQ29MY8j+SLMEXjFytDtVfyZmxX+vyB73K/bgX8OxO0kiJN1uZ+W2s4DLgzm1rozk6dEdlRkuMiieWWzVIU34BY3IfJeTl8v2Bv+oLGy76b+J/a92R3siyCLshQi74vgoyQf3bFuRvzx51sXWQ3yWPrZGSpncOMPtRSbpiuA3IZOc801WdmMLII5/hBj//yKcwfaCNwlTR2EIf1qYL4/ufVB7LeL2VWW7rDo20aSDf1h0JkGxsQi7oHMyvpLQNlsS2A= 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 unmap_posioned_folio() helper which will be reused by do_migrate_range() from memory hotplug soon. Signed-off-by: Kefeng Wang Acked-by: David Hildenbrand --- mm/internal.h | 9 +++++++++ mm/memory-failure.c | 43 ++++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 7a3bcc6d95e7..c5bd24c4fa3a 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1069,6 +1069,8 @@ static inline int find_next_best_node(int node, nodemask_t *used_node_mask) /* * mm/memory-failure.c */ +#ifdef CONFIG_MEMORY_FAILURE +int unmap_posioned_folio(struct folio *folio, enum ttu_flags ttu); void shake_folio(struct folio *folio); extern int hwpoison_filter(struct page *p); @@ -1089,6 +1091,13 @@ void add_to_kill_ksm(struct task_struct *tsk, struct page *p, unsigned long ksm_addr); unsigned long page_mapped_in_vma(struct page *page, struct vm_area_struct *vma); +#else +static inline int unmap_posioned_folio(struct folio *folio, enum ttu_flags ttu) +{ + return 0; +} +#endif + extern unsigned long __must_check vm_mmap_pgoff(struct file *, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 8c765329829f..99d92565cbb0 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1554,6 +1554,30 @@ static int get_hwpoison_page(struct page *p, unsigned long flags) return ret; } +int unmap_posioned_folio(struct folio *folio, enum ttu_flags ttu) +{ + if (folio_test_hugetlb(folio) && !folio_test_anon(folio)) { + struct address_space *mapping; + /* + * For hugetlb pages in shared mappings, try_to_unmap + * could potentially call huge_pmd_unshare. Because of + * this, take semaphore in write mode here and set + * TTU_RMAP_LOCKED to indicate we have taken the lock + * at this higher level. + */ + mapping = hugetlb_folio_mapping_lock_write(folio); + if (!mapping) + return -EAGAIN; + + try_to_unmap(folio, ttu|TTU_RMAP_LOCKED); + i_mmap_unlock_write(mapping); + } else { + try_to_unmap(folio, ttu); + } + + return 0; +} + /* * Do all that is necessary to remove user space mappings. Unmap * the pages and send SIGBUS to the processes if the data was dirty. @@ -1615,23 +1639,8 @@ static bool hwpoison_user_mappings(struct folio *folio, struct page *p, */ collect_procs(folio, p, &tokill, flags & MF_ACTION_REQUIRED); - if (folio_test_hugetlb(folio) && !folio_test_anon(folio)) { - /* - * For hugetlb pages in shared mappings, try_to_unmap - * could potentially call huge_pmd_unshare. Because of - * this, take semaphore in write mode here and set - * TTU_RMAP_LOCKED to indicate we have taken the lock - * at this higher level. - */ - mapping = hugetlb_folio_mapping_lock_write(folio); - if (mapping) { - try_to_unmap(folio, ttu|TTU_RMAP_LOCKED); - i_mmap_unlock_write(mapping); - } else - pr_info("%#lx: could not lock mapping for mapped huge page\n", pfn); - } else { - try_to_unmap(folio, ttu); - } + if (unmap_posioned_folio(folio, ttu)) + pr_info("%#lx: could not lock mapping for mapped huge page\n", pfn); unmap_success = !folio_mapped(folio); if (!unmap_success) From patchwork Thu Jul 25 01:16: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: 13741489 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 B7CEAC3DA61 for ; Thu, 25 Jul 2024 01:17:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0BEB6B008C; Wed, 24 Jul 2024 21:16:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C986B6B0092; Wed, 24 Jul 2024 21:16:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC2C36B0096; Wed, 24 Jul 2024 21:16:58 -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 729BF6B0083 for ; Wed, 24 Jul 2024 21:16:58 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 271FA1C231F for ; Thu, 25 Jul 2024 01:16:58 +0000 (UTC) X-FDA: 82376510916.08.032FD76 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf07.hostedemail.com (Postfix) with ESMTP id 6AE1340005 for ; Thu, 25 Jul 2024 01:16:55 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1721870192; 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=RWqMgZyrRRYuSifWPheEHa5dyRQQyTJsFvhVB6xAx7k=; b=r8iCmh+VB7wafsRtQZEDSiF6SRjBaVPAxmhPo4qJcEZCORvbiVxuLGLpltkSly0NoyKl5l KJyNqMZ3IyI+r3iH7jxg9mUkjlxfE0tRrp6cn2f8rdppTcDYxHmb+cpgbY2WcdNcxvijEH V32oBBIdU4dhPl5gW8NyLocKR2yyXt8= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1721870192; a=rsa-sha256; cv=none; b=Pmk5RdCkqxSCof7PFxxcGqNWmADNeo//MFATQFR0RrgUUXZ1NZo7W8GYen9kXhgkVjVqQT azzRB9biWhD219guiCcpL2EhR8Ys9g+J9mH2OoLw6/iRpgYLp/lpui/wiUIcTMAe3ZTB2j 8fWPkT/ctCQz6uNaoltr3AnO+HrAQA8= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WTtJc3vj1zxTw7; Thu, 25 Jul 2024 09:16:48 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id B30F9140121; Thu, 25 Jul 2024 09:16:51 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 25 Jul 2024 09:16:51 +0800 From: Kefeng Wang To: Andrew Morton CC: David Hildenbrand , Oscar Salvador , Miaohe Lin , Naoya Horiguchi , , Kefeng Wang Subject: [PATCH 2/4] mm: memory_hotplug: check hwpoisoned page firstly in do_migrate_range() Date: Thu, 25 Jul 2024 09:16:45 +0800 Message-ID: <20240725011647.1306045-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240725011647.1306045-1-wangkefeng.wang@huawei.com> References: <20240725011647.1306045-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 dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 6AE1340005 X-Stat-Signature: imfy619smziu76ccrf4fne86nb8f89c6 X-HE-Tag: 1721870215-951339 X-HE-Meta: U2FsdGVkX18RSUhjPjoiZXz0v+7vFZxCp+AUVgz2pF8AfxDw+98OkY9XkiPyc+ovBGskuV6HxjxNcAU2zB5IlPtsRhLAi9z8HlyUbvfDsa10/+wSwxMIXhUjEPV2mJQC+e0hcDlZsYfEQNnNgayr2nmGjGsTdiMJxdgOKPO9MrgUHfrzw2f+bcH/xvO3L5sD+wonNVbHF5RwZgCYf15cR7oaJcGWQTGRm8/JWKVqcDyctspHh9XT8mYMq3EGyjqcsyNWJ0VRLTWUEBSuYSXj4iSsOftpZGgO9X/WWKX5eyeKHqSmlGgY+WWPoTxIRHoi4hfIIv6tk5Z1ld+Tp/3w6h9ROEJHnJpoF0RbcEfpAmo3qHUr24/eKpl84zCxCFO3PsoErzTM5gZWZnAO+l1i32zo7+bPjAf0jBp0Oi9cnQE9b2rzsz1DKhg1FZYYqEoJ0+lmngXyeKF6YYYl3o/HB3WMHV4cH0SvBfp6TrWShMZm+mNrK+fOfu3A05Vp0qcAbzed+9o+KtfE865VTn/BAaPsUd/t/Axup8kPjsFzbUPLo3+7evIvzaLHRxA2SZsokv8I+ONcA0BJ3d5dQZJ6MV3K4Vuko6xflZn7vi5IDqdDc/RQbWzJ2ZnOKq0/4P0DNVuFfxA9LFywxWd5+93d0Z+atC/6Wgnj+uhXuiXpysuxClKYiWBq55KZCsZ4uVGzIBPlOhT7uEECYVN6tvjBTLy8uv007sRVCN/Ln+1+1LnfBJJUa6SC1uJ6P/5wRAykBLt5Uwg5IK/lHSWUOyRn3fflG7FdTq5DwwtMv+Zo3iIwMC7TSlZwkUBl01d8gtQt+imub4Dvc8NdrIMs4EftxxYbJPSYpgypv2p0/BvJ5CgrMhViCzmfsjBxLdZ+kSA2XvF32Smc8I8XUq6F1b/RgD6f/XQPEhhmQEaU2jE9EAFBNc6vh6bRNOTSJaiqrFTPBFCkWp8xZ0Tcbu1Pbs3 s5G4vjCQ 4PiIqsx8c6EaTuklJeW1E8PALfqo7oS4lrdj0YFvc9XOnZ/fiEgIipVDhwBp3QNRAFGFH2XRUqIIKtBLHFsQTV0XlfobAsliKx8ttYFlfiLTYv4XzJ97O+qBXdhA9Cw/qLtY0JbgKRNrto1iizKVleTFIeeNT7/ssJdy8lQO+bHgIgoHnj7T0WvmplIJSCxYu86i5kC05gyH+dlW0LeCXg4IHykFGwsZTs9x/wfsdH7GcHOMkSsZq1FP//fH/zFFuzXkbB+uGPrAw6yk= 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 commit b15c87263a69 ("hwpoison, memory_hotplug: allow hwpoisoned pages to be offlined") don't handle the hugetlb pages, the dead loop still occur if offline a hwpoison hugetlb, luckly, after the commit e591ef7d96d6 ("mm,hwpoison,hugetlb,memory_hotplug: hotremove memory section with hwpoisoned hugepage"), the HPageMigratable of hugetlb page will be clear, and the hwpoison hugetlb page will be skipped in scan_movable_pages(), so the deed loop issue is fixed. However if the HPageMigratable() check passed(without reference and lock), the hugetlb page may be hwpoisoned, it won't cause issue since the hwpoisoned page will be handled correctly in the next movable pages scan loop, and it will be isolated in do_migrate_range() and but fails to migrated. In order to avoid the unnecessary isolation and unify all hwpoisoned page handling, let's unconditionally check hwpoison firstly, and if it is a hwpoisoned hugetlb page, try to unmap it as the catch all safety net like normal page does. Signed-off-by: Kefeng Wang --- mm/memory_hotplug.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 66267c26ca1b..ccaf4c480aed 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1788,28 +1788,33 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) folio = page_folio(page); head = &folio->page; - if (PageHuge(page)) { - pfn = page_to_pfn(head) + compound_nr(head) - 1; - isolate_hugetlb(folio, &source); - continue; - } else if (PageTransHuge(page)) - pfn = page_to_pfn(head) + thp_nr_pages(page) - 1; - /* * HWPoison pages have elevated reference counts so the migration would * fail on them. It also doesn't make any sense to migrate them in the * first place. Still try to unmap such a page in case it is still mapped - * (e.g. current hwpoison implementation doesn't unmap KSM pages but keep - * the unmap as the catch all safety net). + * (keep the unmap as the catch all safety net). */ - if (PageHWPoison(page)) { + if (unlikely(PageHWPoison(page))) { + folio = page_folio(page); + if (WARN_ON(folio_test_lru(folio))) folio_isolate_lru(folio); + if (folio_mapped(folio)) - try_to_unmap(folio, TTU_IGNORE_MLOCK); + unmap_posioned_folio(folio, TTU_IGNORE_MLOCK); + + if (folio_test_large(folio)) + pfn = folio_pfn(folio) + folio_nr_pages(folio) - 1; continue; } + if (PageHuge(page)) { + pfn = page_to_pfn(head) + compound_nr(head) - 1; + isolate_hugetlb(folio, &source); + continue; + } else if (PageTransHuge(page)) + pfn = page_to_pfn(head) + thp_nr_pages(page) - 1; + if (!get_page_unless_zero(page)) continue; /* From patchwork Thu Jul 25 01:16: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: 13741488 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 7ED1CC3DA63 for ; Thu, 25 Jul 2024 01:17:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4AAA6B0083; Wed, 24 Jul 2024 21:16:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE9A86B0095; Wed, 24 Jul 2024 21:16:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 803CE6B0092; Wed, 24 Jul 2024 21:16:58 -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 503366B0085 for ; Wed, 24 Jul 2024 21:16:58 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DFBA9140D1B for ; Thu, 25 Jul 2024 01:16:57 +0000 (UTC) X-FDA: 82376510874.21.49C9740 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf08.hostedemail.com (Postfix) with ESMTP id 2AC90160017 for ; Thu, 25 Jul 2024 01:16:54 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1721870167; 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=D+v9lNFi0AegKW6E5+crUO69itjTxP9IMrXOWgsbrdc=; b=GigxxsNa6fXqQ7Ya9pmiD1C0QsCLWEHO0d6b3kKluvxa5HEN/b2EuJrjEn/4vZCZCWLKUi 36dNE9WPye0gxSMxPkYfpvIvnxOynppFEnfJwEgyHrK8iYz975RIe2L3wpR4MLDl3+2NQU wCQ9L108pIMwsTnMcf50XyipA2sodD4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721870167; a=rsa-sha256; cv=none; b=aPA9NNybQd2TESNP2H3OLmH2VLstN7p815x72FdF/0J5PeQAMWFsM+Bx0XPvDmZ7Dsy+Go A6fTuOG6m0fp+8e757hzgXyJDEARO3Jl02647x7Q8Nzs70ROQOPHizACxl1UcxnmCrK4My O2yJ0UmjtG1EnKzCqYfltUAO1Ay6fKY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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.88.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WTtJc6wpHzxTrJ; Thu, 25 Jul 2024 09:16:48 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 272AF1402CB; Thu, 25 Jul 2024 09:16:52 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 25 Jul 2024 09:16:51 +0800 From: Kefeng Wang To: Andrew Morton CC: David Hildenbrand , Oscar Salvador , Miaohe Lin , Naoya Horiguchi , , Kefeng Wang Subject: [PATCH 3/4] mm: migrate: add isolate_folio_to_list() Date: Thu, 25 Jul 2024 09:16:46 +0800 Message-ID: <20240725011647.1306045-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240725011647.1306045-1-wangkefeng.wang@huawei.com> References: <20240725011647.1306045-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 dggpemf100008.china.huawei.com (7.185.36.138) X-Stat-Signature: q84467ikx61d7bbxnzz4eweqfjs1n1r6 X-Rspamd-Queue-Id: 2AC90160017 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1721870214-194212 X-HE-Meta: U2FsdGVkX1/voNT4uqoumdg9EKyFc7aPab1dydmefyOD7I6zkXriKqpj07eRZfx+c5yqWPHC1Yj+rXdpFtRIfj20S36xz6DB/VGFk9URGY4gUQ35YfY3ORAsdd19Nrg0lYJgAJgklqR4N1sabIiO/H3GQb1YzDZX3yjT7xVAfRov9MbU/h0Lsx2XfgEfZS1tc21pyJ2iptLNaYOxgwZhvgJAwRjiSaTEvZVyXQMjBKuE3JT+FSaZpcJqKn+pGgF1DDqCzAbkmANlN2ZsRndgwMfIiML9bYrMGCnI8IPqP+DNkXWgUaJ0B7sXFMwOwuoWG2H4oLaj1IPOD9//lYt9JO9ku9b2KHPVkmQrC8zowbh+c4c4j2CsJE5VoKs6/IQODD3RDG/68tJSmJ04WnpN94Nj3lhzb52+yW1nL6uw+2BeKdLY3Zt9HAMJuMVT2rr1u3QCpq60a2I9XMDRA51FClQGz/5rJJsqGn/GBrbcYJpe4Pzd4UbWBItUSObDywPEf/GtfffqSwkQvLqB9VXGS6WhDtXo35Ue2acoknzlnUPwGndWIh/PugpGCUQJNGkgT/VYR1XvqBzNQ0Czp43WbyKOowbUZ4MrrYhTx0vJBkmkcrUGo1SVuvaJbJD1KS9vUlRJDt/WR00ObZlhEzAGDYrllBPZqf8K8z5VmbMScBX1XHk01ZLfqhpmKn/mfxM1PBq644YatdVYj6/CQiEr8E46PJiIGRjNtPXhJSII6sV3g/lNOMffASUu+6M1B+pmF6Pk2ZbHY4wR8meOqoTesnapnUtLgQt8oTm8+ZPly6JDYHloEPcj5GM8LVSwRF4S+jHJ2/YMdOlS9LkUrPTN3FFQmt97NdXtZYHNp9sA1Xi5JN/VDoOIp/rgGXZFM6uz9q/gsjVgNPCQYDaq0kh8WdDFEXkZ6tR4OjeGra2TQFpVqeALhwy63W3XVF3yXh3GbyBEKNXcm9BkvuFEEx5 eYXC/yNe 4v9UUG96FQ46qAmy1AVus0j/56zbsTQXK8njiwvjPb19pl80MlqwZBqrflFJKRdA5kXLvdhi4aEESzOn9We1EPGaY0/C7zxA6NPjnyUKPYnLS1Gv8FW/2HJFecHdjbT4sYipY4HqJcWXcBtl6NmJ0VSTrzLkPKgUNvge/ohhkf2ur6zd5LweUzYtrjg7iYE1C51D6zsyh9dqTnuzUvjs5VlL8anDUEa0+h3sxiakrBvinNoobmEj4Jq5WJHx3s1a0IBiXcryJjdgjA2M= 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 isolate_folio_to_list() helper to try to isolate HugeTLB, no-LRU movable and LRU folios to a list, which will be reused by do_migrate_range() from memory hotplug soon. Signed-off-by: Kefeng Wang Acked-by: David Hildenbrand --- mm/internal.h | 2 ++ mm/memory-failure.c | 21 +-------------------- mm/migrate.c | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index c5bd24c4fa3a..2484191c0764 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -403,6 +403,8 @@ extern unsigned long highest_memmap_pfn; */ #define MAX_RECLAIM_RETRIES 16 +bool isolate_folio_to_list(struct folio *folio, struct list_head *list); + /* * in mm/vmscan.c: */ diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 99d92565cbb0..7e0f143bd51a 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2659,26 +2659,7 @@ EXPORT_SYMBOL(unpoison_memory); static bool mf_isolate_folio(struct folio *folio, struct list_head *pagelist) { - bool isolated = false; - - if (folio_test_hugetlb(folio)) { - isolated = isolate_hugetlb(folio, pagelist); - } else { - bool lru = !__folio_test_movable(folio); - - if (lru) - isolated = folio_isolate_lru(folio); - else - isolated = isolate_movable_page(&folio->page, - ISOLATE_UNEVICTABLE); - - if (isolated) { - list_add(&folio->lru, pagelist); - if (lru) - node_stat_add_folio(folio, NR_ISOLATED_ANON + - folio_is_file_lru(folio)); - } - } + bool isolated = isolate_folio_to_list(folio, pagelist); /* * If we succeed to isolate the folio, we grabbed another refcount on diff --git a/mm/migrate.c b/mm/migrate.c index e7296c0fb5d5..51cab1103502 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -177,6 +177,33 @@ void putback_movable_pages(struct list_head *l) } } +/* Must be called with an elevated refcount on the folio */ +bool isolate_folio_to_list(struct folio *folio, struct list_head *list) +{ + bool isolated = false; + + if (folio_test_hugetlb(folio)) { + isolated = isolate_hugetlb(folio, list); + } else { + bool lru = !__folio_test_movable(folio); + + if (lru) + isolated = folio_isolate_lru(folio); + else + isolated = isolate_movable_page(&folio->page, + ISOLATE_UNEVICTABLE); + + if (isolated) { + list_add(&folio->lru, list); + if (lru) + node_stat_add_folio(folio, NR_ISOLATED_ANON + + folio_is_file_lru(folio)); + } + } + + return isolated; +} + /* * Restore a potential migration pte to a working pte entry */ From patchwork Thu Jul 25 01:16: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: 13741491 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 527ADC3DA63 for ; Thu, 25 Jul 2024 01:17:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50C316B0089; Wed, 24 Jul 2024 21:16:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C4406B0093; Wed, 24 Jul 2024 21:16:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA9B66B0089; Wed, 24 Jul 2024 21:16:58 -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 A65836B0093 for ; Wed, 24 Jul 2024 21:16:58 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 591501C2352 for ; Thu, 25 Jul 2024 01:16:58 +0000 (UTC) X-FDA: 82376510916.26.8997780 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf24.hostedemail.com (Postfix) with ESMTP id C4C1C180002 for ; Thu, 25 Jul 2024 01:16:55 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.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=1721870178; 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=9CW5FobJ48usG6n6/p1kVA8alFXJpddb65rUplA1HdQ=; b=SGdcC8EhYaOCD4hMLNvjAasztAr3iG2YxxQtVo80FOso50ourj9XgusjGMM77pQ0thg12U D89Mhi2LJHiCsSc92Bakv0emLrfzQrWLtUqroSUP6OYsryZ1cGMAdm3j0t2g4OtDLJP6Sq 21hUpiZkOy+dGrNEj1qhUZ2kMW1zi9Y= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.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=1721870178; a=rsa-sha256; cv=none; b=KZIFhsIJEe0HCkDutpmvyB4EZvGlGJSJPIFHO/pKBgxqq4Hm2Pi5MCpX8XbYbTgP+RcvpA Ru8dL9/inBce/N1abo0VPEatsltuCWA6UcZLqWoSibv7+cohY9JINo5XTwLi0pOTCOhC7L dFx8dk8WUHy1se41E1t2XYR7vusXrxE= Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4WTtJd563xz1L9L6; Thu, 25 Jul 2024 09:16:49 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 95A6D180101; Thu, 25 Jul 2024 09:16:52 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 25 Jul 2024 09:16:52 +0800 From: Kefeng Wang To: Andrew Morton CC: David Hildenbrand , Oscar Salvador , Miaohe Lin , Naoya Horiguchi , , Kefeng Wang Subject: [PATCH 4/4] mm: memory_hotplug: unify Huge/LRU/non-LRU movable folio isolation Date: Thu, 25 Jul 2024 09:16:47 +0800 Message-ID: <20240725011647.1306045-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240725011647.1306045-1-wangkefeng.wang@huawei.com> References: <20240725011647.1306045-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 dggpemf100008.china.huawei.com (7.185.36.138) X-Stat-Signature: wrsu6ufue6yexr6tqkok47q1y3dcct8g X-Rspam-User: X-Rspamd-Queue-Id: C4C1C180002 X-Rspamd-Server: rspam02 X-HE-Tag: 1721870215-617911 X-HE-Meta: U2FsdGVkX18HImFHJ+r1Ae/oLFW3ZkDMWUw/r5I++StUQCwpMEcSpmCs47uBdqm7w+F5z/HDR7q3n5nws0vwy9MW+HnJPCiP9ayQSOQELClx+WL/e+W9aNF9oNDpOsvbFyGV7sPHRk6lnckbB+RNzz+el/pg42rJpQsJ3oXKl+pMwjh4Dn+4cCbKUbCxU4lyTYmi86ZYWXstcAkQiCrB96x1QYNvkn+GBLgAgSC3nC74nN3M5aMZgzWSLF/D4xgXPVzX1Hw4Wc7UYEzkSzLSSRkf4JRVp/OpLO3TfQ43hnhV6En13DGiE4FjvSUxO3aUUHDAz0T7sdB86Zq3aKC6SRc5yo+MyAKIXwbd3VYLCMhlZysk4LREG/gZzLnOHY2oKgRDlZAD7nCS9eC/+Tf036G4sckQ7RZizJqh8r8Y5Eq82kggki1AE9oDreHqwh6fbI+ryIHXTqeP7hsqS3ptuffMbLpUQ7EIulZwJjvDRHg0dmmzkH29wqwGXzoY6x44CerG8HWz9EnHT3aNk4x8V9Ytxx3BAw4Cajj99h0zX5ttAhtQujYEP1/NYa0Tbw78H2zVAVLUOLglG7F+v3dE12xEYKPfPEmrhvadcaE+pS6G0IEUSnMADaFoknzgdPvyaTYv0C0nkOJ6pFstEeg7QMXke3L5cEFYHrbTrnqlJ7fnustXctXnZqdN07xO+hwXdb6dqGe0EmlxAFLnmpNzi2/uLeKnDm9MCdmfDiCnhiTBQ/y1+z8CSN0VpyExB0u/ZzYlYm9tP6nuyyQKWTidxM+JTEp+g2aNuxaGTsl3pcncMCgA1oRoCZFcm4q6u4Hcju1bCmNRfheq6ZEGJmglt3m7z5EUJ3mVd21xtxetADNxC7OkjDRpLLhZ9kBaC7bkjQNhZAd8O6LzqQx4XC4uyjCe9s2yTAUgQGNqh145M8jzjkge+HDJcdiPWNZJJJaCet/VKxvsrIxkHyrb2pS 8ynr7mH1 l6/FndyCJEaskh9gtn6IXIhkVLHyzWiQ1+dFRNLJwh05+Cuy1AmZUuBUYcuCOKuRTdFfzB8MjVSgBonJoiyt4bhX77aPbmupWtasONns19y5F5VolkVUzBigiasnnzQb7TeBIf8cbqX3cS9K4jLHC7dvsii9Ob7V+muvVOyslJNUvPKvjSckt41Q4Sh2M9FEYTxtLLB8y2VfVfjPpckXL1txDTnm9x0leHZBcrludCKmMEfwf9qwQc05ytxykYPT6cBPFBlUH/vgTpPXBgSGtcW/eki/EKBNo+RMHagmjB/Nc9MI= 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: Move isolate_hugetlb() after grab a reference, and use the isolate_folio_to_list() to unify hugetlb/LRU/non-LRU folio isolation, which cleanup code a bit and save a few calls to compound_head(). Signed-off-by: Kefeng Wang --- mm/memory_hotplug.c | 48 +++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index ccaf4c480aed..057037766efa 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1773,20 +1773,17 @@ static int scan_movable_pages(unsigned long start, unsigned long end, static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) { unsigned long pfn; - struct page *page, *head; LIST_HEAD(source); + struct folio *folio; static DEFINE_RATELIMIT_STATE(migrate_rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); for (pfn = start_pfn; pfn < end_pfn; pfn++) { - struct folio *folio; - bool isolated; + struct page *page; if (!pfn_valid(pfn)) continue; page = pfn_to_page(pfn); - folio = page_folio(page); - head = &folio->page; /* * HWPoison pages have elevated reference counts so the migration would @@ -1808,36 +1805,22 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) continue; } - if (PageHuge(page)) { - pfn = page_to_pfn(head) + compound_nr(head) - 1; - isolate_hugetlb(folio, &source); + folio = folio_get_nontail_page(page); + if (!folio) continue; - } else if (PageTransHuge(page)) - pfn = page_to_pfn(head) + thp_nr_pages(page) - 1; - - if (!get_page_unless_zero(page)) - continue; - /* - * We can skip free pages. And we can deal with pages on - * LRU and non-lru movable pages. - */ - if (PageLRU(page)) - isolated = isolate_lru_page(page); - else - isolated = isolate_movable_page(page, ISOLATE_UNEVICTABLE); - if (isolated) { - list_add_tail(&page->lru, &source); - if (!__PageMovable(page)) - inc_node_page_state(page, NR_ISOLATED_ANON + - page_is_file_lru(page)); - } else { + /* Skip free folios, deal with hugetlb, LRU and non-lru movable folios. */ + if (!isolate_folio_to_list(folio, &source)) { if (__ratelimit(&migrate_rs)) { pr_warn("failed to isolate pfn %lx\n", pfn); dump_page(page, "isolation failed"); } } - put_page(page); + + if (folio_test_large(folio)) + pfn = folio_pfn(folio) + folio_nr_pages(folio) - 1; + + folio_put(folio); } if (!list_empty(&source)) { nodemask_t nmask = node_states[N_MEMORY]; @@ -1852,7 +1835,7 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) * We have checked that migration range is on a single zone so * we can use the nid of the first page to all the others. */ - mtc.nid = page_to_nid(list_first_entry(&source, struct page, lru)); + mtc.nid = folio_nid(list_first_entry(&source, struct folio, lru)); /* * try to allocate from a different node but reuse this node @@ -1865,11 +1848,12 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) ret = migrate_pages(&source, alloc_migration_target, NULL, (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_HOTPLUG, NULL); if (ret) { - list_for_each_entry(page, &source, lru) { + list_for_each_entry(folio, &source, lru) { if (__ratelimit(&migrate_rs)) { pr_warn("migrating pfn %lx failed ret:%d\n", - page_to_pfn(page), ret); - dump_page(page, "migration failure"); + folio_pfn(folio), ret); + dump_page(&folio->page, + "migration failure"); } } putback_movable_pages(&source);