From patchwork Fri May 24 05:28:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13672722 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 700F1C25B7A for ; Fri, 24 May 2024 05:29:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0593E6B0093; Fri, 24 May 2024 01:29:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 009036B0095; Fri, 24 May 2024 01:29:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E39C76B0096; Fri, 24 May 2024 01:29:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C72B26B0093 for ; Fri, 24 May 2024 01:29:37 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 473DC1A0897 for ; Fri, 24 May 2024 05:29:37 +0000 (UTC) X-FDA: 82152161994.29.73B6E0E Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf10.hostedemail.com (Postfix) with ESMTP id 8C57DC0004; Fri, 24 May 2024 05:29:34 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716528575; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EXbpickgsmubOLau9igLhNAjj/mdYTEFDnBj3Q/gvE8=; b=dqkwLxQt44RlJw8UsaZPbExEhLFl7XPUKoBMbRxmqgO7oZkYmofaHHzkzXiMQueRdBaYwV 10aCfXPusMeRWTc7SPLwe+VKtEehYbuXWuoJ6qYrM5uYR7f5i8s/c+cwyzgWgd95KQ9I/w QHQNIj0RNmtDvAH5Mv8VGLDfh1RaVXw= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716528575; a=rsa-sha256; cv=none; b=VfB3kw0NTcn8YM2TkVyFehW1Stvfp48bk8WrFm5Lbik6CBTC1jDK9xn57jNVXPbBDjPnYl XKAAnVYzB9/DEgar2XcbjFklo8KSgMtOuRMHDJey5UPHoKngeXe6wCZThyYUprh0rTvSe0 5McoeSxRWmmSKko5vZkIcnZJcibFcFw= Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4VltnH12HbzPmcq; Fri, 24 May 2024 13:26:27 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 2B9561800CB; Fri, 24 May 2024 13:29:16 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 24 May 2024 13:29:15 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Kefeng Wang Subject: [PATCH 3/5] mm: migrate_device: unify migrate folio for MIGRATE_SYNC_NO_COPY Date: Fri, 24 May 2024 13:28:41 +0800 Message-ID: <20240524052843.182275-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240524052843.182275-1-wangkefeng.wang@huawei.com> References: <20240524052843.182275-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 8C57DC0004 X-Stat-Signature: 84a7q7hzgzn5z8hb9fied5cdue1ra3rx X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1716528574-381248 X-HE-Meta: U2FsdGVkX1/YESsVdOdqewO7ZAOULskszspYjMfcXlb0AKAj9XjqptPK4rpqoTUH9LXu+grrh70nykrQMsC1RKtJ+9tWwAj40eI/k74wp5SzuJcZHTmLdiop8XtIPmzEG6wpdBCfaKE92jxjJlBWdhuAMPBITC7QC+HUkjDBEGW4vM5EDP+8hLld95YwCs6IlzfdxDv4N1OS60nbGDLWghtx3mj2Mwb0M+wLxN0l/bMzqbF0e8HSkTDcy8SD+eitClH8bZ06pnVWkEvxNR6bqN+iDR3qrV23dxlGWgEk44r0Mog4tf4pBVOgpga/QC4HGHvOg7tDgNJEBTIfGw6qnQGFv6kSKbU61Kv/qw6rwRchiv8wps/g1/VSsClOE14zj27ejj74sKDaRLTxapc+t7k4cq2xnAl6dwYja5RmP2HGOfNfwTrsGGbufnjl7d8Lr01uRLnjrDK7i2f72RAV/kAsfl3GgU59Cn0bRtLiPOxqY9O+nTOzv1mIQXI939biskpg1VxiO0P2vJhf2iB4c/NkAz4/bnrStl3E/0Mhl4CBl5+3ojxJA2WZwU1MjaKzddoDetDyg2iJLrYAJGqM3iYAzxYcnf3dwZ3Lu52P6tCA4Dpfx9XDIJB7ir5W/udMzx//PE/lJgKpJDPO5IUy1F7O+5YVschdGAtZkPYqgTVPYOM6n+29XDIrMrEnVdnTEh6nu8omeF7vqgGfYQq+oJnDSz8Xp9bbiuopg/HmqXMA1ScnmRY0hC3DlkPpuueUkwzleGPrFQuJCIlsS/hRwDi+Ioy9w8EywohMyVO+9Ap6bebOX10vbbtPl88xWtO+nWjTj7Tz4YQDd20q32PpoS97T1lvpKDknvmL2X/H5ViTdEO7vuiagz5BcCsRzitVpsjgoEHtPsHWQKa3qX5eyTKT/K54CQp7e1aptr8BJisvp399VCx0bVR7dIOrMF4Y7xx7GdqeP1dut/8yZKn eD4KQbzp U9eVZ9WgTprjuntPDajq4dmxoL545Imqp1RlHGgwQUdxyKEpMHoiFmNVm61FPBhNU9M/iTWTHumBKAQy5QTb+4j5d0JwqgPWQibeU2uotn07VIpJyW+yzCkrjJZGE6Y8hsnKvuXBKM5Tt9ydnJ6c27JVO6ASnS3O/ktiCbg7D+3Rn717/Zp9KnPxoF8R2JHhZbr7QZod5EagLZKIlm9OK4aPmWmS9+2o7AH5ZlFnhhR5eGvFjgkwEPWEmqUS1a28/a6AxYDkEh3g8d0g= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The __migrate_device_pages() won't copy page so MIGRATE_SYNC_NO_COPY passed into migrate_folio()/migrate_folio_extra(), actually a easy way is just to call folio_migrate_mapping()/folio_migrate_flags(), converting it to unify and simplify the migrate device pages, which also remove the only call for MIGRATE_SYNC_NO_COPY. Signed-off-by: Kefeng Wang Reviewed-by:  Jane Chu --- mm/migrate_device.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index f5e034de718a..051d0a3ccbee 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -693,7 +693,7 @@ static void __migrate_device_pages(unsigned long *src_pfns, struct page *page = migrate_pfn_to_page(src_pfns[i]); struct address_space *mapping; struct folio *newfolio, *folio; - int r; + int r, extra_cnt = 0; if (!newpage) { src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; @@ -754,14 +754,15 @@ static void __migrate_device_pages(unsigned long *src_pfns, continue; } + BUG_ON(folio_test_writeback(folio)); + if (migrate && migrate->fault_page == page) - r = migrate_folio_extra(mapping, newfolio, folio, - MIGRATE_SYNC_NO_COPY, 1); - else - r = migrate_folio(mapping, newfolio, folio, - MIGRATE_SYNC_NO_COPY); + extra_cnt = 1; + r = folio_migrate_mapping(mapping, newfolio, folio, extra_cnt); if (r != MIGRATEPAGE_SUCCESS) src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; + else + folio_migrate_flags(newfolio, folio); } if (notified)