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)