From patchwork Mon Jul 31 17:03:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13335102 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 596ABC001DC for ; Mon, 31 Jul 2023 17:03:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E918B6B0166; Mon, 31 Jul 2023 13:03:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E42D16B0167; Mon, 31 Jul 2023 13:03:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE32028006F; Mon, 31 Jul 2023 13:03:47 -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 BA4286B0166 for ; Mon, 31 Jul 2023 13:03:47 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6E47B120BBF for ; Mon, 31 Jul 2023 17:03:47 +0000 (UTC) X-FDA: 81072528894.04.1A4BB3B Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) by imf30.hostedemail.com (Postfix) with ESMTP id F2B178003B for ; Mon, 31 Jul 2023 17:03:40 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=R8qXZOyV; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf30.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.181 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690823021; a=rsa-sha256; cv=none; b=myFhg5tbspG4WcJIdne60OeYxoiTrbWy9e/Ki/MS7HMtEx/KyPuv+2PJOFpqkc/74no6Nb PtVtC3oN0uTrC7GJZhz0Qj80P798vBpYSoG+sZgAwCtTxpWMIl442REmxqOlYEYUMsZMA0 4ldxPss8G/Q2aNx3u2zXj6N1L6w0950= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=R8qXZOyV; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf30.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.181 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=1690823021; 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=M7wiLLYIteoLh+idRtlBIak5S/TpZa50soZhyUrsjPFm4rcZ2pu89uew+LOA/bxJlpmpUp qyZhfYC77yYayx/Xnj8eJ4JGsr8KS1H1dlRce0dgIIFxbhn+1rHIX5XNOk4JqdSDbocIJ6 UvYzLe0D8VnByAQxGKS88r0r9OpbKds= Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-d05a63946e0so4859559276.1 for ; Mon, 31 Jul 2023 10:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690823020; x=1691427820; 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=R8qXZOyVQEehD2hSCsZpjQT5/Xf4F/brzByoll1mkB6kHNfXhJ+RcuKFwjYgA2X3Sk +7iApdQo4Cg5rRr+JdIoFqDPegtGDiAGRb35thEkDI1bUQUjq4aw+LSTgzrTpSIcmWfL bJsnhuf8GiZRZhIc6fFdHQySZ/IskewEUKqkNZ8aYCG1nKX4deKA2DfN9abSC9BVfmNb sjmF+khX55fBUw2Vqk+TxqOS6BA3VaGbAlziGVokfw/bjXQRn/YvIXdekpuhXXQ/VglV zbi9hIBXyZbJADitdtmejGR4UrX429LImbE9yX5FhLBTl4AmxfHwzr7gnLpRW2zU3ngh Rejg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690823020; x=1691427820; 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=elqyj5GQfHw57mw/KaslTh5OKnzmcxK14NcLBtm5fuxtUObwoWc47PXCJ/sSEm01iS Y/cx05Y2nWtAOkeKT8CkHlqbs2hMXP/+LmPVv6MRyWaXD+yvQ1wnq5Q4DQnACwJZggIw bBXuode8i6C3wR1CgcWFxBHxUItZ3+eo2fP49SQnvz2u4mLFlav3cUsjA68SiaamljwY RqPjCJIJlDtwN67ZRRz6yF+/2aUHHs3FGiF6LVC8zdY6hnSa1hv4gBb5Q8Efm7MgSa6C ffUPb/NWyLCuDqN7kFEe2AjbSw/yeH7DT77Z/u7ZA8fWs/6mD58TcXRF51umhBi441fe +Qkw== X-Gm-Message-State: ABy/qLYkVv0NlSMFRudvXSrUvBYmHrj7p7VdXTPC1Mn7FTFbKXAYzNU/ sRUrZpuGhOMz73t2/1lyXB0= X-Google-Smtp-Source: APBJJlG+a23ZkNAOXVkZypjt9XfAMSGYibV34A8tZ1fqqbfsROXiDspwRbZtJgVYmae4gyEjzVzU0Q== X-Received: by 2002:a05:6902:18d6:b0:c15:c55d:c26e with SMTP id ck22-20020a05690218d600b00c15c55dc26emr12586459ybb.54.1690823019726; Mon, 31 Jul 2023 10:03:39 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::16]) by smtp.googlemail.com with ESMTPSA id x31-20020a25ac9f000000b00c832ad2e2eesm2511833ybi.60.2023.07.31.10.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 10:03:39 -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 v8 01/31] mm: Add PAGE_TYPE_OP folio functions Date: Mon, 31 Jul 2023 10:03:02 -0700 Message-Id: <20230731170332.69404-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230731170332.69404-1-vishal.moola@gmail.com> References: <20230731170332.69404-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: F2B178003B X-Stat-Signature: nsr9fqzrtm5x11okhonwo13h5d8a8rmo X-HE-Tag: 1690823020-962300 X-HE-Meta: U2FsdGVkX186FaZ93gnc7imod/y2ONVrh0c98OtqpSXq3E2HNNKUYGx6lOqEenJjJdtD1ynnujOdyk+gTYtrXf1XgLmYZMNDoBONx9AR2H4F848WdgAwOcLluwa7cwhoJwFuVjB4ogk4Gm+GPlE5PYuaVA4D7T3JrWsdLP+fUcT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H4woNtAfiqhfrl/1LWF0COPtDjJoXNTrQjL0vF6w2105z56n2BsiNx8YxX4aTCa0xlP4sYiP5Po1PvCQfBBtrk0zTcJ3biAS2XwjjvHuPOqNNM+1G2y1DTpKgTBaj3/1OzPn/0+Nahqeompz1zisf6GCAefcwereodUI86+j5dLd0e4Ih56nQsre5erKqurB6RKlQe7lrYLFEasatflId/lchHVSlptw4IQ1xHwgHMB9juq7tAiuFtE6oCOoifNzS3y45m0fRTkcKgVKY8xluZp7YlgYGd6Wwk1nq4rhArehmkZ4Oa41pX4AtR5HdOD2vVxdKVvMrKjpZnAW7ETCOaxjOxwr1i6SD+xvW1lNdkmKOLDqBjnpa5IwAdlNoecg4/pVT1BwA0= 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);