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: 162057 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2750024vqu; Mon, 6 Nov 2023 07:51:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbJJOmc10+aNqynnWEjdMTCFCcUIcz/wrZlwde778mteAz/U0b3eKfz6K7/lXT4arPdEZF X-Received: by 2002:a05:6a21:32a8:b0:180:f8c2:6363 with SMTP id yt40-20020a056a2132a800b00180f8c26363mr17531195pzb.55.1699285866003; Mon, 06 Nov 2023 07:51:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699285865; cv=none; d=google.com; s=arc-20160816; b=CHOrY38VhAUt3I8BSrLSn5S0QVGN+bdBFVPQNMwpf1OnVdpo5mk34pzstWlCVkWL3m s/HISvXP/1zyz9XXJprFYdYLVfnrRmutoALGp/MOw+94IAoG5kX6quRb44kYQ60d4uWT unxeaLYAyVnaJFmpot0VA2ycFNmOq+VNBNxaGBgQ2of+wcjiWdXkP9IGMHTkshgRy3jC Ru3PznqFReRVFRCMMc7xFZKJ1epujfW5x89zBed1foOCvLKgBoz4mfSn1zSIt4Xhx6W4 o1KK0uqEPLAZWEB6meXS2CuFE7Jc8jK7gG1AXuPxp7/ltBOhlb9LTIwQvecmwer9vpTB yV1w== 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=ojgvQrMvyJiLtX6+ndxHYSTNudvPlLkff1roVAwMTdRX9S/BWtuPkkL+zqfYYNrvds gp+ZqMQEZYCWpkh7AbLSvrtrFijoI/Oxd9ywT9Ghuqrn/dimsbktDF3+2ALDpAAnlTzO 4fLj97iVrMbgvZa3ftG6bIVMrOHPH4U6EDDiiJA/diMxmtaIB3Bm6+bheq8b/t9U08Lw UOSLQDE2rnxhutQsOwvolpJp3GWQ2Dt17+1cfv+DNDHoy1OQ16S5z19k/9uiNAOb4oF4 D9zDk4I84CXZfGCQuIoKzBSwDKWLcQIOuWfPMVDYS5EEiOaKJEYJpMLWuNwYnaoLHQT7 78lg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id h29-20020a63121d000000b005b8f0c8ddbasi7650833pgl.243.2023.11.06.07.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 07:51:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id AD896804A4FD; Mon, 6 Nov 2023 07:50:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232619AbjKFPuL (ORCPT + 35 others); Mon, 6 Nov 2023 10:50:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232331AbjKFPuE (ORCPT ); Mon, 6 Nov 2023 10:50:04 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50F7AD42; Mon, 6 Nov 2023 07:50:01 -0800 (PST) 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-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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 06 Nov 2023 07:50:43 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781830376632354559 X-GMAIL-MSGID: 1781830376632354559 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