From patchwork Tue Feb 6 11:21:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13547056 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 53FBCC48297 for ; Tue, 6 Feb 2024 11:21:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3DCA6B0082; Tue, 6 Feb 2024 06:21:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 99E496B007D; Tue, 6 Feb 2024 06:21:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 692F56B0092; Tue, 6 Feb 2024 06:21:52 -0500 (EST) 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 1930C6B0080 for ; Tue, 6 Feb 2024 06:21:52 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A3EE3C0BB1 for ; Tue, 6 Feb 2024 11:21:51 +0000 (UTC) X-FDA: 81761139222.22.35FB0AA Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf09.hostedemail.com (Postfix) with ESMTP id 8F451140034; Tue, 6 Feb 2024 11:21:47 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.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=1707218509; a=rsa-sha256; cv=none; b=HAjySQNjzu4tnV1sURV0ctj2ted/WYZdHE65p9n025Z12vmrWlgQoSUiLWVZ41WZ5IptYv jYuZiaa7N7YBiOnFxyRRrmx0cZRLP23FsuKCa7ygt70aLRhjQyqcoaErPreuYywM9uev1A SAHzzqxWzY+nCwHNb9WOGe3nZZ1qYrE= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.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=1707218509; 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=Bt7+CuCqnfd1TP8GqRcil80sudyLnihTTipPIF8jbCU=; b=GHfo4iUYjUqDSxnliiMvcdZz4pvq0wE9sDndPFEP72PbDSxxXsrhLE2FptAtOAZ1mdtIW6 AVbkEnQ5CzbLx5H3vmzaluxPBE7sps8Mh9iDEABaX7IH3pafJ8AkT4tNvA5Ukwa5bqdpXP DFu3brDVP9BSJKk3LHQ1SKQ0yKPyh6Q= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TTgkq3gvWz29lQy; Tue, 6 Feb 2024 19:19:47 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 4145C140412; Tue, 6 Feb 2024 19:21:43 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 6 Feb 2024 19:21:42 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfcv2 01/11] mm: migrate: simplify __buffer_migrate_folio() Date: Tue, 6 Feb 2024 19:21:24 +0800 Message-ID: <20240206112134.1479464-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 8F451140034 X-Stat-Signature: iz7ez7smj3b8bwmiamgnnpiqm461sz5h X-Rspam-User: X-HE-Tag: 1707218507-253386 X-HE-Meta: U2FsdGVkX1+IjPABA5t8hTin7DkS1zhZhGV+UKvbrW9L8Qivm6DsW/VK5muY+sxa1qy6vd8a/71D2VA/2tE0E1MAL2TgYsRDp2/EJ7H6qliYBAQ2u1L2W/s1ng1dzNaohMU3Xp1iAsc1DcWLyuf+KuLEudE4qThqUGcv1iU2FQE580irYgpcz0I0ZJMYQPLePNbW8IbQIQhAp/WbH+VAWXMnmXSnp8l9PQ9goa/Cx8R3QaSKjjkj+DRHlGRKlGAYLespUAM/aJs8P0sZWkdpZf/UpSZBesy4UvYN8+0SuXpdJMP7G6f5IqTAn6awaFBGIGHTGzkij9apwoRzQXEUfVgha+8kaG/MJ6Ex5NjgYrdPzZ9rjvtwVnsWBtWEc/IlttQuoTeSDEIHHc6+fjL/7YeaU0j+04FYwDrRF1LXaFCI/qr86a5O9fYRrc0kwT4CzFyfJGSxLrUtw1TIlcMzdgifLbhfd5iq1yneOIYiv7G+bqcJy+NgWWLraccgCuoyrtoClmwoSPqmA76z1lEhmrAZC0mALl2wK6OgcOsBvsXoLLox2ZHuEJPU9phnAWjEUv3yBdKPEneEN+HmoiswynSbvJ7c475HOQ26jIW3gyLYnHdsCVq447DHwcauei8atQRfncwla45twRmN40f0yOSn21lFGXoZnpJlYLWwrAUrHZSyAZ6KmadCUoIIF+FC9b19WRcMcEZ5FPK5gOCsLH8EcUB+0xCTmxiQPiBiIsonOJ1zL7+7rDTxxJPlA55YYoFSE+y00C3c/nqJa/XlB2TxqvMbWvbo0FWxwPTN2TtgK1ey8eax7oRxoEFHswAp47fi9k39qjkNBdM4YXrr4G5Ep8azvzviZ5BXVG42P2ipqg1w6BslylvtWRutgMxbkXDjnr0rSejHTn8Bpe9IHnBb9kYmrVq2YrP+F8SFwFUY9wQstxWevhH+9TXxTv70v46rpvBrqaQA7ucqNvk ytl7vuN3 Yo2utunHJhKQ9coFviMBbASCLWqChan4T5JjmtdMSx+Rl40AmDDo4G02ULmYdaeEjZXfkFscrl5fEMm0Fvw8P1S+DUqp8oKtxM2VdvLBGSaE0dMCDX8a0ca5cwZhW5QB+Wp7UuGkPjcQN+JEs1peR2rkpTdd/PAZz+wOT/tJjWSoGvl3UQgTnOPvUoEAiSqAEv4IbtDZpVEL719wWa8ahvevnULemeh2pVbE7xK04y/nW2DJbPDwQKYcgLUa8DOeF5iG7 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 --- mm/migrate.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index cc9f2bcd73b4..cdae25b7105f 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -774,24 +774,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 Tue Feb 6 11:21:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13547057 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 1436FC48297 for ; Tue, 6 Feb 2024 11:21:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 02B7E6B0089; Tue, 6 Feb 2024 06:21:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA77B6B0083; Tue, 6 Feb 2024 06:21:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 754456B0075; Tue, 6 Feb 2024 06:21:52 -0500 (EST) 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 1CA066B0087 for ; Tue, 6 Feb 2024 06:21:52 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6ACD3C0B73 for ; Tue, 6 Feb 2024 11:21:51 +0000 (UTC) X-FDA: 81761139222.25.A3ED8DC Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf14.hostedemail.com (Postfix) with ESMTP id 3669F10001F; Tue, 6 Feb 2024 11:21:47 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.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=1707218509; 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=RdTsyGDionxebasJBQDb3Ax7lgZoxcsIOSPkDhbUJzQF+rVR275rJy2rbZ4x1544l7zVDO Neqt4LF0wmWDDOcLiEVls161kN8kQ6Dh0hgS0P0FRqCOX1ExoWGyVC4cXO3mb2LB2DYt3c iZ4mmW2o2ICnwKnZQO+H2+l422nnuLg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707218509; a=rsa-sha256; cv=none; b=nWoZorOou0PdIfVGS5UCJeK9DDDn9JxJ10eXRq6mmOF+4NIXkbL3L6MUxJgydZMXhh5UK2 6e01dAybLUtzuAqHmyCHLQvDerVdii+mqo2H55FXttQ15gjFNeXNJ5JTZduQgG5lBf8lK+ lbZxTy2QiSyhqJuUk1/N47awMXa5zaM= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=pass (imf14.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 Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TTggm22wyz1FKQL; Tue, 6 Feb 2024 19:17:08 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id D97971402C7; Tue, 6 Feb 2024 19:21:43 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 6 Feb 2024 19:21:43 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfcv2 02/11] mm: migrate_device: use more folio in __migrate_device_pages() Date: Tue, 6 Feb 2024 19:21:25 +0800 Message-ID: <20240206112134.1479464-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Stat-Signature: tuafkzboc4gzynxnefarzi1o47599cwt X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 3669F10001F X-Rspam-User: X-HE-Tag: 1707218507-854357 X-HE-Meta: U2FsdGVkX1/gVQsjkhbEzh/AxVfAfAFPI09LF1ek9UblRpeEr0h2ThHN+OyoYbNtqqyJwFvdMcFPc4PGedaAKtKzLlLBCM+5KOyHM7jbQqXBZrS4icprQJSFHgM0A3q/iDVmsLo36tyekFLnznR6pImd/vywu0JyMPt7cAwJ+ycovR21vtOf25I+1S7JKRtyiGDRwqOo04goizRQv66kcbNYh2eDrxFlE6gT8Fr0jpI7defXNyuhCRzRsHKB3y9Iy0mgy2WDX2Irwblywb6OpHulBrkV8uVBMD8KexgmW6obMXwHGAF/PWs2AyQFTKVMiTX+rxjKA4Db39GYT2bodqLB+X7NQlcfuIH802BnyeFEO3Y/7c8eAgSUzaLPAfwV3V6v0emBoin6XzccAk+yc6WJaDte0eJaGGZ879k1H6PVJQ8gsrK7RXpjn3QfIaZtfDRbOjkRcg0Yt99nenXi2o6wupg3UliYnkQeKO6p33gjWPJcoANd/Uc9ej2U8aFoo+diCelR1ITzyHCvIoPE8GoHxmmj6Uwcm5CTtlgqnk4QTDuiJYwMGikQfq8m7h3hY+R/PEYQQBv4M8KYYEljb5YbfEy7tLlIdrJqD7o85go3Mn/UhXO7vmBguay0hznpdHlortDy1CzApHj5zkG6xZijtsnxMtJPwU3tSHifbeY4g99HXD9bhnFJ07QxqJBZ/r85GVcXaUqpmg+d+BKmOC9suF9jAFP+Hz9PKML8Bnq1YnT5N4BZHppF37lJzUfgOYjyjYh+abgJbVtapUB59LdO4SVyKloeXiehy/cVuybr9Z3b25NCF7YHXKU982ALIqhkL4eckPsdeyzxK9WTqarXPyuDcMud9QQiijFVEnIRNVFFvO+PoBLI+Y7yVWMJWV4GGxuzarGJt0taJH8ENQcinDwI8/aGOPEpLJcdCByoxMtwhYyHP1tY+0vcO6NVpFDJxziTT+C+T1D7Y9R AILJLrGX IYIyxtv0taHp/IAeL+JKMySSOdgmBONLbzIwLhIIDMc4Sw4lDE3UPu8zvQlrgYZYmdMd0gL/NYgghvlzEDQ/Jwbu6cTyQPaBbVCdbGOrOlcFl6FO+mNq+nUVtV1LhDMj3Sd0Gy6ORw/3ghgZv/CfFMfVrXzLpXlXFaZ+wkU9FrexuJVjtgTr+yV4xS7f1vuq0iBoDtR5V/B/ObG8MKBJGH3f35UcHjaYg4+pLcee8JDsy0k/h4FHZHese3kzzuYr6v3k/ 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 --- 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 Tue Feb 6 11:21:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13547055 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 65949C4828D for ; Tue, 6 Feb 2024 11:21:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3028F6B0072; Tue, 6 Feb 2024 06:21:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 271E96B0075; Tue, 6 Feb 2024 06:21:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E84596B0072; Tue, 6 Feb 2024 06:21:51 -0500 (EST) 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 C79356B0072 for ; Tue, 6 Feb 2024 06:21:51 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B1EA61A05A8 for ; Tue, 6 Feb 2024 11:21:51 +0000 (UTC) X-FDA: 81761139222.22.7273C70 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf19.hostedemail.com (Postfix) with ESMTP id A897E1A0003; Tue, 6 Feb 2024 11:21:47 +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=1707218509; 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=QHHV+syQzDHVzfsVVGvCwjoI2xKTMlxzNqAZh+iW8djWyALk9WskwLa/vuqvYm0i7iel5C 4OT2Y7gNUuH975rcsSsp8j9RExEXhVq/FkStrCdwDABSbxJgnQQMEaNGKsMKGkktkytpco Pr1xewHZd+io5BzZDwVV4wWk44nEbmQ= 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=1707218509; a=rsa-sha256; cv=none; b=Jw8r4l1uIrcoAxTq59p0ZSpqLfi5sLnjqkV6oNBFA9OAjrkV3sorNusCBE3PW6acEohK7H j5B94n0Usc00m79djqD6ktXouqkwVKdS/44YSkomycC1Z7rICEweJP2w3KgBAdN+1uAsUY PYvxRrZ2bWTPRspcZanbIYY0FCLEZ74= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TTggn0Sn1z1FKSg; Tue, 6 Feb 2024 19:17:09 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id A25D41A0172; Tue, 6 Feb 2024 19:21:44 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 6 Feb 2024 19:21:43 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfcv2 03/11] mm: migrate_device: unify migrate folio for MIGRATE_SYNC_NO_COPY Date: Tue, 6 Feb 2024 19:21:26 +0800 Message-ID: <20240206112134.1479464-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A897E1A0003 X-Stat-Signature: w76gf91eiwmxpa6ap3qiqeybzcj3iun7 X-HE-Tag: 1707218507-932012 X-HE-Meta: U2FsdGVkX1/NJJFAQ1wkr7fuKyf3yHDLfkE6PYg6Fu1Zd0oDtv1QF8NQXZEUOJuD7DrP2eB79FNJfb9EFcF9rJicEOJqTq/1miOvPLiBbMdZ4AgB+N9p3ZhxmlxV3wAkWHCvn7UhFfRTgvNzNfQQudQAAk5tSql6BNICfcAoL7d3YiuCUyyZ+vPqEEG89c8W/QmJDT6RwOIuvnJ+rfyPkMgcPzC3bf1QD7SsnB22b2Y/OCe0nSg4/Fww+u74LV6upC4bzRgclJ/fuukAAQGFheTdzn1KZicQh4CdYLUjjynbzy9oL4ZIH3sDzGeJmdALz6LqcuJC54Kw5QSsFdh/E5tQBRtWdQCtIrqFLOgvv/TfjxplcQLpqz6KdT6irjxHfjvUxA6yyJezkCqqOsQoceGPH6jmxLO30k6qT9EAD1jD01YSbDhnwKKE8YFlezNIr6w3rGu+rhXXyMbTlgvF8JVzvqbNPeHjFjmCz8P6WxXGBtTtqLIg7n7+e2enyompg7K06KaAmMtzPhbDbO9UuXjdFMqUDwGmG9WGegcNFB38C1Qtzm71lvkkbbS6pBHNSDcPkh/tqD2z6H7mlY/oMS5358clFSLNIEwOQRQDqAtSYePgMTLDDv8EAdqc6/XafVBl7k/KAuIZ0lqL6N2lhyWHkTjAEPNrmNmKD5Z7xvXi5ELZinVdBbd7yfMz/1QV0/mrFwHeMH/2uR5vPwGdZBXnAQlfD+ee7MeQrSOzt9ddSN6OHcZzF2F0CLT3dLE2wgl6D6RUYXKtC+5r2lAuRyUBsCLEx+OFVfJS894vGDuemvRKf45NoE9qQaX3xjkVBgYcOZhLcatwyxCNTzrQrXEGZ0oL+68WeQ7AtT1JpKOMwraCNIVjWVNzsZjiRak42GhMXMyV7hrhnk+0bG/SOlDsc333eLrTqMGgQ2tEq3MtU0E3bLGwC3O2o+EF0whEcKObNEpujOuwOVKcF6a z72Ir7VM wk9h3zPbwq1a/h/el5VzwUcb3vQgSBvCqlUKVAsZU/2CFflBBTs8yqsZRnpzPWyi43znGo9+W4FtBhjiSJU8E31t/vd/9k9DpfEJRyV9AF8SbPPfBfMiiFj1g1Buy+qyPb8CvNyFcpeAucw2392pO2WCkdIEgbM7Lfm7DxUdBBLyqVWrBoQOPO81jTOSLMBz5GOYz 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 Tue Feb 6 11:21:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13547058 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 A997AC48297 for ; Tue, 6 Feb 2024 11:22:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 512266B008A; Tue, 6 Feb 2024 06:21:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 494C16B0081; Tue, 6 Feb 2024 06:21:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E33416B0087; Tue, 6 Feb 2024 06:21:52 -0500 (EST) 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 86A4E6B0087 for ; Tue, 6 Feb 2024 06:21:52 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 38744160A37 for ; Tue, 6 Feb 2024 11:21:52 +0000 (UTC) X-FDA: 81761139264.17.A15C56A Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf29.hostedemail.com (Postfix) with ESMTP id BC5DC120002; Tue, 6 Feb 2024 11:21:48 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.35 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=1707218510; 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=2EyZhrfCI3hGk2K2PCHohFB6BH2Ll2i1D3+3PdNdYcQ=; b=FPNsA0uf3HCt5Gk4EL4NqDJiLupMMYC08xmtChGodDv0Wl7pUIWOb8k5Vpzo2A4EuZBDZ1 ksS0qA7sxF55Pi5vyoWI2cx4JZlfFpI2SvkRF+OccaPzjCpx+2RtysAWcvJvYFfgluhnoc fX+DyTc1e6DmKjkM9x80qqh7JfzmwX0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707218510; a=rsa-sha256; cv=none; b=1XME0qV23eh8FrQCcu7vQr3Sf+YZOe29qoCczse39DrD3NdVMAPT+FsV+slbctx9gTqtr1 M7SE859IylbGBnfPU5XR+XPSEfBbZcwpcz/t6mF4XSrX9z8tmgU6k9h73OheyJeV+vSRU0 i932oJn2WXUlmbEBubAlrioGSElVhAY= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4TTgks0LBbz1Q8qq; Tue, 6 Feb 2024 19:19:49 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 2334D140412; Tue, 6 Feb 2024 19:21:45 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 6 Feb 2024 19:21:44 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfcv2 04/11] mm: migrate: remove migrate_folio_extra() Date: Tue, 6 Feb 2024 19:21:27 +0800 Message-ID: <20240206112134.1479464-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: BC5DC120002 X-Stat-Signature: jas8c4ine63gsc6qytpf3g7d177nf15w X-Rspam-User: X-HE-Tag: 1707218508-262033 X-HE-Meta: U2FsdGVkX196k0vU6i4Dhts6sgi4IMrR8g9TyPlwaA1Jo65yjo3PFac2XLjlgs7tJcULdbDbBkWT8Go1XIF9SUrzbrAVsASwYyGuTqyx2K/dnLCpiKemAzDbduRoINr1Tvx+IEzMWWMXNe3Nkc3pak3xAY5sPUfQfxwqLbfDCFZQkCS7so4emFGTaZGeg6zzotTAmUbGL73xfFIbFyRKM71f0t0IlkyHB+fEgf4ibebfffsB4e2zChl9DPhIx3xPci4Jl7OmjMpCxA7okFwJ8fOl9qk1rklIwe4Jevjn9mAL5o/Gog0ladg7MpSz1q41LiM1j6bWMcL4jdBqCsa2LJj0WWQJpsZkNd+yHQs1WV/AdigR9X0vMkXgDrlcaFxDN9FA6HAZaP8THUqbcum0Oc8znQ4y4Jg32S9X7uO6avGe8iV9Du6+ZhGUOrxCUXXDDzhVu442+7dafqCJuykq1rWFKziGzvAPjP1zGTBs9GNrDLyTERC1TL+2EE4e+l7SSTu92zFv5yobiRo9wHOvpf+WYZZiNj5tPiEMEyTWMkqYF5J4OEG8ed9uYSx261Paw8W7YZTQtgYOdhseU48GF/MZnEejnkJrbs/7ZLNeIzVcFp+ycwjgzetECcdEzoMxPIDq+hZBSxdQQb78sJuCHCfnY36Vr74ZCuGNHno2wR92xU832e5Km6xo9rp+6bvDpT2nSrYCThURjQO+1+72dkaKn1xyMHh4v01KCUdaAJPM4ozh2LBN7Md1OxnVos0QGHlGsZMt4NqNZHI3jvQzRXC9mZkW6/3CfKH4PkXB8L653OWZIRY/Rs/2UA5tjZ1+TNK0zJl+GeiLQakOItS/9DDJvJRAtKlkRhWmbP0cmOl5oBs3P70RGKD0ULLXVZ0Vy2j9Iojcj4M= 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 cdae25b7105f..461badf26eb2 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -655,18 +655,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 @@ -687,9 +688,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); @@ -843,20 +845,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 Tue Feb 6 11:21:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13547060 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 9FF51C4828D for ; Tue, 6 Feb 2024 11:22:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C6FD76B0075; Tue, 6 Feb 2024 06:21:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 55ED86B007B; Tue, 6 Feb 2024 06:21:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 001216B0088; Tue, 6 Feb 2024 06:21:52 -0500 (EST) 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 57C096B0078 for ; Tue, 6 Feb 2024 06:21:52 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2DAD9140636 for ; Tue, 6 Feb 2024 11:21:52 +0000 (UTC) X-FDA: 81761139264.19.4C93895 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf23.hostedemail.com (Postfix) with ESMTP id 76D53140020; Tue, 6 Feb 2024 11:21:48 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.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=1707218510; 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=FR1onbveHUe7r8sjm3YYDMwQFwmIxq4X/CEpvOMeXvI=; b=pCJ1zezNGA8AHFhfpO52taNe7fL1rrldPNMgo/OyNDn0L8/DL2IEpP+HQf37NsQC5Y5RBj CuCbbxy1EDyj9u3PTeYGy4EROwdeywM3bPne/z6FplTAlY19wFRL8sXelA2tOoIn4aWkRr QUGdt+YfZMo/IOGvPT7+kBbghqm07SM= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707218510; a=rsa-sha256; cv=none; b=P/PeNkvszIETNpRrLHbD3D9H6m5Tpd8Zl2KQSEXH6bSHrjyknHN+Ug1QO8dmXwln34Rns5 AO8EMfCcilWkEHCPIvaRuC26F8WqnAj4wzRAjmOibabpAEedXpqjpPMIYlHZqEZygG1oUN QKYGu7DutDoTfXHC8vnuEDTN3UoBU7Q= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TTglq2GSFz1xnPF; Tue, 6 Feb 2024 19:20:39 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id C5AA9140412; Tue, 6 Feb 2024 19:21:45 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 6 Feb 2024 19:21:45 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfcv2 05/11] mm: remove MIGRATE_SYNC_NO_COPY mode Date: Tue, 6 Feb 2024 19:21:28 +0800 Message-ID: <20240206112134.1479464-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 76D53140020 X-Rspam-User: X-Stat-Signature: znmy8krj5aqgxzbf3pocb9xsmkpi45mj X-Rspamd-Server: rspam01 X-HE-Tag: 1707218508-4873 X-HE-Meta: U2FsdGVkX19s611wUNbWJBe+720OQDJ4FSSaLx7hHb9uXuiPrtWfCGbq1I57r2S4SmP1QAkH7NFq18RqChPpZA2XWmzuDmrTjn3MkD8iUlInKbauCNDnpCguQKdlnZpibz0nlYvkjOwv6rYBUCXPuqJQNDbZvnp25KGL6D7gbQxVpDXWXZL8EE/e8+KgXmJQapJM2GSdBurUesJFbRE/sJ2j4cZyqWejob64X9ep/F0Cq7G6aJP1gsYWlWIVwHDuTmUKtGoUDrqCKT/Nov56RK5eDZrlL1ZncXwOQFfSrse7HDHsA7JYQPp3al/mlLDlz/6qMW607otF6ckVvONWjtOHhx8+aHesMaEyolmjuOao0vStL+trndDghCCC2vA76P7PuEnhnfjxls9uFEzpMj7ZgnoYtoVtWFB2ZzCtSTYEC6ibKFCu/I+otQ6wi2qH3M6OhWWpt/0pIvjNIExPJlC6a95OeI2ZfR8UJukgPeRRaMHaWMItEbCSk7xvRoE1TOushkeGhePM0JtUsqvrBm1Ue1DBsjPsaNlB2WZ3tyKVcPL5wiZkGVbQ1kbcVGGftFW2fjzyoqak9L96WiokWnJFIUgYTwOKAplyBYpqOAOFx7RuF0lOQweMNFsqCUjqAoJPLHy9oMCzQLkIXmQbmgxwu1dQjMLjwHuno45bklUq8GEs+xUcCgcsye5c4Jrwjvcwmte8Mh13PpM9S9fL2RzvVQzZGchtZOOOW0K2kh2SO1kyNciCw1HMPCVJM8ycatE07/nJItGe37xprq8qIKQHslIPPd/xiDQ+0Ox+JJyaRZ1YPOcgGjJPWS9L0BpamW7vtkvfP+w/BMMjcaGkfsrEqBGmbDmY1Il0RPkahOcoCeFhS1MUXDwDOflaAVylihcF4B7JG9TPzx8AiaP/X6B4evXg9li+t+NtDAKMW6GujCG1D7eZQPIEpjV4j+522HfE2ni/psB4HMGDf5v RPU+oTlr 4Q+LQflqFc6gAGpNx4ldboomeYRwlwSo92BJVhNCMgC2Y+cwOyHMH6paQVBMSl4zowjS3B1U0l+uX3m+MDDSdweO4cL6iUJJlXm1B0fkcDgvsBbYne/mmYjaRIS4BXkeE57f15pF4w+5u/EgJFtXSW/wc/ICaSBnrcC1zOe8YwfMphUD1raULUsEHIOKEu/4YB5nSc9AQXyOXg5hy/aSDi07Vqa6sNm1xaGNh 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 bb2ff48991f3..1d0ca2a2776d 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 d746866ae3b6..4f2a423037b6 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1129,10 +1129,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 461badf26eb2..2dcd0d422056 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -668,10 +668,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; } @@ -900,7 +897,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; @@ -1158,7 +1154,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; @@ -1369,7 +1364,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 c937635e0ad1..b9ffe1a041ca 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1811,14 +1811,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 Tue Feb 6 11:21:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13547061 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 D3CE2C4829A for ; Tue, 6 Feb 2024 11:22:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5AB036B0093; Tue, 6 Feb 2024 06:21:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E49F6B008C; Tue, 6 Feb 2024 06:21:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED0366B0081; Tue, 6 Feb 2024 06:21:53 -0500 (EST) 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 83D066B0087 for ; Tue, 6 Feb 2024 06:21:53 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 60139A0235 for ; Tue, 6 Feb 2024 11:21:53 +0000 (UTC) X-FDA: 81761139306.10.192C2E8 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf07.hostedemail.com (Postfix) with ESMTP id E12B84000E; Tue, 6 Feb 2024 11:21:49 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.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=1707218511; 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=FInqeyBKBdRx6e9pEyelk5QnPcq0EKHsr7Xo1WvbmuQ=; b=EgNv/SPAn7FNCNl0cXRUn4lKXEPaNN0y/wYOpQR40a2++HtgqK1vZ9lvNtr85Zm9ret2AB mp+XmowqAy371EGKuk3hCBKfmxZ1yLyJ7+IrryQL+W7X3zHB7ox3RdqpFgFNu7e6EnrD5E CGGVgxZsCzK3to/LuuLojRWh+CcrsaE= 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.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=1707218511; a=rsa-sha256; cv=none; b=xKBc4i3XoRMW9riEcOi37EtWG2561tCRrU6Ff0Z40yOBoOvbLaZUILHHTRTr04prbWpyl8 igt9MPnyqNu/Y1T1Oz99rXXCwQDwyAT2rKyVGkwvjdzCT8GHYZRJPmm1UVyNR+INedDuqM c/jmYPpx0ZGgxAmCQz4YoEDZKBZPqJw= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TTgkt69Stz1gyfQ; Tue, 6 Feb 2024 19:19:50 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 6B9D2140412; Tue, 6 Feb 2024 19:21: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_128_GCM_SHA256) id 15.1.2507.35; Tue, 6 Feb 2024 19:21:45 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfcv2 06/11] mm: migrate: split folio_migrate_mapping() Date: Tue, 6 Feb 2024 19:21:29 +0800 Message-ID: <20240206112134.1479464-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: E12B84000E X-Rspam-User: X-Stat-Signature: pd9robkaskdruixxkfudhaw7wybm45kt X-Rspamd-Server: rspam01 X-HE-Tag: 1707218509-308268 X-HE-Meta: U2FsdGVkX1/0qPs9L2mZO3WrxlDsx5RcZh2HFnkpnsZdrd9cCr5EoYBKDrJ8pNc4GPid6pmMV9O5lPhvhhXb6eyhvQJJ5N4xcayA+L9PWIfv2baxcBB+Eh0gNQ8CXjBar0HATTZwgRvWicFy/20RxJ8eXiyt51ofcpWNMiHYl4QpMq+vcuR60vdiPcv6aaC9k1sfx+FgKFZm9LNw1ePqxznuHughMrPzLi6VxNQg0PoRV20t2ysBsNsirBKt855DqgSNBw32TFl6dxcrTVgkiLXHCC9bbS7zPDyrcxPpCCcwT77wxt0znWx57fe80mAa/1HBnh6GjjRfSRsjQjI9Mo62o5uib5B06kFZTW0777KVPoMddHm7h43E/R78mvKnQbnJXSBBMcKWpDl4i7h6qEVT5hcpaYQDytdnDFyuWsZXZUPHiIeepQt67r6okcb5mPVUrigSUQAM1W1Pejt+VeQ3tsUiHDuDmcrJ40JlkJGwtOby5OKZvxVh4OFW9E/W1PR9GzO4iTp4S+EcqCY0JDPd4WCGHIS322xKDF1ZTiyZmj9hAwlOeu5vUMGcvfYBqFjXkY/rTllcPnZiJlZtX/AFrSYMvCrFt3kIaT6L1w+qIcyP4jgw54r5mskyAZ58xnJPaFEJjj0sPUUgbaOJHwU0mHjshuu4eF6bFIIN/KkFOqSD4w6WyCmsf1j9hG7maWzHmkskh8G7ghc20zUehUZshtpwsvOsNYuRboX8ADmM3iYN6rk7CkkbVCUaRdNROXMNHOThgUInDyNMO3upgGXf8TXlQ7mftZFvrmEXLBnDmTnznnoVFLiZMwvZAIMM9htqDFq4A7DnMckz0wukT6NKEB2fIqZxkXCHqow5VimtBSAwA6T9RKbbaFO7nhUy+/Cokva1yaoxqW2vVmvxsCOAkv0xpOzGX5WZYVCMSMoeoslh0P/O8ntCGxT5ACX7nJIpuhtbB5TsrwHUicp uArF9tBq Cyj+Qbt0/5dNiGiJNuZQJEkL3XG6KkJO56GY3e1rxh69shHrrgblnSfKnp+fN67tjhHb/NbrXH0p6GChw59WOZgZAilHGloGe4lGpN7DkGdbsbZCpLuy2JHvT9ys5L5IkE4f5/i3Pl1rbLTbxA8Wjxt10QQbM03M/cTa3tqy4N8430gRmwfSxENAsOX2kOjmIW4zm 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 2dcd0d422056..1db93b5eb819 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -390,50 +390,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 */ @@ -449,7 +448,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); @@ -463,22 +462,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. */ @@ -515,7 +514,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 Tue Feb 6 11:21:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13547062 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 D2CD1C4828D for ; Tue, 6 Feb 2024 11:22:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA07E6B0087; Tue, 6 Feb 2024 06:21:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 928696B007B; Tue, 6 Feb 2024 06:21:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D2F96B0096; Tue, 6 Feb 2024 06:21:54 -0500 (EST) 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 DF8086B0095 for ; Tue, 6 Feb 2024 06:21:53 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B0548409CE for ; Tue, 6 Feb 2024 11:21:53 +0000 (UTC) X-FDA: 81761139306.06.2AFE761 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf17.hostedemail.com (Postfix) with ESMTP id 5B33D4001F; Tue, 6 Feb 2024 11:21:49 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.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=1707218511; a=rsa-sha256; cv=none; b=ZscjJV3i72UG82WSQBGkdjzIBloUgWSYbtISP3eAUGy6SbHSGjulQWzXRoyHDXd9/ygpXs TL7B/3N5zR6I7Cucy0x95DASHwtFLBAPZoEYTRf89OYi5yUuY3Sy9CXNXa3C7fSgYyzt+U s/B4nP3enhsANgWhUhhe3BXH6YuYOK0= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.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=1707218511; 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=iF6MDgF2GbY/72iRE4woHgUFzOKCWCddvElGXSXr1+Y=; b=B/6bwx9ncGlgiErD7NVVpBTw+rPObfMO5EQSTZ44MAOeTGoPiFkx1DRDC1uVK5pud49XL1 +Sg/9PvBXrW+rSFSm2A8Bl+qI5N+eyUMfAnhjY6QNd4oXIrW0DKzVkDDI000RCAynTQQ0L otOgG4bB+3ZWWB/8at4EwckQHCXqB2I= Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4TTglM0YqtzXh8Z; Tue, 6 Feb 2024 19:20:15 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 0644A1400D5; Tue, 6 Feb 2024 19:21:47 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 6 Feb 2024 19:21:46 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfcv2 07/11] mm: add folio_mc_copy() Date: Tue, 6 Feb 2024 19:21:30 +0800 Message-ID: <20240206112134.1479464-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 5B33D4001F X-Stat-Signature: gsujt3x6imi8mbhfycfiup87pytqb8sm X-Rspam-User: X-HE-Tag: 1707218509-914210 X-HE-Meta: U2FsdGVkX192hZMYBE93ldXsVnZ0FCSw2hMLI9h591gykXW8GC7q6NwmmBo+2FG//z77KJeP40Lfiq+5M8mAlGpisnzMqHnUBW8Fl3tU3NZX9iAV8bpWgR/lh/cXgkl/8NqkIRksEzf7n7dGdEIgKCawVgrE/v1sczb0Np8AicyWTPa+ct1tlMDvxhmquZd7GO/t2mdq+ZUJVVPywdVN7uC9ovVEZ/7kaWONmVSg2mShSJgDqnKCt7HLSN+PW3xYtY/WMY+I4po0pSw6jVepZdexpq6w8ApeOvF82HNcjhRrMdSEUHxVBMk8byts5yx7wGLiZv60sVRu2WtOC9xWxAl7WHn6unja2B0e2+txBIL6DzEKLkqT1kBW8RW95SnhFRpbeTT5c/aPx/9V8YiVmzIio41UQrXUmFMXiM6w2hVyil20wodcoePvQZB7kz+BbuzVKDHzrUwVb9Bd6FPH9YF164zamcSjxgexYdZYDdKUQLJoVLe4vgCH8OMr6t1FJy5cb2tt4LZzUrkjknr2TyWDGrbwlyLqgs5uTDUMQ7kXuGmr/XVxYHUMmJQzdhQsfF471G9mv6/UbLfnJXaEO1YMcKRK6Ff+v0nSxHddXe0L26nq6GjMsa++XszzwaFxYZTTKkfGx8gy3dhEoglYoMeYQZHo6+dOHlUWky+5EyoYrBWpccwogTi0tyaCizXa6Th9v9Jq7Lf14XAJAi4lz7VP4UbvVGEAj1dtG0VHC1VyVs+ut/GOIPlczWcOhRttep1T5hXrn0K5qnTPZHjnspFWQXg9CrvgaHUZ8Iwlol6rwhh+HT+Jqzys/LfTLkE7DvgLxZM9PJNCdRSuboYfiYfR1ponl6A3dvXhzU24ySw9fNPsyW3d89vytfMx4Cq/8CcN23HGnuNpaXsBBLnqdqb9gi/FDnO7rcNFa/H1csImW0DF1VfDR7oU0tyvJdjDWFFP/AbODMj2xT1B/eu 4JgjccbP vnIPKvcXe8izJhCJFc3+59qL/OniDfmLeVJVCAXsV1wPT9z6mDAM0KwDIJnqGj2N3DAbr4R2u7DjP1mXHcCHHmHzzbxaBw6qF0rlftNh3nE6u6NIH3x1lXuvBL2Vp3yYftNRGzXFkSa0iSDhlMqUKu0f9+SGbAmDkClz9p1D9hag1rPewcTQVE14D31eHBGYEezpHvjDN3qkorN1MjyrM8MGYLk+5n/PeJXrM 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 68ca71407177..8818aa5a1755 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1300,6 +1300,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 5faf3adc6f43..63e6e644eb5a 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 Tue Feb 6 11:21:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13547063 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 B2C51C4829A for ; Tue, 6 Feb 2024 11:22:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED3006B007B; Tue, 6 Feb 2024 06:21:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD7206B0098; Tue, 6 Feb 2024 06:21:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 844776B0087; Tue, 6 Feb 2024 06:21:54 -0500 (EST) 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 138246B0099 for ; Tue, 6 Feb 2024 06:21:54 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CE87540682 for ; Tue, 6 Feb 2024 11:21:53 +0000 (UTC) X-FDA: 81761139306.06.E7727BC Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf27.hostedemail.com (Postfix) with ESMTP id 592A740019; Tue, 6 Feb 2024 11:21:49 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.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=1707218511; 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=7Vfi5mPP9Plx2/ma3bq2oRZ1jkmUJwNpM7DVX6FCJ7A=; b=X49FFN26r/P2nq2EsXoMw3DfXeykX+8JCvkVUaWDHhHmODyYTSw7qIYZqyuvppfXmD603H Ce4phCgeMy26MO3ik1FPmfdZQICGDIN+tS8lW4InzU/t9VUzFcRWg0C1vLLpm/gqx8lHwe 7JOyPS7/69FMKc2defJt6j527AuQOdM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707218511; a=rsa-sha256; cv=none; b=DUd+Ok2UXV4g5TP2V+XAuwrc/GP2ZivdD2NiHm2kB9696e9TejaTuTExHd2scBAZsJ+eGa tE5AU6v00HeZVMlWOWjnu/D/KRXVyl9tjq5sw2z2ny8g/V4CkofznN46wn8dgI1G/sYw2G MDEGMtFAUjVtI4/xKwIF4rPkOgnxaLw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.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.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TTgkv6Chsz29lQd; Tue, 6 Feb 2024 19:19:51 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 9CC921402C7; Tue, 6 Feb 2024 19:21:47 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 6 Feb 2024 19:21:46 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfcv2 08/11] mm: migrate: support poisoned recover from migrate folio Date: Tue, 6 Feb 2024 19:21:31 +0800 Message-ID: <20240206112134.1479464-9-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 592A740019 X-Rspam-User: X-Stat-Signature: i7yozc3mttq9iqac9t4rqmebyzqynnp4 X-Rspamd-Server: rspam03 X-HE-Tag: 1707218509-91194 X-HE-Meta: U2FsdGVkX19jiyXkqNUuWiNHiMsKHtc/G8kc2a9U3QL8NjvLtGvb+v2XaPPXEcuP8CznGdFvGQh7pMEAMFL2kTEbznOZZwBZ2+pyWRvDpu/HTgkT3L6BQAI3C66owi4hE6NC6Tl7x2EVIqePZCuoAnulq4YemLCuxNnFKoFZrZaxIHjCh7BO7V8yVvXIRQ31MHktAmykBby4Ic3zAM6ZV70VZiAfEeY2g1IHp5HnvxzVWZNHepYyRvQIsEQUPbYfnM9mCoY0P4zVYhegOtxJNFcfyEjTdmF8cf+FSO4qGpII5ig2KtBRnd2e+7khKw8mWm4R8vtHbTUYYlrg4uucVTJoIxaLQQ6uEUJMyb+iUosGdRQasC+VEPGFS8yPqBKlsBGg+xLvb4wz/BrjgcJGsEQP71OqeK79dWkUvFbOuS+ADB5UlQJc5R+O1zKtTXnZo+FhHceqD0IofqKvyF0GQEyw7UaH7/VmkQbiLXQWLsSbp686r0BAi1JansDBmSmygoIAMfBFftItiOlbDSuds8L/9bFfba09UCL3rsVTVLCRkVynmIwyN2/eUaHY0i7R0bnC9DhJw2iSuF1jHVqvJXXOztXP+h+x5RSWYUKpdtRO7aHzlItoE4RCABc2iPes5oOVK8eWfQ7GaUJFZwUJB8zUnAWmXbig5I0ZcP4oEnHlg9gTC2O9Cn05KXRGkajwPxGg63Kuq57eSckQhIFuQEvKCpEWl+noFSj5gQRXAyszqByIFwDjjMbGhSrXNJPmzADJqItIjyxZe71MUwhCfFz7b6rfA33E5Ji9XQkeJBLh22ObPKsQrAN2yz4VUEMEJGKChPFXRG5vRvWG2/3FBK2wb9mm0J+a73eXfSQMOyfNIUkeYNBkzHDZLaXf1ev+b5W9qk9EgSKdBB0CM+DbBYM7KZrFkVm/7D48RFByENxe3+IbxB0uVlo0RTP+K5wbdPqe3y1wD5bCXHTNlnk 0wYh83fd sgwTEsB4ITMcVGvU32iCasIzZD1qMfzj/0lzwtpmz846SrDtaCe9+f99Atk/dSNZzx1PpKyJJIUK6esFmUkH1lshxQuQogRsuD5ptF5jr3ESREBolnwqi0MWqR16z+ejwrJIdHX6Zb/Zlaq/OaqFnSR4yDQ== 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 1db93b5eb819..6d99052848b4 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -669,16 +669,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 Tue Feb 6 11:21:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13547064 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 AE451C48297 for ; Tue, 6 Feb 2024 11:22:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 508E46B0099; Tue, 6 Feb 2024 06:21:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 470676B0096; Tue, 6 Feb 2024 06:21:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E10FF6B0095; Tue, 6 Feb 2024 06:21:54 -0500 (EST) 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 AF7C66B009B for ; Tue, 6 Feb 2024 06:21:54 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 890FE1C14FF for ; Tue, 6 Feb 2024 11:21:54 +0000 (UTC) X-FDA: 81761139348.05.090BC9C Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf08.hostedemail.com (Postfix) with ESMTP id 5C202160006; Tue, 6 Feb 2024 11:21:50 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.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=1707218512; 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=FBRFatEMkhE0Upv1e1YVUOjsRtSrsCysTkXGkXY7BW4=; b=IbbYNNVBUf7Km6n+mi3ipT9ZRHx3mg+OZcABGDkF6DAXAqJsepdGbs6Jn6o3wNiqB/EeR5 CT7TVVY+YLxdTkvmvflA2JBCpfsv9RblvMWzxSV2RGelqUjQXUssU3obNjV49OWq+WQIx7 8aZODpx+0DYvGnXuEgb0NFqjx0KRI/s= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.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=1707218512; a=rsa-sha256; cv=none; b=Zsqw9vi7sbygEDRS/Y95uLtPoP/y/8cPxJ5PU2H0cr7bTwAw3n5hkiGd4Pb8TQAlLAUyIR MYr+RYOg6+U2RPRKQxguXkLY20UUJVZtl27VlxtHmCLYoqsc5JF8vroF3rCTSchVIZpT4P 9EdHHS+KpJncxYAQ0O6CGufB4akoOXE= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TTgkw56FLz1gykT; Tue, 6 Feb 2024 19:19:52 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 4690F1A0178; Tue, 6 Feb 2024 19:21: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_128_GCM_SHA256) id 15.1.2507.35; Tue, 6 Feb 2024 19:21:47 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfcv2 09/11] fs: hugetlbfs: support poison recover from hugetlbfs_migrate_folio() Date: Tue, 6 Feb 2024 19:21:32 +0800 Message-ID: <20240206112134.1479464-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 5C202160006 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: tpudkp9h14yra7rzmiru9t6yzmddz3s7 X-HE-Tag: 1707218510-270421 X-HE-Meta: U2FsdGVkX1/65eU3kSdbZfDtFqjRGABImIoldYInAlqiKCTvW56haArTTBZqU7vy427KQN8HA8o9BwfrO14YvxNQUwopk8vKo2yi3NoWWOymbZRC8XHNrblaokfl9iYO/vMzZO9obJWnygbVocVc5/LXlF6XeA7O9Tz0snErlqAhkS1619H835lOk7eQUZRpX+70Zg1UsUDgGO5blvTjsSfJy1lc4jwWI00Ezivy7WvK2zjbjRsgxU2WzNjtqBfK8xj80LdnkI7l+wKWEZEMbrydrDbvkED7A2+K2rJ5X7ST+Cm/Hsm4k4CyKyxAXkaEiLoAe1ea0OnUuvZVhnM4oZcJOr399yzDZb/0fSZTginibpzjbUPrLySwTNg7Dfcb4LXF6M55U6DGENY/s3LAjX94iN1FzPMOdletihpP5IjjWL2TogTGpvOTJRTtV6ioL0PO7MIW9dmi+Bn2xKZwdYxe1hIfNejE9dqTrjFO5uNAYAuEK+4wW+5fxdabVRkvDaDGk9YX2ZhwB4sGSAig/d2NIVwC5lu3uc9tAIhhB36Xg3AHhQr20PFiAp+XnFl1NEFLHsJw/UN2kYgw5kHhg2OVDClapEurb1Cjf+xABwLXOBaa8UG+mXh10WeqIn3siIjY1Ejd6L85cYuwLeHJthmFrvpKVJfYlgKbodYiCA7DmOZ5co/2+wnx9J2ObKCONbuldJFxsMymYREloIXGrGeCCYR5tCp4FAa62tvvOtatmfH0nik5HKZHYcjQC4sdEt/wv8YIUVakl5TvPIcWVCnDS8zPYzJAN2WwFCwInAQzQAeqdg1r9mZETcNfLZz3PMr47YxUQ5iu5UvG8ag+tI1lnhLkhnoyFYc+34VfCnkJiTyqtp1chP8BpPwpWIevwzFCJUfeL+L5HPfHrlTjohbbGUCyXN7VqAQwXbk4eB3Hdmm7kvWfWCMglVkJCROywppGZTMqUj6mDwF2inb dBZ29BE7 ocI4E95ZPwwkjUkzPzqlMhT7IjLWXrnxGt/s3MM402OwUR0ZNmGBZ6X9GNHJmKwImA2lpzx496AgQn6X3fndFUOFoSLc+PmXvPKUvBV/abCRkwtFEDkxnz70y/pq39F7HcRPOYOmRpyjcYRPqxNIJwivBL9ce/dwPelJ0JJSxLnBmRSWkbzqtawmTpaSoUiQs9/BJ 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 4f2a423037b6..b4861a69ff34 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1129,7 +1129,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 6d99052848b4..db189ed8ae06 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -538,15 +538,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 Tue Feb 6 11:21:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13547065 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 A267EC4829A for ; Tue, 6 Feb 2024 11:22:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F6AE6B0092; Tue, 6 Feb 2024 06:21:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E0486B009C; Tue, 6 Feb 2024 06:21:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 360F66B0092; Tue, 6 Feb 2024 06:21:55 -0500 (EST) 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 D4D876B0092 for ; Tue, 6 Feb 2024 06:21:54 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id ADA0B80B78 for ; Tue, 6 Feb 2024 11:21:54 +0000 (UTC) X-FDA: 81761139348.29.0C014B3 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf26.hostedemail.com (Postfix) with ESMTP id 85B7B140017; Tue, 6 Feb 2024 11:21:51 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.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=1707218512; 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=Lbim4OxWpe+7K4MQiappNT1vfza0vYYhAmOt8/UlubI=; b=JmKmDebATOrhpLN9XonNEGb04Ihv/yus1SiaaqpG3HXhTlG2EWUyDDVjhzE8HvsAe/JUu1 XjEYnV1mNVjA4kHKLecfhL/UTXcj9efDllJfO2r86jUEs77pcF1pdC3qsVNmmiI0Z2JtJC gYSJsF86DPp+fP5VrRwVPW9PXz5jQKI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707218512; a=rsa-sha256; cv=none; b=Uk5BG77nl2gAOsYiGq15bOGzA3tWzBdRzUgPY+l76TZ6lozArIvulddQ0eFM1HpGNTrSYJ xYRYMIpux1vZskkskzkrxuW0Yz/9dwMLqu9j14Q4e0s4MPt69dl2MMXFIgQK5zudEFQidG V3vy9oxgvEZICArFM4qXrsWg4Jre3jc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.35 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 szxga07-in.huawei.com (SkyGuard) with ESMTP id 4TTgkw5npnz1Q8mm; Tue, 6 Feb 2024 19:19:52 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id DD363140412; Tue, 6 Feb 2024 19:21: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_128_GCM_SHA256) id 15.1.2507.35; Tue, 6 Feb 2024 19:21:48 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfcv2 10/11] mm: migrate: remove folio_migrate_copy() Date: Tue, 6 Feb 2024 19:21:33 +0800 Message-ID: <20240206112134.1479464-11-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 85B7B140017 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: i39zcgiqzrxhbi34qy7yyscqff5o3q1y X-HE-Tag: 1707218511-549536 X-HE-Meta: U2FsdGVkX19m7BjD4wonFe/mIGi7IuiP5a7Pd34FlXAg4X7rcFpVAlTxJJmQPAc3ZEunNnmDkXhTaaJrrwO9RLuWikox1Q0rhm4Vt5h0KWnBd+X4JiWalnuWbFH68TOiysk33s6m6fnyvGnIrkpO2LKUDQIYfGseQR9ZYxG8jKggXk8j631n9U87pFCr30N5pcSMfV3hZlR7psYY7Ngl625moWD5ejZ4W/nAEjFIxDodR7GXejFAPIxhPhKeYF8+T5vgyqlQVdkwqtQ/jv6A0CGTaVyUXAirXeL9K2N2gpukQv2QClMkV5lhiU66fJMwpIw5D7Z4Mbp+YO93klfVgOvD5UCYN95NJTjIU0BrNTFlZ26ehZjsmd735H5iFu3d78GJ//xXSNgHTFW2ncBZ88NyvI8awfXa+2l4PRIbFd4BE5dbQE9N4UKTg0b6yQ/eUCqJaloosRKZahwYDIK6ZrInZYre3u6/aLfeNrwiiKLF0Stlj2W/mZ/rLZYgAxA7T3eETopCpexepSoLlg2iKAbr9lyESlj2qtdIWjnhrdwdA8PqcxzyOjyqUUHbhGDHVxbr4VNoxHqhEFjt8eH5nrSwmDGQjQ4TZZs9KYWPPUlbZqxmPsA0BEO3TZfAoOj94EPK8aPoRxuqKjZvTB8n7pxXduecm9Hn52JJqJf1SnIg3eNSOrWmeBAeAiaxPALUlR7LpC7ReYi6sjfDDJggizAnjbEpKKbtUeUlN8SJBtlFQpLpJDljqZ/VTH/LY2naAG7TyjOUGyckUfPOb7RxrfidOf5TrO6eCZeBolFBIOpoeJ01kr5puPq9oMiutbRoUyHW9ekBcSbU3oSyJpTxt2aWYTpeArq7VudUDzEGsbanBx0zkVL0t0oBTokLSCArEtkpdhcB6p15BDqiRTLQwn6E+dKZbeFaK1y9c/I2kjqmVfmSRIS7Rn5JteATmE/pKCUTJElH714RYqpAAoo pTrV+spN uzr4ruAKe3OqFaDIKasil9h8lNy6YXKG/NsG1ERUpg3q4isQFgwynFAXkY9xr58OJIbB1OPr9A0QNzNsavozTN21UtBq5yGzu49GV3vy1X6v7nfd/dBYjGL68MqK1Qmyn5HBmAyqG6GNElOp+Xbc0QMQZzUUgbsADB+X5we8ir0DulTBS+4+NxOvqSwZVphrlb5T7 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 1d0ca2a2776d..631e83eee5a1 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 db189ed8ae06..7a3aa0294031 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -658,13 +658,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 Tue Feb 6 11:21:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13547066 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 6FA66C48297 for ; Tue, 6 Feb 2024 11:22:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4ED26B009B; Tue, 6 Feb 2024 06:21:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B9BDC6B0098; Tue, 6 Feb 2024 06:21:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88FA76B009E; Tue, 6 Feb 2024 06:21:56 -0500 (EST) 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 60A356B0098 for ; Tue, 6 Feb 2024 06:21:56 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3ED2AA1CCD for ; Tue, 6 Feb 2024 11:21:56 +0000 (UTC) X-FDA: 81761139432.20.849E5D7 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf01.hostedemail.com (Postfix) with ESMTP id 036A940016; Tue, 6 Feb 2024 11:21:52 +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.35 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=1707218514; 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=muKRg/OgrGzpPzJhCqxjfJuUwZdPgx5gbEV5Frn9YCU=; b=sze/mYBIObKiUGgUFSZkE7s/bJu0mS4Gjf5kN1HJzkiylGLFAGgkK/yG5gTlKYvRpIpHfr pI+St6EJ7Jgq81IdEnW1iQ3G3pZvSNNnQK9OV3n6fd/EZkiDDI1WUUZxWvhN0mUN6eyQey xIh7wYbw7Fyfv+4Vhb5o+W+FbIIL0HA= 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.35 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707218514; a=rsa-sha256; cv=none; b=sedgBxEjmFXXUvsBfwpMIGEiQTf7u/J7VaDOXMH0janP4+LsPw/+c3VR4JYg9svBdwQz+h T7U+spB8rfJjgjaKwBGIG3KRCe8zwSVZYQC0XuM9p0qK/yR/CdXEZNQxGuBSztAY+MP+B8 bYOlZ4RPdFQtZfT8PtMjY9zRj2CG3Dw= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4TTgkx3LWHz1Q8qj; Tue, 6 Feb 2024 19:19:53 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 8A3ED140412; Tue, 6 Feb 2024 19:21: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_128_GCM_SHA256) id 15.1.2507.35; Tue, 6 Feb 2024 19:21:48 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfcv2 11/11] fs: aio: add explicit check for large folio in aio_migrate_folio() Date: Tue, 6 Feb 2024 19:21:34 +0800 Message-ID: <20240206112134.1479464-12-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspam-User: X-Stat-Signature: iedd77s6ds7ykx9h1okbqbci63dqcua5 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 036A940016 X-HE-Tag: 1707218512-216664 X-HE-Meta: U2FsdGVkX19u8wdnxGwZQXrPUC6CUomWQsRqsIMf7UoBJFuiNGYEk2qLivA0SsWyjS3+4iTINASlVup8wgOuJWrKmQGgDcbe1SKBZXxkkg8H7/BdRK9vT+z51QjZRhUyLMS9QMH8TpoLnVORUgZu84TAXUqQdRFN65yhbEGOwZV9fx08jij0xrqjdNuwTdCizjm/DEIjckc+pGipKb7T5mAOsEeIYgTAfl2slEjZFA2L8iknNRxh09A4OmnIpBvASaWBxgdtyPsJqi7vEImuI+qCiyG8/jFMQQJomdWlg0Oy3XDHVS41e+a3CB4j/VHzIWlEnMQqNJRiWHn+D8c+s4OoqfVWrmEcRvoYyXovvm263XHEqdtHOSehwYCvf+r07GprUbhxxXTjnWd4qGcGxAXX1OAjb23W1MPnmHS8NachOnMaSbWA/M/Jnbk23q5SEdR35Ypu6OzhZhNYNzkVsaOxjvcSZaYutnzFCWjl9bs7drHKNWAXRBSHeeaAaRNQLkMU3YcPJ4XkVI/cJRupTq2efiOV0Cf6D71H0AT4B1pajNC6UWkmv0MANHsbQ8boyM8VdKCPmRBlAYvEbEHNj5Nd4lVKTB22uFixDZhFAL7wdPJ3Z2gf6Oc2S5VzZB112MD4FqBRQnhM1pnMkplkg0DxY/eWoturzG7XZNKrKyvLJu8KOz5C/46xdG+20NB6D2nESltEjVtmDhuBVTExMa4A/0yWSKu9/eZe1AxXXGZ+zsPBnGCU0Yx7cjtJQ5PXpJxBays6OoOzWj3T4ugBclfvsmK++K6fu26BydgrkIhZlQH+2/Ofjqb+zBiKO1Epe5i7k8/BcXm+7ytFfanuWz73WvXJAEORpAXTNmlGg3p5CZXNnL5g8tqQfAj5P054BmfNITBVFRRR6gKmXGhneDP/obsAvFQ777xobV8C2kxLTtn5kLBjlCgrjpgl93nZ5FxsniF4zduKOzA8cez MyUXrsYX JBDbm7EVO3mjmDmhsrJaRkTFU4wSghMLKg44CH8me+XSV7GvbVHSM/uCzYRLA5phn6uX7K6tW4IqJ9eEdpcFNbLNpNEm558xaQdrABXNaf0GOfpxV5rw0wWlK+UiW3X6STevuaMV62V+0JCSeLHAtEpF0E7mLJg8qVLRiNluwMn3ULLU2ZgUlQXvVjpGIeEOAeEYM 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 631e83eee5a1..372f22b85b11 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;