From patchwork Mon Jan 29 07:09: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: 13535062 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 68FE8C48285 for ; Mon, 29 Jan 2024 07:10:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A11786B007D; Mon, 29 Jan 2024 02:09:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 92A026B0081; Mon, 29 Jan 2024 02:09:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F56A6B0083; Mon, 29 Jan 2024 02:09:59 -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 42C9B6B0087 for ; Mon, 29 Jan 2024 02:09:59 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id F3DCF406C0 for ; Mon, 29 Jan 2024 07:09:58 +0000 (UTC) X-FDA: 81731474076.24.392180A Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf07.hostedemail.com (Postfix) with ESMTP id 99B9540018; Mon, 29 Jan 2024 07:09:54 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706512196; 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=cqpxQBobUaCVBevYaT8TLpoPhlEky37V62DAGEAQTEU=; b=Y0Siph6hN2cNj82GFLPJuq915VCUXN4TuJNnYgA8vRGcHhtXoLnpwI1oKr8DYyY3J1kLou Q3avhmXC/YUUrTu/lQDoiCY40Dj8WodRVdWVKJAsUbv2MKU2hHNsnjpq/rA531tp31Yd6J JoofV7Ekpp0sIzmgdu8vVOCQeKHyneo= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706512196; a=rsa-sha256; cv=none; b=1qIWeFYJD8mhOcP8t1hxU4fu89/lio/bWeACglg0K98VG81zqsZtJYjzyWFLX860v1ewk9 ay0iUaxZsOB7EErAUInPWvLIiV8P69ofOpGeEOosa+MhyrYDJl//bSjVcYiK0n0JXAQ+fF kEXI03HHnrjZdEsQJZLvuRHXW5AYDtI= Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4TNfXj5rQ5z1Q8Xf; Mon, 29 Jan 2024 15:08:37 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id D604D140EB7; Mon, 29 Jan 2024 15:09: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; Mon, 29 Jan 2024 15:09: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 rfc 1/9] mm: migrate: simplify __buffer_migrate_folio() Date: Mon, 29 Jan 2024 15:09:26 +0800 Message-ID: <20240129070934.3717659-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> References: <20240129070934.3717659-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: 99B9540018 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 3heasezb59sd9ed9zqiomzd6gy8bd4h9 X-HE-Tag: 1706512194-8493 X-HE-Meta: U2FsdGVkX18juRag52qp9RvC/gyovUXjYQGQ8wD9oMSp+uOH3ZiXjYsr+639+SQxJT1WiWpHD2EGFV0US6qF7lpOo7fYT2fSKFvMOcKv1b8CdYywJoo71EOlzmXxIVBNsTewT+lMeoEsalOiNMaf63Mx3AGMEzkZ4A5fpbg5t4IvcyvUihn4sPDCujRX6ElvPKwkbXl+VBTYIUzJQ3YJCpVdxCdorpz5nUIAymHx0gkeuozzt95hEgpYWU4x93jeDkoz/m3iMBk/lUWaRxt+8oOLMTHltBsU5UTQCSEaK5kUyIkx2id0tu8svZYBDzRXYbpQ6ACS1QE/I7Ya+IYRVOTJxmiJR1gDm8l3AHyPwfFnH1Y5XgSiJMxdqSzH792uqitVqxl1wm+WFxKkGT5pWbi2t+YAoEgTFvUg71CT5/vKQd20hs4n+kWRXYEYgNAK5rlRT0f0qyR5slZu+IBIDD4Uq4ro6hRZ/c1C0aRy/aUHVnNWMtj/Tc8sxhojN1p1mNS2TJ6zSRaM/hzj4MsXilpozWlZoOzq1RVH6suIyUwUMYSSxh23ylwq8trD0snHFsuf6u3sP0z53QuJprawxuHK89mhrsX61fTHKozGbSSwYPG4fKpMb23YA3pQsGPj9BjP+lWlKS/LBF17fqxm2yYWmCBCiWgpk8bjIJWBTOPGCRRvv7V/3olQolCz63V1FwnLOFw3kfMWqe2NM7bAV0INhSt8rNWtE5E1Ox2a9RSQqcKM5bS8/nDF3DJRWTuhuW23n9tq4btgm83JRbZhhQkZzq+H7j+4xPjVANgNqOZLT3rfmYBknNSnSEWlgqjgNvVWQQGFUSPGoA3zEkmIQLMF9bgt3JH8zrl+QtPUa5X4cFe9qQ/K63bujdYYBbxWP2fJfHzve6iLEKRONOcLB7/VabVhpKTpV63q3a106bClpkeHF3wvYa9p4ojXQNzk3rYEglERMctFMRX/9Ue iAOxYaxq hpwbjf1TSLcqBAKxFwgzSkv0VXKu1fAOwzAq6mdat9wPeJN0VNSpgj9a48bUzSAaTfdM14RhP/dq0rrIComPldcYy1Pu+aiNQFN6f/Y9Q8eOPg15Y3JW6KudvpY3myzWwLYBcMfT5gEFkkcykkBEJ4vL2NQqH3slYIss0mezlgHaQdhBXZ1IDJYjYR5FRZ0tNip1u 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(). Signed-off-by: Kefeng Wang Reviewed-by: Matthew Wilcox (Oracle) --- 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 Mon Jan 29 07:09: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: 13535063 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 D0D39C47DDF for ; Mon, 29 Jan 2024 07:10:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0033B6B0087; Mon, 29 Jan 2024 02:10:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EF6D76B0083; Mon, 29 Jan 2024 02:09:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C83C56B0083; Mon, 29 Jan 2024 02:09:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A32366B0082 for ; Mon, 29 Jan 2024 02:09:59 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6F59C1203E3 for ; Mon, 29 Jan 2024 07:09:59 +0000 (UTC) X-FDA: 81731474118.21.98E8F42 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf19.hostedemail.com (Postfix) with ESMTP id 1095D1A0003; Mon, 29 Jan 2024 07:09:55 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.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=1706512197; 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=QqTIOlrtZkjnZBOy56NFsfvPFGoBl6IsNXFc+pSsR3w=; b=JDAro+LrmQ2Vr9VIXftvdiDpbWPJvDNOSLyuOQzUw2hDN4vX7q5cgGpjIV1pYeNRtdPVvB tXmkMvJiQoZ5IZWbT8IgmX8hYETdCMQ3or2Pzp54LUzLJTT7aekEx2bDkHK3ofr2CdJ/n5 JtNx78OQumDHgJvvSe6ybc5rwwwr9lY= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.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=1706512197; a=rsa-sha256; cv=none; b=tVgr9gQkKmYCoxyQEEnT6+TpMDX9tX4vimJCQgC8Wcc/HBZcaCCq7r63B8LpZHB5DUfAJk I49XEfin0R4X+max6jy6b4M0ZNwRruYGjYrlsbg//PtlCO5B5WFWFQi7mUGHcvi/5cSo+I ihsj9WlaW2rrDFeketR7oNp+bMk+OBU= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TNfXB0VdCzvTXb; Mon, 29 Jan 2024 15:08:10 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 80BAD18005E; Mon, 29 Jan 2024 15:09: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; Mon, 29 Jan 2024 15:09: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 rfc 2/9] mm: migrate_device: use more folio in __migrate_device_pages() Date: Mon, 29 Jan 2024 15:09:27 +0800 Message-ID: <20240129070934.3717659-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> References: <20240129070934.3717659-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: 1095D1A0003 X-Rspam-User: X-Stat-Signature: t6snbhsxgpgsuq5t6y7s6axa5me9tjmi X-Rspamd-Server: rspam01 X-HE-Tag: 1706512195-737792 X-HE-Meta: U2FsdGVkX1/VY107gooTBOIXpapyitpIHmsa100y+z8AD7l1dyezMFplW5BRk/tJUTBFDzvw6g6gGMSAbRP4wldAs3Git4y48MV50P72CNPS4LajlpGyyTgZuLxOkMACST/Mvic+6CSGSJCvZ4PWNPkOU2NsD55rwWO2gtwwe+6mQx/458WlHn5+fzPDp8V3VHjyZ8t/1lLDgzIrVLK8GIUB4xd4FzPkKEP5ZDTCzbmfpJcDG8wWUSzsoAWPANh88x6D2SrMT0iEhnTMM+6jn6UKDIef391s1WX1zaG1SYEZuOMujYYzeAJwa8OY5TeW81At1YuA8IApJlC2vTJEm/yVp/V4M86ALlFqUtC1HulOcksi8OB9JbBoBooKNRSPO0t5nUtEbXsPqvuI555fSh+9ZCd8G+KIKJykhiP8mfz17qCI8u1rh+TB1U+4/038uXwyyzx3sgYW+TBAww8SjH+ZoWEUV3T3MriUOilRB9Jv1ezG3Y3iZWebDtVG0m1CPbw+Mif1lXeDmAiB467aHHxfqt/Z/OEVys0GDKB4jQiyqzSjqajkz0YZo7906nzAf+gl1bUdLK23fxKuUYt7X/l7MF/vePIKB2nPAw3Yg9F+hNv3vPzFHCAhUWBlApGDQzYa+WrvymOL3B61+7iT6yP1Wytu7MAy0y1QemaDtcOGcwtOg4OL+R60A4gUpx/TAhsbJwlrxEzyP/Ap5/1EGGzgw0FFuXUJ1NwaXDbcv4F4nMtJ3yAyXtzPdggY7Cbo+TBarC44v5jYb6uN0wJutKoAGoIU7aZ/V0YkBy0DKbCUXtd8FGt7M9H9bPySqRaI4l/WT3DEu8dkexl3MV3ruKfDoyK8ZAtVgWps96lE6Ahjl0RA4CjHcGvmOr+E0a4jzM4/mUZ0ttX72Em9KFwGOBZ+rClRGLJGOPlIHZosBd8KD2HVC7f0m38YkgXhDKnBTvRHvwdNOYRJuVLT//T iCAw+4P+ +qDu4LKS59Xsl0dEgh9bwqky590B8jES5yFPAtp6BRdBiSsXxhh2W79nrBKo4AaD7CFHdE4QC0dm2m/YYzdjzSAZ1P8/o/A0vGfTGUvHSupFNlY7yjmlZ3T0SiS+OSo2MvD3b/ox25/eVBelpLH39df+g31J8xr22PiQnn/Dz3aJ+MFPNkO+mWY9vqnuYlT3NRTLof0R/55KcXvg= 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 three compound_head() calls. Signed-off-by: Kefeng Wang Reviewed-by: Matthew Wilcox (Oracle) --- mm/migrate_device.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index b6c27c76e1a0..d49a48d87d72 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) { @@ -729,13 +730,12 @@ static void __migrate_device_pages(unsigned long *src_pfns, } mapping = page_mapping(page); + folio = page_folio(page); + newfolio = page_folio(newpage); - 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 Mon Jan 29 07:09: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: 13535064 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 663DCC47422 for ; Mon, 29 Jan 2024 07:10:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BAF616B008A; Mon, 29 Jan 2024 02:10:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AFF796B0082; Mon, 29 Jan 2024 02:10:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77C856B0083; Mon, 29 Jan 2024 02:10:00 -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 58D056B008A for ; Mon, 29 Jan 2024 02:10:00 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 252E012049C for ; Mon, 29 Jan 2024 07:10:00 +0000 (UTC) X-FDA: 81731474160.18.8F2885A Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf08.hostedemail.com (Postfix) with ESMTP id 51B7A160013; Mon, 29 Jan 2024 07:09: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.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706512198; 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=qz1OxHMcu9b+Mwcpeh11Ppmm6hddyM5wB9M1Z7kbWfo=; b=Vb9aXk8JtrkYNvDfRAnofHIcrdiSoSksCzAw3EtiTIuxSLuxY+Md7ApE3bi4rDQob2ajOd Ix+TaHr5pETFDGNJYGa48ISQy0odpzSfYTsYDfUG4BseAa9vtLBMH8L+c6GziMqczEwKG7 PadFoxbll2Bm6TOnUFXj3om6tNlat0Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706512198; a=rsa-sha256; cv=none; b=sh0XdzVg9wzpmw+vGx9kpzRrgz3986QhdHYbnjeUYWC3cBgDntcr6AUD/nwDNlfSx+3dvw fK7rU/Wga294NLQSNz3pdxeVXMFuG5gpvQzbhhLHC/kO0QuRGC1QmjsUi3+sufvqjo9YDK TABBnIM3rpbcNSyX0cbg7UYKjVj4pa4= 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.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4TNfXy13qLzNlmP; Mon, 29 Jan 2024 15:08:50 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 3A109180076; Mon, 29 Jan 2024 15:09: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; Mon, 29 Jan 2024 15:09: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 rfc 3/9] mm: migrate: remove migrate_folio_extra() Date: Mon, 29 Jan 2024 15:09:28 +0800 Message-ID: <20240129070934.3717659-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> References: <20240129070934.3717659-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: 51B7A160013 X-Rspam-User: X-Stat-Signature: 5thbu8pwfuutgzp1xqojdir11jsb63zm X-Rspamd-Server: rspam03 X-HE-Tag: 1706512194-42685 X-HE-Meta: U2FsdGVkX1/a5UbecqkkwajPQy2GDooRT2cYeHiF177+WH7t/2MfJQ2832DBV+9Camc9snsU6n1DE/OqQ9KiZVDnat0Ag0qlmk3+m/Ex0avpd2+V8ApfF3JKpoAW2I+FWKPU3AUfWE8f3T9RpcBeCjDkQ6s+/CXHoDH7bB1TttesZW/rHeoaRUcuDWUZAruFwiMgcroa88basGrNnGFBGHDZ7Ko8YP59HIKgf53Z5etlP5fKKUfaDKhGLdHO1lpV6jXN41AIfMzXlBjKLVqNT0zgdTRJMHfN2cCftDVmeyAMWMbwMQmw3REb2Ad/mH7kDIg2VVcT6LSE+WRJRsARpMHe51b38HRNA3eRPudOCibiYJjEDpJofVVw/Nhf85A+zE6QtdGdPBrT7p1fFpvgDvfygtsrJB99FzMZCxP5W3FZt34rC5S3DleRSWvMyeOPWUbhJuSBrzalgTJDidwf/geYrnVUmHDnQtAd71zdSHUOGFYhV2/hUzZYnOV8Ya7TgGw2S7ChNHEkkvhHrOh8FJTSmvcCUp0bQ4NZyLfxRuojOtNS7yYBL2wJz3V3eDGkp3Mu8+YU3kKqcMOGTy/mQK2tMCp/f67eg15xHeY2VoOib1GTArWfSHt19SFbFda/rl/kOk3ftP4bUSfAGOHE2aI4yuNnNXrfNVPkfu+55FsfZ3UJAw10OdO9ALvzSZss4IpJ4/Pjc/KSneLLH6196AdUUnbxxSGTrEnqZatn/AHnFG2rY8RZGXoZ6tCSzNxRjzkeXZdUaB91XTNvixR2E5cqH/zUTVxYXpzscKcrkszLpFx7vBw0vbHzAl7puDdKjUAPcbXscjTNF7OB2qCoa02GDAly4rpnrZiS6SO7RME8Qfbukop5PaOFuRbJLSNJmUfucBO2t6AAmxPNLfESGk4nI8gN9nabl0khxpIkc+S8agBnw0OyM6ve9rrsHYDqVbrN7kOKmD+fMVOWXDS 5a9LxHDS fXKBFHt3EtjHtTkJVweeiVS3grisgDh81PDc140VXBsmCWDMezR4kDPeePIfqzYQi0SWFDHNAWbRrDd0G/1xHFX0JTmfsnjJ2SOxLPZdQfgdqe7X90Djvg0lvTlY5WTa4sRAs0b6PQ37b8gWMGYMHVdQ7LkvcfeTJyl4Hb75MV7TnwRblBH1Y3xWOIi48amXFH0m+ 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: Convert migrate_folio_extra() to __migrate_folio() which will be used by migrate_folio() and filemap_migrate_folio(), also directly call folio_migrate_mapping() in __migrate_device_pages() to simplify code. Signed-off-by: Kefeng Wang --- include/linux/migrate.h | 2 -- mm/migrate.c | 32 +++++++++++--------------------- mm/migrate_device.c | 13 +++++++------ 3 files changed, 18 insertions(+), 29 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..a51ceebbe3b1 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -655,22 +655,24 @@ 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, enum migrate_mode mode, + void *src_private) { 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 folio_migrate_flags(dst, src); + return MIGRATEPAGE_SUCCESS; } @@ -689,7 +691,8 @@ int migrate_folio_extra(struct address_space *mapping, struct folio *dst, int migrate_folio(struct address_space *mapping, struct folio *dst, 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, mode, NULL); } EXPORT_SYMBOL(migrate_folio); @@ -843,20 +846,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, mode, folio_get_private(src)); } EXPORT_SYMBOL_GPL(filemap_migrate_folio); diff --git a/mm/migrate_device.c b/mm/migrate_device.c index d49a48d87d72..bea71d69295a 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 Mon Jan 29 07:09: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: 13535061 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 28F4CC47DDF for ; Mon, 29 Jan 2024 07:10:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7580D6B0080; Mon, 29 Jan 2024 02:09:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6DF026B0082; Mon, 29 Jan 2024 02:09:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 580206B0080; Mon, 29 Jan 2024 02:09:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2D4506B0080 for ; Mon, 29 Jan 2024 02:09:59 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C76C240283 for ; Mon, 29 Jan 2024 07:09:58 +0000 (UTC) X-FDA: 81731474076.26.1BFA573 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf13.hostedemail.com (Postfix) with ESMTP id 7589320007; Mon, 29 Jan 2024 07:09:54 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.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=1706512196; 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=dS6bVv4fqOabocshMqh7XJ/eSHBm/0jZ+QvKDGlmjuQ=; b=rnYDULooxrtURegDUqHk+zTMhLPEQDGyWsr1+I3Bo1VZbUKH+KgkC1fYtly9uGxsr5ff3G Gs3OisCLPzS5OJmaoTmCm4/atvNUk558cR639mLrnkC4qqMvqoNScXXeqZn0EzZ793aK13 wmfrUYw4f1SvM29/BId6AhthEgTcX1k= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.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=1706512196; a=rsa-sha256; cv=none; b=eaiQHE3JXuinxCSY8ngldfVlyO6YRq5V7WfJGUNrdvEKYdZb7Kuznc4hOzpYhHCAmMs8DZ tWc2SCOEFQJhHIVMCv4a63eDCsg+8++ZMVHgzInNDjaxX/OLqf7wBSOHecqQ/gwet6oEOt Bzb4p2l+ucY6FGiQJTi5rbGNyjfCX14= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TNfXC2qHwzvVWK; Mon, 29 Jan 2024 15:08:11 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id CB65F180079; Mon, 29 Jan 2024 15:09: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; Mon, 29 Jan 2024 15:09: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 rfc 4/9] mm: remove MIGRATE_SYNC_NO_COPY mode Date: Mon, 29 Jan 2024 15:09:29 +0800 Message-ID: <20240129070934.3717659-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> References: <20240129070934.3717659-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: 7589320007 X-Rspam-User: X-Stat-Signature: weshhcb5zyho775todni6anco6g7ycue X-Rspamd-Server: rspam01 X-HE-Tag: 1706512194-487735 X-HE-Meta: U2FsdGVkX1+LsLixugJLk/GkrcJRONiH8caEKoXmknSFwopOBlJm1isHGGM9DzUaPE3J4NF+DNS9iWiRCWEQkRMDYJWCMAUlsTiLnUTTbju9RrYkl9SmKkhj91dR7DOavE+5LNHgsXhwor6h6gXV/NoI+0okIbfeE/seJBoHtqrVrrpa+74v64zayT/evT2X21gfBcGycEfFhQpIccZTuum7/sxIGFebuZgjiTHvakfGxHttZIm4Cq0PTB/MvKw1vwSIyBBzidbx6T6+/LW4WI0/uARVZtWqde70KPRu1sZnh9JD+YfLSf42x+widXJ0Yo1QGhElJfeIX2aq6wF94sOVYL3u1uzpKBvBA8oOim26JQgGjZxfxS+XLz72W7xGhH2emwHIpNNQRtFFE307fBLrkMUgdEb/svSWmEMbJogHrDe8As8z5S1t8JdRZOETal9Ydi8zfywOlLETyRZMGkob/rlaaDrE3Gk8gLr6VFEITDshhJTehaUSrMLABCyMHmGrpqA9OFgd0IbiHRiD4mHSJOf2TYLo6906PNEex0SYN91zYWcJeBBdNDE55sXF4i4U+NA3zmRtowmmyud5x5rSRWyibB+NawUdfXfXH4frjXTA/PzCga++cCNMT/KvfN8IhZPzKGhQD/VRmgITnzVJnYwYh3IFQtqyrgfitLJeLqTiQZP4irMNxkopSyn718PWG9o74647Qp7fqYNssyaOn9BnR9PbL2DqKZNpB73G+qLF3lLRU1iAxenw7eObmsblbU14yfuI/wXUCsqUbCLcDOTHUBXEHK8KrBwGWXOJiQOJM4pX7BLOFuSoLxTC5s5ZYLl2faMVUR+gLIMQbFmA/Hvc2izfYAXpy/aqJ7YAbNgh8+dpOdda9PoH3YQsrq/UZRwZiJ8sdJUibWgGmh2452pHxGaYyrzFTZMXYqTGda6Sp8iabInlMuuHaIo1GoJ8P0OlWFta6UOSCfE NVqQBDoN 19gvSmwaurWHmKyepkzuSqgyW8JUnIBu5MVBllJkm4qqJsDnOqXq8v+PkK6c4OHQDA+pcL//zo7xF08j3z53K8oszZhnWmF92uODMNOxRjIC4z57hkEL0BOJP9d5fFCBwMjR+Bo5tgBVFV2AsrB2wPctrJLuawm/Hszc7Qml+i765CFUGmV08dbWISLGweN41/kJS 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 ee13c2ca8ad2..52839ffdd9a1 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 a51ceebbe3b1..107965bbc852 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; } @@ -901,7 +898,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; @@ -1159,7 +1155,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; @@ -1370,7 +1365,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 Mon Jan 29 07:09: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: 13535066 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 638ECC47422 for ; Mon, 29 Jan 2024 07:10:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CD936B0095; Mon, 29 Jan 2024 02:10:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F1CC76B009B; Mon, 29 Jan 2024 02:10:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD32C6B0098; Mon, 29 Jan 2024 02:10:01 -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 ABC3C6B009B for ; Mon, 29 Jan 2024 02:10:01 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7B1B11A030E for ; Mon, 29 Jan 2024 07:10:01 +0000 (UTC) X-FDA: 81731474202.03.45EEC57 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf07.hostedemail.com (Postfix) with ESMTP id B6D054000E; Mon, 29 Jan 2024 07:09:57 +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=1706512199; 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=xgsxhf5sjocA88FA6d4ppu3Kj0tKOqf0r0HmqGCZCng=; b=bOPIOe7jVWsQoL+xBUnFmVeRBObyhkGtsyvnEklL/4b/P6VPaIVfejcTbDTWGmqILfAnoW trFJ2vWMOgeCDdAgytayTHKrQ8X3neJ9dVUEpdd3UsqXWDJ6ryVk8dNTWRjtUdsDQpY4Va SBRClOU0YsTwEdukw8oPlkmLDcW3w+k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706512199; a=rsa-sha256; cv=none; b=n1/NrGXzqyDqMDTPFiRMweZp+NhggbRNVrQJDFMl1v8Lrg0bLaqHUxxlxmz27R5pGiUQ4V PtjBm6gC8NXbk5bk08x5dWlzgeHvNJFXGCmOg+tRfawHXgoXqvgq5l/bxa6UTiw4XcJwFB mEwxmiarpOxdtZ2fIiW0tDR3Jews1zY= 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 Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TNfSy54GRz1FJfX; Mon, 29 Jan 2024 15:05:22 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 757FE140336; Mon, 29 Jan 2024 15:09: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; Mon, 29 Jan 2024 15:09: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 rfc 5/9] mm: add folio_mc_copy() Date: Mon, 29 Jan 2024 15:09:30 +0800 Message-ID: <20240129070934.3717659-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> References: <20240129070934.3717659-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: B6D054000E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: c5efb1pcd3zk3qtymbb3fkamrreedcus X-HE-Tag: 1706512197-194447 X-HE-Meta: U2FsdGVkX1/TEocCTWPwyME4ivmCYiRuObmbpKUb21sV5J10VnBhz/228Tr27ZIPyLYp4qCsXqEG4MGF/+FZS2p+uJacposocbcBEaUNlfV0Q7zgxeqsxSYDyzAmZeMpAo2qajqtygxNAABqNCSsTnKSM1QoXZMLHNXllQ/kcCb7jsLOzxppRdAJvnVP2TeiKoSBe93eAzFdwR42KKsgkRuZOhG1wlU/LScE8t8YP/9J8ah6dmXrwMVSyaFqqsLMP0mq33poZp7+e3bawK4Tma1ve+F4sAamORbV6TXcPwQqkcHFhp3EYGrLY/IOw128Q8hpbgTlOJ4w9yGzm8/iZ7xdm2JiBJCiA4ISfOAPFMOf4EZNohU3fw7T+Kckd7nQAYm4l+6LF3Xy7IOzIBgPPaoqkEhX2Fa9Y1c2Pbfm7sBYSmrA+0sY38FQX82codbuYoerblRqzVBEEr/y7wDM9uEwH5/x3QzC1zr/fZAQNGVdvuG7AokrVW1lSRKsi+4jKIc/1VOcct1wRBfYXn1DRLZDXdBCMPgq0nkoZhX9/DbRRsA8elBTvmaMIIpzTcZt0uIEIddlWM1eHvyhBuqSDbJBhjNAfZHIkp9iI//FDC6+KqovlrbgmAB3WMjyjryBgV0i6Wwfl7UldlGeHBQXQm211Z7zBMxjEIYcCGwMFNb63MAQpHz03kzGLpVCFLjyNilo5S4UBZPMAqcGV1XgzBIPeGkZoyCR0mxbs/jL3AUxIozXi06rEb80mqB3pIC+7hM9VMLfE9xufCBN7YGfaikPqgmWFE8OvJlXscoe3bWPQrVfOD61sr4IZMlZVU6DnU4eraUkIGjFon/1LECc9wDPuOEixJjbYbGJoPq2bEN17YMWAwM3cheATbFnOWmoGK1jdl39eC1h/+wPpNCF3PGjkRt8e9ZO7WDDHqov9EcJJ9O5QKOXLcUNzevrlAX0DHkLlzCr6gkepQD+NUe 67IrT898 bAGkbzTBLJdI+9PbiyABunccztU/SbqGPfEOyyckxydoGgV3ATTygV0VdXRb54VmJWwt3dg5zHII7dQJ7031Ta0+g9UUDrWOS0rDStWXDP9knnVUTzaVZX21WoQi0c+PECuB69e1EDVfKU98eqSlLf/RRE7JGKEbWpSBJaTktees9RGsfvzS8iAaqroeXU/99xfu4 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 ac6b71cbdffb..fffa6025d8f9 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 Mon Jan 29 07:09: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: 13535065 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 1B044C47422 for ; Mon, 29 Jan 2024 07:10:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77E196B0082; Mon, 29 Jan 2024 02:10:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6DEF26B0093; Mon, 29 Jan 2024 02:10:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BAD46B0082; Mon, 29 Jan 2024 02:10:01 -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 1E28A6B0082 for ; Mon, 29 Jan 2024 02:10:01 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C770BA13AA for ; Mon, 29 Jan 2024 07:10:00 +0000 (UTC) X-FDA: 81731474160.11.5B7E4C0 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf13.hostedemail.com (Postfix) with ESMTP id 0A75020008; Mon, 29 Jan 2024 07:09:56 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.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=1706512198; 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=wob4Vgn1ZkSMoOSUbtWxys1VhnUJlKtaKtwaTBq2NW4=; b=vv9SW+jQ0q8TxWFLX+QYW6Q6ZXVwagi8QX2rMQdjWwzpslB2gi1E49cju4ykHHej5/L55m gn25tIeyzA0wMYFIRW5mPI6x2XiRoE6opcnichNoH5mVJjdH7PrKrA8cRVU3MRqL6VuJxn SrQ2rGAbr71zApW/zuLboRvlcmXoQzk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706512198; a=rsa-sha256; cv=none; b=Gl4vWCNGPl4Shn5kmC4K8/zCkz047epYlUN9G7hkWbfVoXMGwSkpbOcHdNckm+MuPQB3WJ nVeQzA7mxt+cpIBQNyfK5x49mchikr6gYpHSKAhCif514pJkuZXQ6HpV49zu2ikdCINBSf r7KrCUQlyw58UVKmpYH1MCFqVFzbiEs= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.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.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TNfSz2Kfxz1FJmJ; Mon, 29 Jan 2024 15:05:23 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 1734A1400DD; Mon, 29 Jan 2024 15:09:50 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 29 Jan 2024 15:09:49 +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 rfc 6/9] mm: migrate: support poisoned recover from migrate folio Date: Mon, 29 Jan 2024 15:09:31 +0800 Message-ID: <20240129070934.3717659-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> References: <20240129070934.3717659-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: 0A75020008 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: rqx4yecuhyjcxc15af4e86o6yr8bjmmi X-HE-Tag: 1706512196-658370 X-HE-Meta: U2FsdGVkX1+Rd+KhBJp/hp44VUcoDky7r2NgJhzkUGdz/OYKQ785CNlJBeSt9TPXwbZu7W8HPEdqkEyknhUvLi++39LHbo0vC7KcGI4vN24VWiBbM5iAA4q0IGSY4w4F5X1cxn23V/3qvclJyhraX+Fm0PABia/X9XwTtatp97Cs/MFj/UOZ1pOqwbvsFRTImfxrXaYffmKuYfymm/pIgjo6rrXEG4iuCWSSO+wH5Zx5EwdaCeQK4T8P4Wg9fhqZyUXlrsMQcPRT0p0fxlwfQNg1NdDQsB8lKfklVAe3E88shguWAp5cihnsb24Pxp5uZ8RAcP4SO+YCTusc97UOZVlAYMr3Q2Lf4Oek5nmFCKEdJ3F8ZR3P0GZuSjEg9I0MHbhAJuNCTZiKlcZc106LPnJo+7Reo5vYQ5nDUE/yhzA7di4L6++MAvCWjOZn1AkfD6oL29JLhQpo5SGqzIKnnvXiSzVio2MJFn+tD3s48hpSE3wDKsKNNoen8kfpjlngDL6uTRoV4DNQn5u+VxwH2UA+5GiE/kBDpyERe1va6JdG0gENoKCyrY/iLZl4lHnu06xnh8JhJcXvFS2EtghXLRZL1ugTHRPd2kBFHrvo3A8GpJwJ/OvVhB4iVxPp5S+2tUjdbw3IMsgTvVFsaIfZpV3kUr2fiYjAjaXwZJ2lI2QblGJcddxkJUXZGF679sLrx6PGg164pbAeuCO4ArN1w+/OKvqHJmrOSNILCPaLYQNg/aOC5lYFc8RnpsaB2ggRf28YnfpMeyo4LQHAXArLIiA/zxqK6tQnxk3+jTu/EjGMKdsGKkBfHj94n9jzrtI3raa2Ohn4DZeNNdu5KouQ06lOWCPx90sJ/7x1p8LV+H8RnzkFkDfXdlNL75hByym2Z1hBED0o2wqyAc0+LJsWfZj2Eh8g4OLZOjDxesY2csUiliPRa8VjakvX0S+MgbFE87QAvNfjJFZL8VjLkE+ kS95a5r5 WTOru+4mKBXmLl8sDvI5g5E9FDo4d7eJ0ZVGexhVwzFQrtCVp7HpEg/yZMjqul8A9Nk9DD+i65fDjFZ4slrwzgMxoHs9qBpkR1UYqwxg03/YBAOeQe9pVhpzF9ySUF+WJnrqcjsCkqHu/pr4= 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: In order to support poisoned folio copy recover from migrate folio, let's use folio_mc_copy() and move it in the begin of the function of __migrate_folio(), which could simply error handling since there is no turning back if folio_migrate_mapping() return success, the downside is the folio copied even though folio_migrate_mapping() return fail, a small optimization is to check whether folio does not have extra refs before we do more work ahead in __migrate_folio(), which could help us avoid unnecessary folio copy. Signed-off-by: Kefeng Wang --- mm/migrate.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index 107965bbc852..99286394b5e5 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -661,6 +661,14 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst, { int rc; + /* Check whether src does not have extra refs before we do more work */ + if (folio_ref_count(src) != folio_expected_refs(mapping, src)) + return -EAGAIN; + + rc = folio_mc_copy(dst, src); + if (rc) + return rc; + rc = folio_migrate_mapping(mapping, dst, src, 0); if (rc != MIGRATEPAGE_SUCCESS) return rc; @@ -668,7 +676,7 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst, 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 Mon Jan 29 07:09: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: 13535070 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 3AE4AC47DDF for ; Mon, 29 Jan 2024 07:10:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 960D16B009A; Mon, 29 Jan 2024 02:10:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F4406B008C; Mon, 29 Jan 2024 02:10:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 338786B008C; Mon, 29 Jan 2024 02:10:03 -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 ED95B6B00A0 for ; Mon, 29 Jan 2024 02:10:02 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C0A041401CE for ; Mon, 29 Jan 2024 07:10:02 +0000 (UTC) X-FDA: 81731474244.24.AFA7A42 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf14.hostedemail.com (Postfix) with ESMTP id 4561B10001A; Mon, 29 Jan 2024 07:09:57 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.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=1706512200; 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=LZ6Y5L3dRmfa/dBtMJdnlibq2kcHoOr9a3q5ildHcpI=; b=2QTLS1sXzjPP3r9Nq3wpWOHlVTEkIpTDBVDaWtOEio2HdwbBOr0YZO0I6BQl4uSZUe+fHP avYRogI+oUE9l+qNqspONaR9je8f/NHkqPdsHsQX+xSof76HAwA3CSufEklN+PqDkAjr8J xZgRzlx/tcliitperxQggvfxzoEpl0A= 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.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=1706512200; a=rsa-sha256; cv=none; b=t0d7uSuYIEtbFaozbJz+3VJ7DcWuuJ5o0gRuDy5JQgR7qQZRK0QnUlyaX/sQ/orR1a6WAz swASC9Z9FG3wdnce+J8Hk+ymL2gkWN6ativPp2TEMxesE/r3yBuaQo9mcF3+3rAwdsLHad EYNBYwQcLSDs5BmaiF2f5gfBz+131zQ= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TNfY112ytz1xmk8; Mon, 29 Jan 2024 15:08:53 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id C3D1918002F; Mon, 29 Jan 2024 15:09:50 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 29 Jan 2024 15:09:50 +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 rfc 7/9] fs: hugetlbfs: support poison recover from hugetlbfs_migrate_folio() Date: Mon, 29 Jan 2024 15:09:32 +0800 Message-ID: <20240129070934.3717659-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> References: <20240129070934.3717659-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: 4561B10001A X-Rspam-User: X-Stat-Signature: d3ffe3xobzwgydjmua56hsoj1m43e5y6 X-Rspamd-Server: rspam01 X-HE-Tag: 1706512197-397312 X-HE-Meta: U2FsdGVkX1+R/CjfS8e0d/0ZQX6v+o9+Irok2VEPHo/pSU1/BSwTzPhaIz7m17fvtjedDJlSwIHT8VfJ8Zq8P+zwDXbc5BV0svmnZKzkf2jUNuXdOn33mhwypUqCQU78MpQ5Ija6W/oAhXT0zv7FNB+guPjZo8KtNqccoyZjAIlLtOuF8FfGAmVgdk4t8vGTtrMKF18tovXByF5IlBsDOXLHFdIXegx+BR7npSFmD1bRage/BCz7q+KkUReLcTIwbJDh41jNES8/YRYRShFmfM1UfDjhgnIUIIS1E5dB6t6SMqz3jwOQOw8tRWv1wJs4PdYMqyGgqJArxUEqSL0qInGXeWgUO9WuyISFKkpBcxOOpH5exb03B3PTg3fqee6CeQYLHgzNst7arDnBZXhn9JOvQnKS+G0MLsyqZZRFBC4jjmvyDt76veLgHP5P70cdtn+1/R8Mr4C9oZqfJ1uEgbNC+XbfqT3aI4+c0BfPuHsgMpRBaNFXlNxBkJ+xz2NXHx7kJD7UNJowtp1gfwBm7fqD2Ssw7u5rpq4Qsp7ZqKP43J+PfWt5dTDrvUb3nADmOOpSSyjpECvBFUkLEYU38/b1MFMhYcuNP9+N9Dv1IayhuxJHtyz2Cx3Q7vpS/BwbWc/WWuXt2a5JGqAVL1tNOCeUX5xEhYbsvROfE/gTY1ZvLRR2WpCp+7a8AlFMN749yOssCq2iIHhBaNSO7JlTNPGfFNuaIatzxsqIJoVdoZw/JGL1HVAYB+NYA2bLD750sW2AAWYgw64UovTFDm4rT7u2PuOKPVju6V9l9AFrQHwpByfFB7g66OD7PEvXtd3LAgmHElBVz0BjHoTEJsExpiD14nxo7e99iT7dP1ZfI/SmXkbp4zsVdwJBYe1dIHzIpJBU7Acr3uxLK+v8YNHT9ne8HU+Y+RqYWiDIvu9ekNik+DGh6DD+oHvZQu0/CuDRHKQ9AnhJKtGi1ma1S6d ViDVLRph WTJf9VFysVlVLFVI7aXHXSIiU4njjIawfpU9Spc56hskXta8Tp4oq9YwLofRKs8O2IUljaRkHVwhKMvik4w26UJiTRwqeEkWY8GItM+ROuXGZZtU1vb3lIwtTT2AAG6thfMWwU+1sZjti3Dvx8b3EgJ92AHO9Wzgy8I13Zn4gYBLkoXyWBTE8yLM475KDsS8FzHKCd4NbSrVOjJo= 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() to avoid panic when copy poisoned folio. Signed-off-by: Kefeng Wang --- fs/hugetlbfs/inode.c | 10 +++++++++- include/linux/migrate.h | 1 + mm/migrate.c | 3 +-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 52839ffdd9a1..3871968d1780 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1119,6 +1119,14 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping, { int rc; + /* Check whether src does not have extra refs before we do more work */ + if (folio_ref_count(src) != folio_expected_refs(mapping, src)) + return -EAGAIN; + + rc = folio_mc_copy(dst, src); + if (rc) + return rc; + rc = migrate_huge_page_move_mapping(mapping, dst, src); if (rc != MIGRATEPAGE_SUCCESS) return rc; @@ -1129,7 +1137,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/include/linux/migrate.h b/include/linux/migrate.h index 517f70b70620..ab387ea66365 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -79,6 +79,7 @@ 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); +int folio_expected_refs(struct address_space *mapping, struct folio *folio); #else diff --git a/mm/migrate.c b/mm/migrate.c index 99286394b5e5..097d67c82f8b 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -375,8 +375,7 @@ void pmd_migration_entry_wait(struct mm_struct *mm, pmd_t *pmd) } #endif -static int folio_expected_refs(struct address_space *mapping, - struct folio *folio) +int folio_expected_refs(struct address_space *mapping, struct folio *folio) { int refs = 1; if (!mapping) From patchwork Mon Jan 29 07:09: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: 13535068 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 EE8D2C47422 for ; Mon, 29 Jan 2024 07:10:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 842056B0096; Mon, 29 Jan 2024 02:10:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A4E66B009A; Mon, 29 Jan 2024 02:10:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 420BC6B0093; Mon, 29 Jan 2024 02:10:01 -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 A76A96B0099 for ; Mon, 29 Jan 2024 02:10:01 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7B3541A04D4 for ; Mon, 29 Jan 2024 07:10:01 +0000 (UTC) X-FDA: 81731474202.06.4E18188 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf26.hostedemail.com (Postfix) with ESMTP id 9339A140011; Mon, 29 Jan 2024 07:09:57 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.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=1706512199; 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=uxhEctjVQ/oSS3d4gV6S1haGxLGuZKcXXk3SyxRDJCE=; b=oDINf6Zy9dGRvYmbTn/ErJV2uCZAn8MzaVnXzqHoc9bIiW1QD3TLuKBJ6gMBAfibIoPhTk 6xhrgagy+DsP8Cvb3KDPTMoTdYupHX/Rt+8UBOvZXejxTkQNDiAoHCViuIBPSZeuvriNog GdCa8WRqM+kyY4YF/aDGpU+j4/SfUdk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706512199; a=rsa-sha256; cv=none; b=5BlujqTcWlFAfU/mvgHU8Ij1QO1CAAdUkksshJD1i4B03QOFjRRqle+xurrXNp/s+EHPfc 1KTlifQYHc+o6peHDQeo5/wimdqC545oHR6kYMTtNBm/9i98S6x5r+jgmKdaVzpPRPk4Rq lcePN1ohT6ikjI67zoPSMfi69Un1pfw= 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.255 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.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4TNfXp2JQ8z1Q8Z6; Mon, 29 Jan 2024 15:08:42 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 5C8D518005E; Mon, 29 Jan 2024 15:09:51 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 29 Jan 2024 15:09:50 +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 rfc 8/9] mm: migrate: remove folio_migrate_copy() Date: Mon, 29 Jan 2024 15:09:33 +0800 Message-ID: <20240129070934.3717659-9-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> References: <20240129070934.3717659-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: efkisns713xcwoqpeo6w3u8d9mgd6kuc X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 9339A140011 X-Rspam-User: X-HE-Tag: 1706512197-761700 X-HE-Meta: U2FsdGVkX19f6TQeJd5BEK3LDeOSMX4e/WPJMryPb+rH67XA5Od9SzEOR2duRw6FiFIpLzu9yBMv1FkKnz4SwHHwYtoh9Bqc6vYq9ZiWtOvtCgBt41baMD1lPp0u6ayrM4gRXsSDhMaoQ4chEskUA0c72RJD5+5IC9eNpgt+v8pbTcIM0vLnWxMRli3PM1vpAm85Q8cs/RX6YOi+odzepNgveg8Q+H/4UvlJDKfYUedD1TPUPIUsZOWdj6e6IL3ZIiXCURdPpvECyL5qKcEYE/1lAL2hdmKKt2klevaD/iasAVjCCohcniPTSC5deSJA3SRjN4njGC9k8flsRmB4ORlyifC2+mf734Zgv8NgraJKQhdzhognAIMX2AM3K6/YEDFbvep5dwtsO7UxIVyOjlmw5qxtUbfp5+Gh1RENM4HLsxakDo7UaDiyKs+MA4+AKsBCi8aqypKmk9k5fivNNc8Eg65tmwSsMcoiKRl8cPcFEkST/sPW4AjoiWA3MJjTXyEKNhqj/EZwyQZwDOQyyI1zqQCGFvXLO6JiMQrs+4fccu+NgM6oRf0Ep0+F0YfZFLOPECN0t2dJXmuPb66mAOtIkqvLht23E8MjnETOSOtFd73atmegME0s16myhLbihvCKOOJw8ZmRq2HefL0F1L7X4lnASl1sPyUa3weSpd+DWNRnCSJ60GNL9bLLfxyofQViAO/ZYPJuokLDk08O5D+hXBy2ecNGeygH0vp7Wqh+h6eXnrZ+kbJ9ci8PdSB/jPN/T+jdWysNQHtdPblGSLk3BKGmJSEjzWv4obLzeA4eZvO1aflQ3CGig7WmDWaOcbJQJ17KNa/iQLVwNCaABd0vfCGf7pB9O1rh4SwqW2pTdQRVhvv6oTSVrFM3W+RcM4Tq+g81ceb74SnZ5GLfCiFMP5DFKHigvQIoTE59Js35i08gFu+n3K6/XUQUMv2S/V4I0I7vbrJlOohQFRE oeuGtkbR IgGr/ZgBgj/nYqYJ2RRS85dOUKRDrjBE5vsQUv0uFq0Qf6nDAReaPOCz2FeYwaeAPtc1BbQCZ2DTw4mmijqpnvdPv6BxmZUbnnA7kTTB3xQk180MZCXRku1H9Hl3Rz9CjsUyaUmFVDtpf4ztHba/gCzJfVOUKZfCqVDWDVfqAAjrbcJKhbq26JOfKPJRLW4AnTiab 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 ab387ea66365..13fff8f7832b 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); int folio_expected_refs(struct address_space *mapping, struct folio *folio); diff --git a/mm/migrate.c b/mm/migrate.c index 097d67c82f8b..d5c1b1542335 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -643,13 +643,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 Mon Jan 29 07:09: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: 13535069 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 BB9F4C47422 for ; Mon, 29 Jan 2024 07:10:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5FEA46B009E; Mon, 29 Jan 2024 02:10:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 580426B009F; Mon, 29 Jan 2024 02:10:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29A656B009D; Mon, 29 Jan 2024 02:10:03 -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 D99C46B009D for ; Mon, 29 Jan 2024 02:10:02 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id AB7A480770 for ; Mon, 29 Jan 2024 07:10:02 +0000 (UTC) X-FDA: 81731474244.24.9845CF1 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf15.hostedemail.com (Postfix) with ESMTP id CC812A0011; Mon, 29 Jan 2024 07:09:58 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706512200; a=rsa-sha256; cv=none; b=I8GBz6INqpyIgXjrDG3+tZNL/URTRS9zOaSPAvyQggNMvvOVxNy8Of4MybXCXKVU40dGZK CXP77MUFbBh5puyHRUk1eSc+IXSJ/o7w3RtZi67KRGZ63ugV7Kre0StFQT0dgx/8CoNnHM rSU8BqwMIzl3RF27ePdFGQkY4ipMpl4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706512200; 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=T9l4uXaMIpiasxRBGjlvtFNrIlIizkyq4ptgkMIKZIg=; b=hlBD1ydt/aRILzaKBeDv29/Vmwj2aJauQVK9Qoe/2F71DveNgvOp7dI06vmoKC1I62nwF+ tMl6y7gEh2NJZI7Dhgxxib6s9ngF/4QBTkL0N9rZ2Jd5VodWa7T5Z3ZtwTpTKiBdom9Qg1 7RVkQfKqsJBHVdG+8/UE8HX+qCmCbK0= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4TNfY16qdFzNlmb; Mon, 29 Jan 2024 15:08:53 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 07984180079; Mon, 29 Jan 2024 15:09:52 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 29 Jan 2024 15:09:51 +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 rfc 9/9] fs: aio: add explicit check for large folio in aio_migrate_folio() Date: Mon, 29 Jan 2024 15:09:34 +0800 Message-ID: <20240129070934.3717659-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240129070934.3717659-1-wangkefeng.wang@huawei.com> References: <20240129070934.3717659-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: rspam06 X-Rspamd-Queue-Id: CC812A0011 X-Stat-Signature: p65w176pr9poy8apfa6d4cfxe5jgx9qz X-HE-Tag: 1706512198-709206 X-HE-Meta: U2FsdGVkX1/pezLuydLDpa25F1Zs1SHtOB0zxnRSapRE25Jw/zcE5GfU1Bt7ZH7ctsSXEsf7Yaocysaq4vGbm2YoiwbSrM2mIEHeyGLW+nLoA/SAQpy5kQ+Qc3Q4EBa18UbNMfPziE/KRrm8RvNiwQfH/N9hgahhboooC1x7SWA40RTvp2dy8JmtLpKzsrQ93koQeTLWbNI/B7pyRSLSmsiK6mBy60hSNFFG/9ESIoW/2tLOiC0cc3OHA5nwY1lZ1Boe63tSpIG5dT+WqUcoKb+FZjzE3BssLWfwHtFkNyqMQx5fv/MdSiZFKHCrNrBkPsTxyYfAnwdgRCTdizcQuGqiI2L9u5tUs3BbeM7sfimxRZ1Ho0Xnhr9RtsY48eB6XMP7uQHFJGl3xeHg/KFjB8QaR7p/YFV7IzFtWA9+7t67oUYgYV0N5oGaTH1cKgGAMUNiSjFmBnw+5PiivMynYoqAdFdny8qHZobMe1ls7rN9TT4Ag3n8icz8TRtO7yMmYnS3aJR5E72kTok8sA78U4tx2/PD/LOV5nyjnKn3m0OtvWRw1wPclYyI6VPXlGZkeoX17RiyE8f0u7gJ5l9OyIv/H1ZJ0TYEudRUBIpeg8Wn46kaIsvw2LQF26n29X0PLDBldYNfAMWFXIqqHnMlyyuRRptJOTjkb2S5E+/Mev/g56iu/nZMQam8v/6O6GpWyEcOSK+sdUED8/EcqG+cqg/I5hqK0jigBkOJqbICXkI5CpUDahFIJnAD7jQhtqDofoJ4UdXf2iQ0teAyDBKy1KPKzNswRx6/z4iyiuEgFjDwaMTQJcXFgiUGOjqYtJPhQm96BsQxBW89qpgXgjbXyqQjd/Hxjnf1p4AyYKcohgC2k0nLNP0Zjnz84AL8jTSosmmi3Vy3G+2b2yTlUvC1PdWLj2TAWoyYFTTsyN9bJNlsIHUflh3xPiFC626u/WhxohXUzm8+V+NCzQHXYHx Kn34KTKu K0r7zz9EsmNQu8PR1+mL1gZ6cTyR23ALAO0dM5WdsQGs61fFum03dGYhTn3PGyiZ9i+RrKHvKoGWIQPUI19dDbVyWfnfu07n3IBSAGdYXbxrK8ynn8XzwZ4ehQh2Ydq6Dhk/kaxSwiEuAp8C64i1qGCrmFIrGNFmKK9+EcGeYbtJ5kMQ1SjKNooYjExfg0n+qhJQc 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 folio 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;