Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp896294rdf; Fri, 3 Nov 2023 20:56:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYgFVwSh6fvIwSHkQJ5kQft6p28QdMyS2we92YN/7nfey+cs+o0m3kOLB2TuDHgj73BSZq X-Received: by 2002:a25:37c4:0:b0:d81:504f:f879 with SMTP id e187-20020a2537c4000000b00d81504ff879mr11156142yba.28.1699070174635; Fri, 03 Nov 2023 20:56:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699070174; cv=none; d=google.com; s=arc-20160816; b=Cg6yZVGMerL0jzXilgiMckdbjEiKZ1lkk16u3afEIdX8mz06Mb2ArSf6GyGq9kAexz +wpevXgKeKHLbl1aZXphFMOl00DB64IW5emGqnXhaG1Y/umU7R16udU6vT1rumy7Yeh+ F++7TMwp4rKxAEqEpf925bOxvtjOKsT02dgnP1IIVDLfOLGFe4Cno7nUpjvt/mcowWp1 NOHt5a9/h74kK4tCwRZz/tyNx0hfyuXnzeY89aW3lzoR4przeqvdVNQRq6jssv4gzDOL IbRmcrHBYUzmHK/K4Z3N33SEbQcsIbU18ztvul8T33r7hymjJ6rwzqr7G2bYEkj4UDAH eNaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=oZZ54VdEIlacFfuk1r0uZ44GYKJKe8HsZ6PDThbFMXE=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=cK40bRaP6KcLeSrs/v//+kEwGAo36TUlJ51AoNsfHaTDQZLSqQBp/TCHgvYvCiXhQ4 vf68Hx/jrfObYwwefXwxNkp2t6sGYUet4dr9TbtHnA/Y/KG9jTFxVXkh+A2/mDCbAYgX Y0pKiTZas1U+XsEfdg7O0Aj3P9G4dQwpJ7xvtCoqtuBzgbp8cCeeta800jgkx2ZH5F4M 2HNmEe+3CEnOTOCvZaen6VC0f/5+xb81Jo6u94xMx3XvPtITU7sl38xfQjJGNOS2ZWnD TLqY3Kc0Qf6OVhYwoapnNWRQYmbw6BCrKcOdPuzPOpO0dMGP5vK4qiSJxviZ8NIZtXgq K1cg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id i9-20020a17090332c900b001ca335f71bbsi3072530plr.140.2023.11.03.20.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 20:56:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id AA84583352B8; Fri, 3 Nov 2023 20:56:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346210AbjKDD4A (ORCPT + 99 others); Fri, 3 Nov 2023 23:56:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234316AbjKDDzs (ORCPT ); Fri, 3 Nov 2023 23:55:48 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B5141AA; Fri, 3 Nov 2023 20:55:44 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SMkKh6BgFzvQ5W; Sat, 4 Nov 2023 11:55:36 +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; Sat, 4 Nov 2023 11:55:40 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH v2 01/10] mm: swap: introduce pfn_swap_entry_to_folio() Date: Sat, 4 Nov 2023 11:55:13 +0800 Message-ID: <20231104035522.2418660-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> References: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 03 Nov 2023 20:56:10 -0700 (PDT) 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 -- 2.27.0