From patchwork Mon Aug 7 23:04:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13345285 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 A88CFC001B0 for ; Mon, 7 Aug 2023 23:05:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5E218D0002; Mon, 7 Aug 2023 19:05:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C0C3A8D0001; Mon, 7 Aug 2023 19:05:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A86AA8D0002; Mon, 7 Aug 2023 19:05:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9C7D38D0001 for ; Mon, 7 Aug 2023 19:05:23 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4D3D080185 for ; Mon, 7 Aug 2023 23:05:23 +0000 (UTC) X-FDA: 81098841726.17.88C548B Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) by imf27.hostedemail.com (Postfix) with ESMTP id 761F640022 for ; Mon, 7 Aug 2023 23:05:21 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=OAmqT2Yp; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691449521; a=rsa-sha256; cv=none; b=Yl0Vpo7hKWE04QD69XvXmkA/oqXqsHxZA2xv4GpVylfdaRCyimFkGLwvUSCRi0ufa8N/g1 bG53NcZ5jJqm63HaopEoAaCiEoit5oV8PK37entIniPuJUFQkrrR/E+VNsuplztQHAy2Tx ULKd8O1gmPaa/lG1d7FIVEh6N+BkPa4= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=OAmqT2Yp; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691449521; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4fjhesd7+rMkDZLOr6Kc4cG8956dLxCQQb+ozfQX3UQ=; b=DsfFLJ5+yn1QS8sW8kD9zLSNHkyYP2PH1qBCDJMziC3V+8An+bmRVIRsSPgOpM8FjtGvfV M3AR+S5yOO0JgdyqCQrLR1LN4mgaDX27rWv3JAYPYLwicqMnLn2tjeqMOclLwqr1RNF9Z0 oIPAef+zfHg6m5HFrGNiG4Lid7dyDQs= Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-d1fb9107036so5482618276.0 for ; Mon, 07 Aug 2023 16:05:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691449520; x=1692054320; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4fjhesd7+rMkDZLOr6Kc4cG8956dLxCQQb+ozfQX3UQ=; b=OAmqT2YppB9CjfKzA6MbkbWQuHnOV3YDebJzEzMnvrYaEBnGvyiGDdIgN+UFddYCO/ oWD9ALjnIUimu69EOXrUSOl0V3EQ3lBA7Y1MYmMc666cwORz5NLJr1mYNrQUbkaEMEWb UevlkxC+fhWM5pG0rXCbCmrqQYjTZk13aOAK39qUeW68Z9nV/2KJzWOSzi4xEeDeVL48 AtQrP4AvQ44B2EZwMOx7Ik4iUJ1TvzBS0XzBfxhLsaCN0UqBFIO7A8RIwj+QqN3o+IuJ Kl4ISRZis5dwTBUexOURKgSzbeO3folaxRuVtH/QGDwOd5SIJ+mmY1APEfvTznAxJRIC w6YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691449520; x=1692054320; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4fjhesd7+rMkDZLOr6Kc4cG8956dLxCQQb+ozfQX3UQ=; b=gE/vtZyN8SzasYMKFc8Vm8uxR8kBUOrewX0Vo88zyX6jnF0dFwNIOg2FYyu4u9bUaa VgKMV1OYQRZxMUiDXLSgeW8FzEH4Zmi70PIdi9E77zML9lobzpB0HOlMM+6Xo52zZfhg KQAwZl2N6p8JiCpWQL8uMw6KW53KVjG17oHvr6ZoXPhPHu5jCh2UveuuN6TX4fVJpzin 5J65bxYZsS1gachBp6DWRvFzUpe6qpcRXsFCb8hgD0+nGdbW0EXg4nRg47/nsrVczPN8 6iWiZ346T9S79EQAvTutFjo2MewA3ImBkPe0u+Gp4tWYVHDT28UbXkqoXRZAAE0mnSwt K9Fw== X-Gm-Message-State: AOJu0YxTIEtsOSDmce1gmHJVUasb6nwr33+u0SD+7HP5qn3ltaAz6+JD HIVOZN8Oqi604Kv4jA7tVzU= X-Google-Smtp-Source: AGHT+IEx2gi8PNow/7jZZuthXFdwcQBm4qVvrwXdHrr7o3CRr4bjoCnJoA9HiZN+Tg0Khw5JdZ/TIA== X-Received: by 2002:a25:6088:0:b0:d2c:32cb:c631 with SMTP id u130-20020a256088000000b00d2c32cbc631mr5682581ybb.27.1691449520366; Mon, 07 Aug 2023 16:05:20 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::16]) by smtp.googlemail.com with ESMTPSA id d190-20020a25cdc7000000b00d3596aca5bcsm2545203ybf.34.2023.08.07.16.05.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 16:05:20 -0700 (PDT) From: "Vishal Moola (Oracle)" To: Andrew Morton , Matthew Wilcox Cc: linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, Hugh Dickins , "Vishal Moola (Oracle)" , Mike Rapoport Subject: [PATCH mm-unstable v9 01/31] mm: Add PAGE_TYPE_OP folio functions Date: Mon, 7 Aug 2023 16:04:43 -0700 Message-Id: <20230807230513.102486-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230807230513.102486-1-vishal.moola@gmail.com> References: <20230807230513.102486-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 761F640022 X-Stat-Signature: jymgpqrq5o8ez96ps6q66edcg45gytr5 X-HE-Tag: 1691449521-324410 X-HE-Meta: U2FsdGVkX1/BqntY0DFrBjlEFksu0iuLcD3e/H41MPDtByuDpGS4kYEnTG0QjVM6s2Rlb3hmTL83V50WSRm0oMNuWtowx296IAes7hE90phaumVnCTK6ekKrt7mnz7/HseBHQLISzCSnruDNhaW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yjqq0WewbRhXyb2KxTLxzlks/2wxlol36Tgje+11+i54KzXVq9MUuf2+tlOjWzP8UZbyLhflg2MdrLxxvpf2RkumPVbD4QNicY6ziSZtQxj22PtlaJiOjkTLZjkIyDOI/+LEmlWt1t5TJMPwLMT0T5REX2AJNESgqgsnCATr7MDGZXBxVpKxZ3AKs7XKDwEzgVkfe3YyD8CKv6h2QJRwl5O14nTadpEVmvbPzcjqWhE2hr10TS6DUVI5T1naR/MgUd+nggq+GBIqHNjTcFxOrEFGInUHdt+IeXWK7tDjiDVpNPdy96XTmq6zRbLQEVS9HHgEun/iz1YtHF+O21jK2v8uWM/2LoHosq65jkbNBI6T2Z9JmZFXTrpD9CyUnOKmaARhEFsUPSApfLeFbtIw= 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: No folio equivalents for page type operations have been defined, so define them for later folio conversions. Also changes the Page##uname macros to take in const struct page* since we only read the memory here. Acked-by: Mike Rapoport (IBM) Signed-off-by: Vishal Moola (Oracle) --- include/linux/page-flags.h | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 92a2063a0a23..9218028caf33 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -908,6 +908,8 @@ static inline bool is_page_hwpoison(struct page *page) #define PageType(page, flag) \ ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) +#define folio_test_type(folio, flag) \ + ((folio->page.page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) static inline int page_type_has_type(unsigned int page_type) { @@ -919,27 +921,41 @@ static inline int page_has_type(struct page *page) return page_type_has_type(page->page_type); } -#define PAGE_TYPE_OPS(uname, lname) \ -static __always_inline int Page##uname(struct page *page) \ +#define PAGE_TYPE_OPS(uname, lname, fname) \ +static __always_inline int Page##uname(const struct page *page) \ { \ return PageType(page, PG_##lname); \ } \ +static __always_inline int folio_test_##fname(const struct folio *folio)\ +{ \ + return folio_test_type(folio, PG_##lname); \ +} \ static __always_inline void __SetPage##uname(struct page *page) \ { \ VM_BUG_ON_PAGE(!PageType(page, 0), page); \ page->page_type &= ~PG_##lname; \ } \ +static __always_inline void __folio_set_##fname(struct folio *folio) \ +{ \ + VM_BUG_ON_FOLIO(!folio_test_type(folio, 0), folio); \ + folio->page.page_type &= ~PG_##lname; \ +} \ static __always_inline void __ClearPage##uname(struct page *page) \ { \ VM_BUG_ON_PAGE(!Page##uname(page), page); \ page->page_type |= PG_##lname; \ -} +} \ +static __always_inline void __folio_clear_##fname(struct folio *folio) \ +{ \ + VM_BUG_ON_FOLIO(!folio_test_##fname(folio), folio); \ + folio->page.page_type |= PG_##lname; \ +} \ /* * PageBuddy() indicates that the page is free and in the buddy system * (see mm/page_alloc.c). */ -PAGE_TYPE_OPS(Buddy, buddy) +PAGE_TYPE_OPS(Buddy, buddy, buddy) /* * PageOffline() indicates that the page is logically offline although the @@ -963,7 +979,7 @@ PAGE_TYPE_OPS(Buddy, buddy) * pages should check PageOffline() and synchronize with such drivers using * page_offline_freeze()/page_offline_thaw(). */ -PAGE_TYPE_OPS(Offline, offline) +PAGE_TYPE_OPS(Offline, offline, offline) extern void page_offline_freeze(void); extern void page_offline_thaw(void); @@ -973,12 +989,12 @@ extern void page_offline_end(void); /* * Marks pages in use as page tables. */ -PAGE_TYPE_OPS(Table, table) +PAGE_TYPE_OPS(Table, table, pgtable) /* * Marks guardpages used with debug_pagealloc. */ -PAGE_TYPE_OPS(Guard, guard) +PAGE_TYPE_OPS(Guard, guard, guard) extern bool is_free_buddy_page(struct page *page);