From patchwork Fri Nov 3 14:01:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444562 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 CFA61C001B0 for ; Fri, 3 Nov 2023 14:03:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 372EE28001D; Fri, 3 Nov 2023 10:03:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D42028000F; Fri, 3 Nov 2023 10:03:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B2EA28001D; Fri, 3 Nov 2023 10:03:53 -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 EB06828000F for ; Fri, 3 Nov 2023 10:03:52 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C19E5120604 for ; Fri, 3 Nov 2023 14:03:52 +0000 (UTC) X-FDA: 81416811504.21.370CBE4 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf16.hostedemail.com (Postfix) with ESMTP id 2647718002B for ; Fri, 3 Nov 2023 14:03:49 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.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=1699020230; a=rsa-sha256; cv=none; b=wyPivp17AvRYAZ2CwHcolvZAUTDuC3vx0pR5Yk7gjiw3yS4MVW672icu7jePsU6Q6++QmJ n3JkEy/Gg2ywcLgE21toMHpd71akZAWN+2d4YAfC4bLkwICKgYc0n+ri75Knd4mZNeyUXB f+4ADGh3GG3KIZzmg7wVeShdEnTSKtk= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.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=1699020230; 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=5WjhsGz5/m2ldEiSjLl2Au0dbbriyQnQoS8lYbel4dmCH1Qn8w9l5zBRUYhykM7b79/GQY pp+QS95msJHUH7K1TZQHdA/TVZp2oZMA//ik6W19Bwwq47mNE5ICCYnWhkA2BmXCkVMIH8 VvnZ4Wy9Jmaw/fWWEOOOi6dtWbkwx6c= 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 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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 2647718002B X-Stat-Signature: ao1a6pxxxj587dk9uf1do6t175j43tip X-Rspam-User: X-HE-Tag: 1699020229-173344 X-HE-Meta: U2FsdGVkX1+d0sy5MtM754OYp+Sf0ZqN30eB0+bcZoazAv7IOjIX4xoDZpQtQrdQk0raZOkBG9S9N2Atc4mW3uD5C/+vdFRnxGb1qkuhW6ZtNdo6oIV3Y9QCYZIjWMjtTp30X7MswkyMjPD2hhw9dOCd65/+0GHZVjD7S2SjNpc5qS8JGwTopINJoZSkzUfr5yxpKh50QY380ZsTvCSMCMP1rP7C7VW9EaySrkXV5th0wq79be139g+Wxqng6BWCncmIdWMEhGXceGi+YxZTSV5aRTep1kLdXVBeBz2/Abh8uOTro6GDsvyOq9XluUCctv2sHnuX5Mg4FErS8j0Y7zhQfMiZ6qQZXhWiMLsSwXcWYl4a7I+H8o5bjx2vyweDFXChmdSfvb5ph7AfH2eb0nVYPXuQUqq2uNXB+KszVWHixJeBqVAYayH7nDXES43qzuXbRk3CSM7BdbFLhesMI6YaDDi8a5nNllnVruKCaJB5xE2S6G2Ikc9YI0XMMFUxj4x23+RgOHbJkC+jtuNWwkU8Sar/jLFjrWwwnr+IpOZA/+rw959K7F1Sm1GT14LqQd/UDgS18ZUy5/FRpkP9juEB/AN2xJ6d5tAJyZQUPybvOSuq+cfdY/Bv2xKr4TfCxpM6GspmQ39k9wG3WGL+I0wjVfuSB74MEOu1Qmh4N9uSmw2Mko7ITq0vsl/ucV3X6mEgdjjzYHGAj6iyFKYhBMywAvS6+3TzW6KKYh73KAMDNMWK19AQAcYkfLT/Rz/p5/mssWj0LLqC8Ak3KFCT+8x0gZi4+YairgT+QEKc3rxPxpFmj6v9mQ92MeHJivl9UlgGYQI/uGCSE+rFY7BQvfMf3G62s4tIEABlm0WDSt4lPiy73zveioty39kiHrYJD1rnkVpmZp+pvSNqX5lGlZ6dSAa0Q5Dzg63ssDXC+AMO+9qFU7VegpQ+dIRkYUbkmhOR7hV4JD9LWhi54Op yMqrYBD7 /k7Mw1k24Ea9obrS1S1OfFRWAEliGiGvaGbH5JpD5FjgdP0WYsDTforgzLx9v9s/D5Mwvc2nRf4VpF6SgANXbAusFxxIBA0hIJu3Ndfb00JnBDxMtVDqDaSmY69pqViCIGd+/V7X98jGuxFQOvUjmRMvZw8gwrkWOyXcYdUwIW2B3MyVhpNp+s9YfxPAXfrUwyJ8l 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