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)