From patchwork Thu Mar 21 03:27:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13598367 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 67ED7C54E68 for ; Thu, 21 Mar 2024 03:29:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 860076B0095; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 771436B00A4; Wed, 20 Mar 2024 23:28:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DB266B009B; Wed, 20 Mar 2024 23:28:59 -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 DFF596B009B for ; Wed, 20 Mar 2024 23:28:58 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BB3BD40B6A for ; Thu, 21 Mar 2024 03:28:58 +0000 (UTC) X-FDA: 81919614756.11.272DBF7 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf05.hostedemail.com (Postfix) with ESMTP id 4F0BC10000E; Thu, 21 Mar 2024 03:28:54 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.35 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=1710991736; 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=eDwDBqvuaLo0V3vwemwkd+OPbJ2RUKNKCE3IPdII2D8=; b=o82ET5GlNq6njvZjHSvJiEb44Lj7/soRJFthpkTtIBD+IoB63y3vMHviPuO24UxRuY0dyf ABMgDcM4f8VkDifaYg7eBHQjFrGAfaapDyvW73T5DB1T7B0GkGKX1z69S3A36D5ZmxXJ38 MrHXNwV1zgdxnL8A5uDK/TbfZ/gpPBE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.35 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=1710991736; a=rsa-sha256; cv=none; b=Pwu7L/ztWI0pnHF+OXcxbNdBRVS/B6mVT/hA7FdwxyCbVRmpxwC70Adj4Q6bmIA7hFu1i0 8oCzCqpsL208dP1XZzwPE75cnahKrP5LfPSieX2+d8E2KA/QWAPDZ4OcEPtchgr8CRevsM WjxtmrtjIrocMBZCK+ozzXGhrYqjAoo= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4V0W890Dv0z1R7C0; Thu, 21 Mar 2024 11:26:17 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 63E381A0172; Thu, 21 Mar 2024 11:28: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_256_GCM_SHA384) id 15.1.2507.35; Thu, 21 Mar 2024 11:28:50 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Naoya Horiguchi , Miaohe Lin , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Kefeng Wang Subject: [PATCH v1 05/11] mm: remove MIGRATE_SYNC_NO_COPY mode Date: Thu, 21 Mar 2024 11:27:41 +0800 Message-ID: <20240321032747.87694-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240321032747.87694-1-wangkefeng.wang@huawei.com> References: <20240321032747.87694-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 4F0BC10000E X-Rspam-User: X-Stat-Signature: d1s9tmw7e8fz4q16w8ecxaaigtkzamx9 X-Rspamd-Server: rspam01 X-HE-Tag: 1710991734-19917 X-HE-Meta: U2FsdGVkX19QyCN3YQd+u25fxHrhcG0waYmwRdqrhQEeZPsuV9N22Tmha4q7uy+HIfAC0cUm8LIBGFx5jbvDU2nL9cpRtpthMsdkgS0ObOVC/aeq9SeSuSjtnqYVKjFTzdlvtL6kgHwrsGXcg6Uljr5DTQPN61VUK4/fCIFVTF2MzwHOgPhZtVeXyXWAicxOKrPgGCpqsTJwH7Hzge5QF7WNIdRPXLkGR+oGB9gwBF1psIBnfWLljU0Ihs4JprOgUa2BYLYzItv1qTZRJCzMvtw/Gs6rR5WjS+EFUd6G/LnD3BgmPHfNfHvzSE6pa2/3f80n46JmfV3NR5vnlyF3OMgLZE/1XG+2SUOuQ0Sc39bCNPrRnchGcgpsBri+sBvtqSJ3QDVk4xWxce7843UYcBK5cfggIzTUDx7zDIG7I0sFfX52IQsKQl0HDMShNu+9Ywy9xsXQHu9wD64iOgZWwf9iwFU58Bszva0UbkvSEnrsVou2mfcL9NJNjaxSWEJYjTWsdDeXeTiNEgUtl3Ry0IchS7Q+2Q/Avv42aKVpyjyu98L3LnfSjPB58Kg4fk17OTAQD0HfdrhNusjsZ51CNWteTvlfzx5BDwzkhykvKR9jo2vP3xc5fwPQgJCHgdqnj+5pK6evYO31or0PHuw5Uec+1QNC/Z2EUCUU5FVGrWRMeLUsjz34zKtdUO4YKQwNmEsNirQNeWSm5O79LoZtcHj7u5mF+MoSRClpBX7Bk5xeYQMytmF+XniqDZ61ewhsfKOM0NTDlNNi1eDsbg1X/9GgjdBtbJlARy+zbqVIGWUyv0qpJ7T5J+Z9gik6wA9xyrlexmu3UEW/nENNoLeLvbtRdCUdnkM7zilH+581HhNW1hnXE3P7J59i+zPg7yJXNv9AzfUuZ3NDIyNgi2MOX8cWTvKH+ygT3n+mkeCFzOHisLA0p+FhDSrgozBivKS0q0VgTGZYWWZhUQ+wF/W UcMJdzXU Fo7nFWrCVQGOxZEN6Pkt9xjPNz+fXY2rA7RURPEiVQhnrvkYlqHe7TI6pl+8yRUsjeEVIgB1iIb9N2ZGj5n19mj1wLU6IOzE0hQLVzmdeSyvxDQnu2FZgav47ttU0O8pTdSkTWypnDmXZm+GcbqYwULhGbAzZGv8G7XoDLDBlmoRjf/2emYwR6VPPlUWPKxA6FW+w 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 9cdaa2faa536..e36849a38f13 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 6502c7e776d1..d0c496af8d43 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1131,10 +1131,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 c006b0b44013..669c6c2a1868 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -671,10 +671,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; } @@ -903,7 +900,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; @@ -1161,7 +1157,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; @@ -1372,7 +1367,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 7d7cb3eaabe0..4467cdb1f565 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1752,14 +1752,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 */