Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp503398rdf; Fri, 3 Nov 2023 07:04:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYTbUit2CZpTdSQjS2oBvh7qjCduA5YN6VT82ZbJfPJr/OtJDcpR4Pi/aKtuTkfBe0ZKb4 X-Received: by 2002:a17:90b:4a50:b0:26d:17da:5e9f with SMTP id lb16-20020a17090b4a5000b0026d17da5e9fmr5084249pjb.1.1699020284817; Fri, 03 Nov 2023 07:04:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020284; cv=none; d=google.com; s=arc-20160816; b=frzFTgLm/+KbFxdva5WT5hjfBh0oM0u14VX+jpRg0X6++MwuJbwVKn8ySV/elNRUAo b4fDDxOoWeh3EHD1IL4seBGZVqnMqzL4RTbxlezARP+Bb+iQkCgutQaytEvsxOdqfgwS K/V8PfGLIfNNrRs0VbXIFbFyqDvt159yY77NURuw60l3ISyiPLeRyHY1ou5uHjkUcdaa wtwySkB3LZ9eidF5CBEw3sbeDwEHUjDBq0/uf7QGZvuhNKIBKGMq3oaTTkKdjE6YzOIT VGgFX5rZvAEKosjs8fw8cn1Xpb3fkhX9RDZapaeuaxaqHP62javZ+lD5egpNTvDHPIjj VtUA== 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=DBRX7AmN0RKxuukUjwrXlV3Xejtcf5g3P6kKHiFZk82fd3xMG35OQMHFW739wtj3cV J/afg0BHSXYMNCR45/p9Wm9X7FTNwrnVjiwI8FrIE9945MX1taKG9+BubJ6UmAXL618k GrpbMozQSJ9ycccpwm+XWJw0Nn84d4QfJhHLhFw3kTpeZaUVlLnAkdN15HDVwgmH+2iC Xpg3PjVpjBE1vI16qFEGGdqT3LR6JL+zRs2ylUZVjTJ3CwiPc1ztP42ifTgG9618qfRr d8VKHaV2tYpKSrEJ3+WBeqJ+R0wOu9vC+fgIpD0AeYZKU9RAz18VibowoiKXJaXWZoFl uvPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id u2-20020a17090341c200b001cc4efcc852si1645448ple.427.2023.11.03.07.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:04:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id E1799829C990; Fri, 3 Nov 2023 07:04:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377803AbjKCOEC (ORCPT + 99 others); Fri, 3 Nov 2023 10:04:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377762AbjKCODu (ORCPT ); Fri, 3 Nov 2023 10:03:50 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3251AD59; Fri, 3 Nov 2023 07:03:47 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SMMsm0SKlzVkhg; Fri, 3 Nov 2023 22:03:40 +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; Fri, 3 Nov 2023 22:03:44 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 05/18] mm: swap: introduce pfn_swap_entry_to_folio() Date: Fri, 3 Nov 2023 22:01:06 +0800 Message-ID: <20231103140119.2306578-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-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: dggems706-chm.china.huawei.com (10.3.19.183) 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:04:35 -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