From patchwork Mon Nov 6 15:49:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13447140 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 4C4BCC4167B for ; Mon, 6 Nov 2023 15:50:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 490C98D0027; Mon, 6 Nov 2023 10:50:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 43EFB8D0028; Mon, 6 Nov 2023 10:50:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 133A28D0027; Mon, 6 Nov 2023 10:50:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id F1D6B8D0028 for ; Mon, 6 Nov 2023 10:50:10 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C12AAC06EF for ; Mon, 6 Nov 2023 15:50:10 +0000 (UTC) X-FDA: 81427965780.11.96AD08C Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf15.hostedemail.com (Postfix) with ESMTP id 1C653A0012 for ; Mon, 6 Nov 2023 15:50:07 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1699285809; 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=oZZ54VdEIlacFfuk1r0uZ44GYKJKe8HsZ6PDThbFMXE=; b=Yg3xIdvhsodRW2bxVR33LRd5pjQZM1em31FAyxhNCNSh2ZcuFKYRAoJ2oIbSaQAPdbuTIz 8s5F8VDhqXuds3TWqW4NwtJ9Xe1TYf0980zJYTzXK0DlB1zj4YatYrafDHQ2tYU1myYnAE pAD/9Q1/DyjEitWKks24L8nn8/4U52o= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699285809; a=rsa-sha256; cv=none; b=WFKhhxQhbRXaNeo1snU0CMrVsOKEsCwkG9PjLvZJ+py/9DkMR6Iq5c83fFthXspv4dy9s1 pFGa+zlB02FjuPHmdKJKGCm71tfy9ccT1YuiEOeqaZ5bapvQ0ZsB6LPAzRgG0CszvPKMyM 3MZBct5yFDllTFTuG2tgUVf4ycBK3g4= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SPG4s51RDzVlYW; Mon, 6 Nov 2023 23:49:49 +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.31; Mon, 6 Nov 2023 23:49:59 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 01/10] mm: swap: introduce pfn_swap_entry_to_folio() Date: Mon, 6 Nov 2023 23:49:41 +0800 Message-ID: <20231106154950.3399469-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231106154950.3399469-1-wangkefeng.wang@huawei.com> References: <20231106154950.3399469-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-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 1C653A0012 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: gzcrjcpcydp7zj7negaezqu35rhunss8 X-HE-Tag: 1699285807-234962 X-HE-Meta: U2FsdGVkX18wSqZ1qMj0eLiKNEwweP0/VDUj8XjF0VCEc10DRL0Fp5GxGQGgx3BoKm+nSSaPS+W9TVuuCbA19ZlxWc2zqAtpPQhgF+Hg0MpknVbAhqHBY4Ke20X0Mb+zKEsuv3wsLncMp+1T2nCJoffPB+ytxH9EoEZ6v7ghq1owF9y4nNE6CiqB91Y8/JCDCYBjnxZzahAflyO1WDCrPp7uul7U2eylwJqnqwhu2WtCfmyFqMOrPFgEXZY9PJn1scLD41SRJb0UQhP0FGpYo/aNnytPYLNXopi/Vxa5rtZMVHtw5WABOOanKI6YQ78bV87YPepnLfwbLoM0nKwsqfxx1EE2X0x2NtFqBHAYL2UdR84Ew9UeNEGA6/MLDM/CCrshDYsJFBTDMydvJiJguCki3rLh42yftbDRVWgq4ZLD0HZ5iyPffjMLemA94eh3LE9KNUu69SyJ6SyonW6GNUVHOSqUAxKk4kWJraHSywd28qTjE97VVWI8wudjTw2A74wFmtssWJ8hJvWJxuAIvg1LQtW3It4aPgao5725JJ3bAWXG4YA6pmOAAdTUzATAEUoJvmRlTUhZ2PhVHC4G89Z1Vx5bbThMsi/wTrYzulcJoXRXcZYCADbhqTD50DfFPsusbHtSs+FiEKE6kh3dtVWt4TVqDa2rpeIdhrR9d08ytAB0vb+yoD6i7HnM8Aedw4OHKqZMRM+SEXoG/CwHJhlLDNAH18YldXMQpqDtzHQ+iqWpt24yjwq/rpdMpJX63Oacmzj2pqNQofk2X/MJnQIRw+i+G3JnXnyrdWdxZkpbg1cACuosaiYOsbB7T0WOGz6WemvNfReN944zGm36OELiAkovDyBZR9KWL0E4pXqSxPIZtWUxdTlS7qRp9CIZZUf3FtCk62CKRxPzsKDMoGy+XKCD+E3hdutnCTDNrOUpITig9WqrRDop6TGUPzeJL3NCDaN6z7M+lr6+fuP DD4Z+ydI V7crvjlK4WXRWjeGEUXprpxLUopJ/xShywCzCZV2gRFe9K6r1oNoD86l62fbN31fbNvLfXJnHmuGyxq9TAXFm3Wou747Eo/a7Nm44Zm+Q3oLmLjGw7etRPd0dLIFXxLevzF9R3QlZ9ZWoRX5RNoYHByPwxxYXjdZBTjaTihIGXFZZVotVR9q+345oaYJodhdsDweI 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: Introduce a new pfn_swap_entry_to_folio(), it is similar to pfn_swap_entry_to_page(), but return a folio, which allow us to completely replace the struct page variables with struct folio variables. Signed-off-by: Kefeng Wang --- include/linux/swapops.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/swapops.h b/include/linux/swapops.h index bff1e8d97de0..85cb84e4be95 100644 --- a/include/linux/swapops.h +++ b/include/linux/swapops.h @@ -468,6 +468,19 @@ static inline struct page *pfn_swap_entry_to_page(swp_entry_t entry) return p; } +static inline struct folio *pfn_swap_entry_to_folio(swp_entry_t entry) +{ + struct folio *folio = pfn_folio(swp_offset_pfn(entry)); + + /* + * Any use of migration entries may only occur while the + * corresponding folio is locked + */ + BUG_ON(is_migration_entry(entry) && !folio_test_locked(folio)); + + return folio; +} + /* * A pfn swap entry is a special type of swap entry that always has a pfn stored * in the swap offset. They are used to represent unaddressable device memory