From patchwork Mon May 1 19:27:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13227920 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 9224DC77B73 for ; Mon, 1 May 2023 19:28:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19BEB900004; Mon, 1 May 2023 15:28:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12454900002; Mon, 1 May 2023 15:28:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDEBD900004; Mon, 1 May 2023 15:28:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E12EE900002 for ; Mon, 1 May 2023 15:28:38 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AAD08ADA3C for ; Mon, 1 May 2023 19:28:38 +0000 (UTC) X-FDA: 80742673116.01.619C547 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by imf04.hostedemail.com (Postfix) with ESMTP id C59E940009 for ; Mon, 1 May 2023 19:28:36 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=pYnEspIg; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682969316; 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=9i6mX6BOTgb2TGO86QCloW3rCrq78sBOKu0dxXwRHVs=; b=OoAKdOCn0r8UmTwPwaQzEmhLm+GWTiGkZRRq3S3+a0nVE4pojBudPnr+rD7SBstyZrLVPN /fIy7beopKUFxUZ2Ybh3/GWcHrxC3ET/J9Qsh1Fjuus08gQtzJaWcBhO2XR0dmBXKslULU leVlH03EVTiZn2yHr8iN73MtTNCPyM0= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=pYnEspIg; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.215.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682969316; a=rsa-sha256; cv=none; b=s9eMbgwr7uBQcR7U5NUye4IBe3ySqUq5dTK1QP2S1mB1uhlVUvWirNt6ggVugceLsOQvM1 LgVoxu4yKCi+f7eFtk7SL34Ij/fBqlkG8eADAPQIt9wQ+gXn8GoBELaii60SqWK1LQsCiS dGI4DUYcKa0nRS/JXNZbBRxXUqNxiKk= Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-517bb01bac9so1886471a12.0 for ; Mon, 01 May 2023 12:28:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682969316; x=1685561316; 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=9i6mX6BOTgb2TGO86QCloW3rCrq78sBOKu0dxXwRHVs=; b=pYnEspIgQ/94L4B7QgE7HxUaLyMe6HQnu5gVv7XKe7wrHmtTwaLadWDte57s2SBwdQ 8bePLJ5Ai3/AmYhH4RiAfK8IjGb+8BxlohLn4+W6ycJ9Pg3WMvHLkkZOviW7YYTD/mmK GtZnk734H4mZvUq9Iut38ZejJnfrw2oYgWeCZ6PRbVlgoGyBpRA67FKhICj+7yH7j8HF a3LIP2IDGGOTftrbrsZRq8EQiQ5R1WymqweCw9yu0t92fclq88jf6kqwtf3FextynpJY IncHO/7Qw6ErlKR7f7HeTzuXXgCmLczBJBgXHLIbesev1rm2mkGmxXqiRqgTqpx3oce1 ZBnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682969316; x=1685561316; 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=9i6mX6BOTgb2TGO86QCloW3rCrq78sBOKu0dxXwRHVs=; b=GOJh9W0qi7z1B4b3S0fw8d7XIdeJ+lEiXshFn7shzjF+Dn/LqH093by4lbAyu27B0D xq/Gw7OEqnAro7WjJH50kuOVoqGwfsbxUoy+0dq6jDYeCq2Tm6pEf59PQARtUQNGcN3K BZpId5NbQG62aUlJ3ufC6x8lkti7x99P3Yl1VNHB2RHyzSe1d6MNi5oAx9kHfbwB6nWM cQZJZIvu1tCQp6frKl4E6fDkZQN6WQzNY2anc2iVUxCdS7g9j3ePI0JiVfvdFiQY/N1I ETBBvVQgpJJYqNh9pex0hiPreVaXcB/IY1fP4hbkpX4Hqfj0mGc2n4EXz7bLc/lm3rJ5 Bv7Q== X-Gm-Message-State: AC+VfDx/PTjlULfwRG3F7i+WIEpolsYFGwNb5KCbos/F8dSkZMLYOTSz Xcx7xaT8HmeyIlPUA76Ylq4S6anYPoWz7MUk X-Google-Smtp-Source: ACHHUZ4H6i4St7ld1wD0WuHlGapRQhff/8tSAzzBd7XutE+/MiRiNA1zmkp/wHjGquMcgELZnMsxdQ== X-Received: by 2002:a17:903:1c3:b0:1a9:80a0:47dc with SMTP id e3-20020a17090301c300b001a980a047dcmr15039374plh.3.1682969315645; Mon, 01 May 2023 12:28:35 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::9a2c]) by smtp.googlemail.com with ESMTPSA id u8-20020a170902bf4800b0019c13d032d8sm18175622pls.253.2023.05.01.12.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 12:28:35 -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, "Vishal Moola (Oracle)" Subject: [PATCH v2 01/34] mm: Add PAGE_TYPE_OP folio functions Date: Mon, 1 May 2023 12:27:56 -0700 Message-Id: <20230501192829.17086-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501192829.17086-1-vishal.moola@gmail.com> References: <20230501192829.17086-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C59E940009 X-Stat-Signature: yf8rya9qt1isenpu4bs3q59bztrah5xm X-Rspam-User: X-HE-Tag: 1682969316-909381 X-HE-Meta: U2FsdGVkX19cceIInCH0Mv58hSRJztqz6taa3orrD76seT9ukiuoylPGCpjfM4QqPmQfGSB5ecHdAoz87kARzZCnLWcpqFf2iZStFfBeso/ZMVxoXTmHO58p+1MLhzdUmoU86MtNRT+4JuHL/E8b+5LyzS6i6W4vrEhMFQEGo9ZeWj8NKdnwe5PM5Pig0xq1HMOCuZfH89sL1nsST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qUdQzyPp4Pp2Dukm8++IdqdkgyA6b6h7Q5ilm37d0cTepE0REQzCwKlWXI4DEnoH3NdaTljBPSL3wmseZWSAFu5ArZkbN9GDP6TNi3+kFROhUDAZC/slUUfVFbD1S9W0bido3GDwF9J/Hd8iM3J5FARiA6rTgcKA4W80bElSmvzGeDWyRkoILvrDCshdzTVrKorHC9Uyc4gnIJ6F5m4FmTWjTC68hgUM0Jpgyabw1xQSpPmb3iNfR5pNG1RDqzsLzQgGOmYic+20gYlA0nFoWFzB59x4BSyguGMTkeu+g= 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. Signed-off-by: Vishal Moola (Oracle) --- include/linux/page-flags.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 1c68d67b832f..607b495d1b57 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -902,6 +902,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) { @@ -914,20 +916,34 @@ static inline int page_has_type(struct page *page) } #define PAGE_TYPE_OPS(uname, lname) \ -static __always_inline int Page##uname(struct page *page) \ +static __always_inline int Page##uname(const struct page *page) \ { \ return PageType(page, PG_##lname); \ } \ +static __always_inline int folio_test_##lname(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_##lname(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_##lname(struct folio *folio) \ +{ \ + VM_BUG_ON_FOLIO(!folio_test_##lname(folio), folio); \ + folio->page.page_type |= PG_##lname; \ +} \ /* * PageBuddy() indicates that the page is free and in the buddy system