From patchwork Tue Jul 25 04:20:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13325714 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 416ACC00528 for ; Tue, 25 Jul 2023 04:21:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5C4C6B0075; Tue, 25 Jul 2023 00:21:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B0C79900002; Tue, 25 Jul 2023 00:21:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9858A6B007B; Tue, 25 Jul 2023 00:21:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8BC926B0075 for ; Tue, 25 Jul 2023 00:21:11 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5189C40CD8 for ; Tue, 25 Jul 2023 04:21:11 +0000 (UTC) X-FDA: 81048834342.11.7E8BBB5 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by imf21.hostedemail.com (Postfix) with ESMTP id 8195C1C0017 for ; Tue, 25 Jul 2023 04:21:09 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=NIGVZvXp; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.182 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=1690258869; 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=DXYENedStYVsFXpaqy8X3+wmlabVR1q8JHyD5+dxFj0=; b=HLBFS386FbSmQgU2qXPALD33VDPpbxcAf9vGUK40zcYaM9TmXrd6FO8jgxMQ7RDe3UFlhT NTvN0vcsko/XZvr6Zu7Is2o/Oaj95UQiZYgpEt/qxslaTlvz1gS3XYHVEe+tiZhRFIyjWX xxCM2Zs4BCZWK/jSD8EPZXjsMykXZi0= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=NIGVZvXp; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.182 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690258869; a=rsa-sha256; cv=none; b=pGs3FD5HwnuBWTCkmMfDR7RXJJ7gZzRung0lTWD/khT6LuO+uyKLaVl+SItE2JpnvV7qcZ GxMTqQXCZk3gTBuqjk2dWlHhp9Y0F3DpxhMomwsYoaVK6dZfJ0nKpfltpnEk0fCJbJ0b63 Nc9JHDPwUjc9F9FVgQWxvFcOxbiTPrE= Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-cf284f4d7afso5663483276.3 for ; Mon, 24 Jul 2023 21:21:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690258868; x=1690863668; 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=DXYENedStYVsFXpaqy8X3+wmlabVR1q8JHyD5+dxFj0=; b=NIGVZvXp4f6PI/DiyEOXr4f5A6/bm955BIOhiZOHaf2xh+RIldWqkGVwj9eR6s7h/D u8onvMaEHJrYU/HCUYvuGCCHfNRwQcrgAf2DqnNwPmYZKfV6oX/8zUa5Ig2Q+OQW0ypq XPjKaW0SZdhI5qLkWxfkcfI+eeyw8wOays1ttc+jYPlhsNlhP4uKwb+dfDR5nCYKuXl2 +XMxk/OSmgfJy9dL/mFwEgWIg+fhMPrVsdF2dCpA0ebzWdyAhRP+4N95J6UWvMmJ+uKs yf/le1oPMyKhHzKGvzlCs3EuPlXqwgoKoHDer5fRkFbOxeVLftXul8Z+3F07FK5C3JFa Y2Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690258868; x=1690863668; 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=DXYENedStYVsFXpaqy8X3+wmlabVR1q8JHyD5+dxFj0=; b=VRRB2gjQrMWIBNUDR+hpgnP+K/r2IrCUWLB7evLh7k16P58ByIk9ax4xBcPZmwqfA4 e2KoWTYn2gdNd5+lDz0tydAGaR2ge4VElQ5W8ZYEiloRvLHt7psKqGLKBOLlXlkf/jF4 r8/7sKLgIjrMq97YmBS30PxSmP1pMkgET8s7LRElssJOanHXn+VgJEwmId0OMant6kYW rvmGlNdCGLF0n995s+KU9aDKqqLkhDX9kdInPI0A1QYwP6euIT/JMBrQlqBAPM7cP1jN 9IMdEsxFMdDGVpnjuJ82T/u1BTjG5hSHUGCAnHs6HA/sGV7Eb6eDrxUBBE2TNj5B2Dgb YeDA== X-Gm-Message-State: ABy/qLYXklYLK+H6qUmkquZcfjBr9cMm3qDwS3wp4DakEXkURXLm1JoM Vjof/PHJz7KQpqDDi28pbEw= X-Google-Smtp-Source: APBJJlFMeQGxec1oJDVWQUYg3sII69ysVmGK3iC6jxP+dksIpqg/98z6796G6YK9NBoYSePtafE2Ug== X-Received: by 2002:a25:7ac6:0:b0:c5e:d3af:35cb with SMTP id v189-20020a257ac6000000b00c5ed3af35cbmr8904739ybc.42.1690258868599; Mon, 24 Jul 2023 21:21:08 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::16]) by smtp.googlemail.com with ESMTPSA id h9-20020a25b189000000b00d0db687ef48sm1175540ybj.61.2023.07.24.21.21.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 21:21:08 -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 v7 01/31] mm: Add PAGE_TYPE_OP folio functions Date: Mon, 24 Jul 2023 21:20:21 -0700 Message-Id: <20230725042051.36691-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230725042051.36691-1-vishal.moola@gmail.com> References: <20230725042051.36691-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 8195C1C0017 X-Stat-Signature: qu9tydij67gps3skjcm57b1xs7ay1qdz X-Rspam-User: X-HE-Tag: 1690258869-594196 X-HE-Meta: U2FsdGVkX1+vR8AY8SJNm1ArzmOgXja1NBMzJz6jfF6r42VB+jD/ePxVe/WS4QZF3ZAEHSreWOnq2Ftoz3nbUXC6b7iY9tPnLOm5NIk+TpYULC3efkE8u8jOF8H5QHHoiBNKHQwD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HvBsVgB19HrAh2XH/shajq2GkNcnmqh/vaTraLvHESZ8ucMZrYSIm/en/yzwU5IpM9TWYkpHIRjyg2XMHAZe1ScXTz50cPfeXtwIhuchPZU33j+NahpfMSsBXnKPk6gl5nAnzDxlJZNOKgG/pfME+Wr+70WcRH9T2bTSYrRoHN2eUy2s8G/Iucqj/ssB8DNJv1M7DeluL3/r3Y/pUN3uccSj45aokzSyvd+uziQ3xwBmF21J12/v0bieohiY+X0caGncipL/scfpUwhGP18Nmq0p2AfzWaw6egBsjY/Nwff0NfJd2L4B6hgindaPPbKqGZ8xzcpvWAiKuzE0gzrVJbgRR99RX2ZF+YqzhvZCrWiXrPUiFlY84xPHXq0iuGNYox2h6BYbbxBoEvPNa8MhhBfORaTyMkbp10ea3Mf4RiQsIJ43Ias5SICLNlj8= 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) Acked-by: Mike Rapoport (IBM) --- 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);