From patchwork Tue Feb 6 11:21:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13547058 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A997AC48297 for ; Tue, 6 Feb 2024 11:22:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 512266B008A; Tue, 6 Feb 2024 06:21:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 494C16B0081; Tue, 6 Feb 2024 06:21:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E33416B0087; Tue, 6 Feb 2024 06:21:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 86A4E6B0087 for ; Tue, 6 Feb 2024 06:21:52 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 38744160A37 for ; Tue, 6 Feb 2024 11:21:52 +0000 (UTC) X-FDA: 81761139264.17.A15C56A Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf29.hostedemail.com (Postfix) with ESMTP id BC5DC120002; Tue, 6 Feb 2024 11:21:48 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707218510; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2EyZhrfCI3hGk2K2PCHohFB6BH2Ll2i1D3+3PdNdYcQ=; b=FPNsA0uf3HCt5Gk4EL4NqDJiLupMMYC08xmtChGodDv0Wl7pUIWOb8k5Vpzo2A4EuZBDZ1 ksS0qA7sxF55Pi5vyoWI2cx4JZlfFpI2SvkRF+OccaPzjCpx+2RtysAWcvJvYFfgluhnoc fX+DyTc1e6DmKjkM9x80qqh7JfzmwX0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707218510; a=rsa-sha256; cv=none; b=1XME0qV23eh8FrQCcu7vQr3Sf+YZOe29qoCczse39DrD3NdVMAPT+FsV+slbctx9gTqtr1 M7SE859IylbGBnfPU5XR+XPSEfBbZcwpcz/t6mF4XSrX9z8tmgU6k9h73OheyJeV+vSRU0 i932oJn2WXUlmbEBubAlrioGSElVhAY= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4TTgks0LBbz1Q8qq; Tue, 6 Feb 2024 19:19:49 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 2334D140412; Tue, 6 Feb 2024 19:21:45 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 6 Feb 2024 19:21:44 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Kefeng Wang Subject: [PATCH rfcv2 04/11] mm: migrate: remove migrate_folio_extra() Date: Tue, 6 Feb 2024 19:21:27 +0800 Message-ID: <20240206112134.1479464-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> References: <20240206112134.1479464-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: BC5DC120002 X-Stat-Signature: jas8c4ine63gsc6qytpf3g7d177nf15w X-Rspam-User: X-HE-Tag: 1707218508-262033 X-HE-Meta: U2FsdGVkX196k0vU6i4Dhts6sgi4IMrR8g9TyPlwaA1Jo65yjo3PFac2XLjlgs7tJcULdbDbBkWT8Go1XIF9SUrzbrAVsASwYyGuTqyx2K/dnLCpiKemAzDbduRoINr1Tvx+IEzMWWMXNe3Nkc3pak3xAY5sPUfQfxwqLbfDCFZQkCS7so4emFGTaZGeg6zzotTAmUbGL73xfFIbFyRKM71f0t0IlkyHB+fEgf4ibebfffsB4e2zChl9DPhIx3xPci4Jl7OmjMpCxA7okFwJ8fOl9qk1rklIwe4Jevjn9mAL5o/Gog0ladg7MpSz1q41LiM1j6bWMcL4jdBqCsa2LJj0WWQJpsZkNd+yHQs1WV/AdigR9X0vMkXgDrlcaFxDN9FA6HAZaP8THUqbcum0Oc8znQ4y4Jg32S9X7uO6avGe8iV9Du6+ZhGUOrxCUXXDDzhVu442+7dafqCJuykq1rWFKziGzvAPjP1zGTBs9GNrDLyTERC1TL+2EE4e+l7SSTu92zFv5yobiRo9wHOvpf+WYZZiNj5tPiEMEyTWMkqYF5J4OEG8ed9uYSx261Paw8W7YZTQtgYOdhseU48GF/MZnEejnkJrbs/7ZLNeIzVcFp+ycwjgzetECcdEzoMxPIDq+hZBSxdQQb78sJuCHCfnY36Vr74ZCuGNHno2wR92xU832e5Km6xo9rp+6bvDpT2nSrYCThURjQO+1+72dkaKn1xyMHh4v01KCUdaAJPM4ozh2LBN7Md1OxnVos0QGHlGsZMt4NqNZHI3jvQzRXC9mZkW6/3CfKH4PkXB8L653OWZIRY/Rs/2UA5tjZ1+TNK0zJl+GeiLQakOItS/9DDJvJRAtKlkRhWmbP0cmOl5oBs3P70RGKD0ULLXVZ0Vy2j9Iojcj4M= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The migrate_folio_extra() only called in migrate.c now, convert it a static function and take a new src_private argument which could be shared by migrate_folio() and filemap_migrate_folio() to simplify code a bit. Signed-off-by: Kefeng Wang --- include/linux/migrate.h | 2 -- mm/migrate.c | 33 +++++++++++---------------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 2ce13e8a309b..517f70b70620 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -63,8 +63,6 @@ extern const char *migrate_reason_names[MR_TYPES]; #ifdef CONFIG_MIGRATION void putback_movable_pages(struct list_head *l); -int migrate_folio_extra(struct address_space *mapping, struct folio *dst, - struct folio *src, enum migrate_mode mode, int extra_count); int migrate_folio(struct address_space *mapping, struct folio *dst, struct folio *src, enum migrate_mode mode); int migrate_pages(struct list_head *l, new_folio_t new, free_folio_t free, diff --git a/mm/migrate.c b/mm/migrate.c index cdae25b7105f..461badf26eb2 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -655,18 +655,19 @@ EXPORT_SYMBOL(folio_migrate_copy); * Migration functions ***********************************************************/ -int migrate_folio_extra(struct address_space *mapping, struct folio *dst, - struct folio *src, enum migrate_mode mode, int extra_count) +static int __migrate_folio(struct address_space *mapping, struct folio *dst, + struct folio *src, void *src_private, + enum migrate_mode mode) { int rc; - BUG_ON(folio_test_writeback(src)); /* Writeback must be complete */ - - rc = folio_migrate_mapping(mapping, dst, src, extra_count); - + rc = folio_migrate_mapping(mapping, dst, src, 0); if (rc != MIGRATEPAGE_SUCCESS) return rc; + if (src_private) + folio_attach_private(dst, folio_detach_private(src)); + if (mode != MIGRATE_SYNC_NO_COPY) folio_migrate_copy(dst, src); else @@ -687,9 +688,10 @@ int migrate_folio_extra(struct address_space *mapping, struct folio *dst, * Folios are locked upon entry and exit. */ int migrate_folio(struct address_space *mapping, struct folio *dst, - struct folio *src, enum migrate_mode mode) + struct folio *src, enum migrate_mode mode) { - return migrate_folio_extra(mapping, dst, src, mode, 0); + BUG_ON(folio_test_writeback(src)); /* Writeback must be complete */ + return __migrate_folio(mapping, dst, src, NULL, mode); } EXPORT_SYMBOL(migrate_folio); @@ -843,20 +845,7 @@ EXPORT_SYMBOL_GPL(buffer_migrate_folio_norefs); int filemap_migrate_folio(struct address_space *mapping, struct folio *dst, struct folio *src, enum migrate_mode mode) { - int ret; - - ret = folio_migrate_mapping(mapping, dst, src, 0); - if (ret != MIGRATEPAGE_SUCCESS) - return ret; - - if (folio_get_private(src)) - folio_attach_private(dst, folio_detach_private(src)); - - if (mode != MIGRATE_SYNC_NO_COPY) - folio_migrate_copy(dst, src); - else - folio_migrate_flags(dst, src); - return MIGRATEPAGE_SUCCESS; + return __migrate_folio(mapping, dst, src, folio_get_private(src), mode); } EXPORT_SYMBOL_GPL(filemap_migrate_folio);