From patchwork Sat Nov 4 03:55:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13445389 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 3D932C001DD for ; Sat, 4 Nov 2023 03:56:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F15B8D00D6; Fri, 3 Nov 2023 23:56:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 079078D00D5; Fri, 3 Nov 2023 23:56:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5C0D8D00D6; Fri, 3 Nov 2023 23:56:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id DA0F88D00D5 for ; Fri, 3 Nov 2023 23:56:01 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B1F7A1A0DE2 for ; Sat, 4 Nov 2023 03:56:01 +0000 (UTC) X-FDA: 81418908522.29.F7D4726 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf02.hostedemail.com (Postfix) with ESMTP id 913C38000B for ; Sat, 4 Nov 2023 03:55:59 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1699070160; 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=hK/9cnJAwLWz5P32Ft+2SjDo0/U2QTdQHkd3VXWZ7loivxEpUuDo/13Yd9AmbsFyYxBB95 NTH1XKAWeoaaL1YRADwduPem/7KPwCZFJidBEnHX/oO8AwBn627M6oM91nsiAFyGXQlNMR p8mKn974LPjdbVBIXaymqDRg2VojV2E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699070160; a=rsa-sha256; cv=none; b=uN7bLfbSjO+OGc1rXM4mnBVWpGcDC1Q/vtfsf0Zcu+hVJ8Aplk+SWz2FlCqqdKAe8eeruE OOzc0Yuytu0KltTvS9S4SBE3o15o0OAyQ3MhzQU1oKghTFft9TOSRDfSZ/PHlCJPzaPRLm rJoPggbvWywGOZpwaIJfNu7vwR9ZmWQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com 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 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-Rspamd-Queue-Id: 913C38000B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: bwg8qta1aw7u89yeiu18hxxx1gyoo3b8 X-HE-Tag: 1699070159-11553 X-HE-Meta: U2FsdGVkX19NZ/LbWJwtIWUWPyduITdmwtifDRJKz8s/e1bm4Q7zQqt62TKkV9ZqWXAB47RHp/uaU3nNJgCjDncPl2RLspWJEyWlja69yP3ouZ8536miw7dE3jSwhL2iRNAVAaAi7v8BbCP51kWKr1qEOKusayIoTSYN66p89Df//ynx+7XSm75BB841WHPddJuozjGXGr9Fz4C5c/RLAuNmwYxn1kdmzvxv8s0z/7as/BFM8YtZAhAdLejZPEmtdKv573Cb3/O+6uNVITis82pvJpyNnLW4TPrh6I5DCARk+mAVYRukjMdVHXXKJ8iH80IFpXpxm7OhjhTsLhXeI98t1/NX6BBefgeSexgLWEr3Iz/RyPpLCso9ikDV6ztvUhM+aQXR8/q8gK/OZg2JhHrMPS/N5geLMlLjB+d2N58wUaOzlk9/mlp+8ZdcsOf/Hc5Lgr+hHyxNrI0ZYEFAeeCJpMG2WwM6N1P5JAGtv8WSnyN+vCQtVs2CGWVwf0CjeF3l1yb+H3pmPdxqGgKww7XFBJljhBbqZxJ8UhDAGkxV5SyYrGp5i/nMN922T4xSi5W86ppTNpKS++TaieYnChZ1JEQB4JvhfwCxVlT2r8Sw8LLFccrPmVjpQ0Wpbs6GbJuqQJXnjHaBdXousNcAnu1tEUXseVPi8Z5A2Shpi97L8ZmspWPNBt5/VjyBvyF5DUi4dDa2rsuBe3AErr6/DbD4sWm/JMdQNH6tNwRG41XiMNpE1ffehbH7d7YTPdIPfNwrz9Hx9I5Ipn6gFG1bKbA2gqkOfxIdLpL/zKzEH71SY6crvZVLk9o+P6+cNaMUWg04NLulFnxVN3d1q3MNZr83EAfEp3o07j2+Y5TPDM48KFWhIWdZIoAphEMEfPD5aRc4qA88IZna1hoiRInMdKdB7ldVnKH1Xurok4NKDkpmZ27P6y+TBqcSELWHdc6HFtkJRC6IruwNTd69KEd poPEw718 I+9N8ti3rf7YRzJX9ufkRG26N5R3jzHVg+Zeb7301XBancRUeVF1ltF1LKeaHIx2GrnrkxI/gowLV8rVTGNBEi391fCUrekwHG206UJfQkM3JS5LPkwZMTekB94RIJaMwXBbCVo+5zPfCPuVvtK48KTEcU/zcRegArj0KmTM1OvYu/4RcqghIn3Xu4/QBtiIeDryw 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