From patchwork Thu Mar 21 14:24:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13598776 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 72335C54E68 for ; Thu, 21 Mar 2024 14:25:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD8B16B0095; Thu, 21 Mar 2024 10:25:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8A996B0096; Thu, 21 Mar 2024 10:25:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB7E16B0098; Thu, 21 Mar 2024 10:25:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9A9786B0095 for ; Thu, 21 Mar 2024 10:25:08 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7045412136D for ; Thu, 21 Mar 2024 14:25:08 +0000 (UTC) X-FDA: 81921268296.03.E4CC5F2 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id CB1431A0016 for ; Thu, 21 Mar 2024 14:25:06 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tmDboZEe; dmarc=none; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711031106; 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=UUO66vHKvPfAbmInHFgL3UfGdliS6xZEbrFBwuiOeG8=; b=rCEIN+5DL2GNn0RWGDZpm9QJe08nPR1fGtR0pTJAlH0vN7dlzKwkKxYN3fIf8Zu90JCCCf X/TOSPsykk04pBM6DYy2hweWQUc5XmrSM7UztJSTUApn1QhiaCHBxv/OtqwOpbQRxdVzFC vJM4ggnQQxhGKfHulmZa1Kz3kAIonYs= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tmDboZEe; dmarc=none; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711031106; a=rsa-sha256; cv=none; b=cUfJzNHze2oZYg6fSfRAzXy0WYz29gUbQu3L40q6r2mKYeKrOG3qA2sYl0WoEsUGZaFlbf xAiMrm6gT2Ual8jTRi323VC0dnA56Ki9YbFc+aYJt+PeOTDIRaosaOQ51+u5UWJrVmy9UE CvJQuqCBj8D2Pe5WAStVVFz8VsdtJd0= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=UUO66vHKvPfAbmInHFgL3UfGdliS6xZEbrFBwuiOeG8=; b=tmDboZEe6hbgb0MtG11/QNaq53 G8mq2iMFrX8QvESdWj5cIlc1Ze98teSkAPw+2X3ixhqtJMimYzDwaHpxmLR4bBgZRAemoMDbsxoGC KB+yWfBBIn6s1qpEzT5yJMxcDNt4BRubre7FLlnv0RUg3TRGnUkkFsts84w4wCDTzuC7mplU9OAyW TpZMSyqBpnwkmoaH/h8Q9Xx5nBwru0AwFzVmEQTDDlH40+jUK80OYcwjsfROi+uy4YuiWIgVpZvQf Wm1w/7o5nlPHRxYA20uDRRLonpmXbli6+BFmthT2HwP07X76dL4LWvLmI2eQarCtYMZ1xHbcCQv9V GPD9SIDQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rnJLf-00000006u3w-1o9u; Thu, 21 Mar 2024 14:24:51 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, David Hildenbrand , Vlastimil Babka , Miaohe Lin , Muchun Song , Oscar Salvador Subject: [PATCH 2/9] mm: Create FOLIO_FLAG_FALSE and FOLIO_TYPE_OPS macros Date: Thu, 21 Mar 2024 14:24:40 +0000 Message-ID: <20240321142448.1645400-3-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240321142448.1645400-1-willy@infradead.org> References: <20240321142448.1645400-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: CB1431A0016 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: u4mmgpo1kiq6psukzo9ks5sc19hhg7at X-HE-Tag: 1711031106-429606 X-HE-Meta: U2FsdGVkX19yCoS/w0575yjG4kpxTfztPPxv4GDqZrM0NLsB+7Y87EqMWek2D93V/+AcS0gUPSz9mN/8n8KEDkWnsCroSR4mauZRlWsZ5Vbvc7LUsPumPjSVjgVQWYJ1QO4FYJ5Qf2yqyCK+F0akjde5+JoGHSSsQO81t9mP3REvSod1Xz7Bwaa3VoLXk0cCUf+WMaw5i/59FZ3m6/crmZImQ9K3MLkfo8hq8qjYKYeVrkYqEhmhdLXdOJl6eADYLOqu8c7X+m4p1G4MGad26ejxxPROfXBC8eTyoOTjxpdOaK2EIWrmoGRGXEOq9Xp6IsurRBDWOj3NUnqvs8I21x/1SR1USWPPzEWwvnRZJG5zyS3DsvztG9oUssG9fXxAF454PzoMcvxVV1DKUWi8Rmd6F1cYKZUZGQ7VesbRVJXG/2m2an/vzPnOkWTSGiHEzc2AYCWBybtyyjY83hWfxwUXvEceRrBBHra69jkHmjeIHoEpNOxnw8tbbePwXPqEmOB9tlV7zLqeWfQf8ui9qm2opfrfHoiBMfUn2WAtxncm1vIq/VYoeUlX0Zcz/1fRlYx1byssqbgaLnKgEhbzuG75wSPdRcKHmu/51Epfxe6/OvA1qiwBtgVva5xp9IhDkkpPDmGEnOplaUa0vxD9UoqgUaWepjZONtrtdS1V0KBovCSypYUo2ubmOPjLwWc+4o10lIpKiVxqZGS9nrW3CVJh6cxmXr42uP1637fiSPKXb+zAl4q7BWs7p/82JyFyLEOsdk/X0dEUEcVaBxG2xhE/kDFGAzAeTb1eIS3oklj3s+PrHMjsDr0fop1hgyonP6Z1N9nys1Qq/R07vdklntoKlnt5poTfC8A5Suk+mp7M4eAHe+Lhxckj+9o0GpKI+ZgSRnpubJcb/B1LUboyHRvVAUlKFsiEZD5eh9DqXqJFRSHJ0H92RktNHo61yVL02XNYHfZNEZXujk9II/h RpYXFXhD UohyAl/+CIgdeLbQRJMxOg7G83bN8VTHKXJib48Q1ALjGjvLbC/4xR6P5DfzYlTwQ20e9jhjEAp6YHIcBt4QNG6tGnEtgfK9L/lz460F2t9myD/DDhI5A34EvWbUHi/h2smAcVUJ+HiFjZ9bYc9NTCZXAyWcvwmMrBh0MGhGVYE7q4zCOxEM94MoYJ/rShRUlQ68E9a63aj0+yeMtrF7rRJNEqk9WlJRyuuAb 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: Following the separation of FOLIO_FLAGS from PAGEFLAGS, separate FOLIO_FLAG_FALSE from PAGEFLAG_FALSE and FOLIO_TYPE_OPS from PAGE_TYPE_OPS. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Vlastimil Babka --- include/linux/page-flags.h | 70 +++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 652d77805e99..dc1607f1415e 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -458,30 +458,51 @@ static __always_inline int TestClearPage##uname(struct page *page) \ TESTSETFLAG(uname, lname, policy) \ TESTCLEARFLAG(uname, lname, policy) +#define FOLIO_TEST_FLAG_FALSE(name) \ +static inline bool folio_test_##name(const struct folio *folio) \ +{ return false; } +#define FOLIO_SET_FLAG_NOOP(name) \ +static inline void folio_set_##name(struct folio *folio) { } +#define FOLIO_CLEAR_FLAG_NOOP(name) \ +static inline void folio_clear_##name(struct folio *folio) { } +#define __FOLIO_SET_FLAG_NOOP(name) \ +static inline void __folio_set_##name(struct folio *folio) { } +#define __FOLIO_CLEAR_FLAG_NOOP(name) \ +static inline void __folio_clear_##name(struct folio *folio) { } +#define FOLIO_TEST_SET_FLAG_FALSE(name) \ +static inline bool folio_test_set_##name(struct folio *folio) \ +{ return false; } +#define FOLIO_TEST_CLEAR_FLAG_FALSE(name) \ +static inline bool folio_test_clear_##name(struct folio *folio) \ +{ return false; } + +#define FOLIO_FLAG_FALSE(name) \ +FOLIO_TEST_FLAG_FALSE(name) \ +FOLIO_SET_FLAG_NOOP(name) \ +FOLIO_CLEAR_FLAG_NOOP(name) + #define TESTPAGEFLAG_FALSE(uname, lname) \ -static inline bool folio_test_##lname(const struct folio *folio) { return false; } \ +FOLIO_TEST_FLAG_FALSE(lname) \ static inline int Page##uname(const struct page *page) { return 0; } #define SETPAGEFLAG_NOOP(uname, lname) \ -static inline void folio_set_##lname(struct folio *folio) { } \ +FOLIO_SET_FLAG_NOOP(lname) \ static inline void SetPage##uname(struct page *page) { } #define CLEARPAGEFLAG_NOOP(uname, lname) \ -static inline void folio_clear_##lname(struct folio *folio) { } \ +FOLIO_CLEAR_FLAG_NOOP(lname) \ static inline void ClearPage##uname(struct page *page) { } #define __CLEARPAGEFLAG_NOOP(uname, lname) \ -static inline void __folio_clear_##lname(struct folio *folio) { } \ +__FOLIO_CLEAR_FLAG_NOOP(lname) \ static inline void __ClearPage##uname(struct page *page) { } #define TESTSETFLAG_FALSE(uname, lname) \ -static inline bool folio_test_set_##lname(struct folio *folio) \ -{ return 0; } \ +FOLIO_TEST_SET_FLAG_FALSE(lname) \ static inline int TestSetPage##uname(struct page *page) { return 0; } #define TESTCLEARFLAG_FALSE(uname, lname) \ -static inline bool folio_test_clear_##lname(struct folio *folio) \ -{ return 0; } \ +FOLIO_TEST_CLEAR_FLAG_FALSE(lname) \ static inline int TestClearPage##uname(struct page *page) { return 0; } #define PAGEFLAG_FALSE(uname, lname) TESTPAGEFLAG_FALSE(uname, lname) \ @@ -977,35 +998,38 @@ static inline int page_has_type(const struct page *page) return page_type_has_type(page->page_type); } +#define FOLIO_TYPE_OPS(lname, fname) \ +static __always_inline bool folio_test_##fname(const struct folio *folio)\ +{ \ + return folio_test_type(folio, 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 __folio_clear_##fname(struct folio *folio) \ +{ \ + VM_BUG_ON_FOLIO(!folio_test_##fname(folio), folio); \ + folio->page.page_type |= PG_##lname; \ +} + #define PAGE_TYPE_OPS(uname, lname, fname) \ +FOLIO_TYPE_OPS(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