From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49949C4361B for ; Tue, 8 Dec 2020 20:12:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0080E23A02 for ; Tue, 8 Dec 2020 20:12:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0080E23A02 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 97EE86B006C; Tue, 8 Dec 2020 15:12:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 931AA6B006E; Tue, 8 Dec 2020 15:12:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 822786B0070; Tue, 8 Dec 2020 15:12:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0144.hostedemail.com [216.40.44.144]) by kanga.kvack.org (Postfix) with ESMTP id 6C8176B006C for ; Tue, 8 Dec 2020 15:12:01 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 33F09180AD801 for ; Tue, 8 Dec 2020 20:12:01 +0000 (UTC) X-FDA: 77571211242.03.glue82_000345a273e9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 19A8B28A4EC for ; Tue, 8 Dec 2020 20:12:01 +0000 (UTC) X-HE-Tag: glue82_000345a273e9 X-Filterd-Recvd-Size: 3367 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Tue, 8 Dec 2020 20:12:00 +0000 (UTC) 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=GXe88oFVuW5E50eWvehgyMPXo+ZSI7ysxpRbYPxEyKw=; b=L1OAotuFTl9MqvWQhrRpWjeJg7 +NIHpnE87lRzWc6LFtgOO507tVsQcSG8RjCTgQb1Y+pwZEjOfkRrNZAkeN+6Tf00VPF7V6wHDYXsc z0DaFe7sTFsHdOSAuqm5IXnFATDBFn+NTCo7w7V/8mbGo8/zkecQr78Vns995egjAMN2UFVwj0WtO LBv0s1Jinda1fnTss8fp25rI+mjD0vvoHj4DsPc2aE/0PDlS/gRWtNqOJ51JN7E457oqgBG5h9V2n PGfXHzIi+0Q1uca8c1BAjYhlG68a16ShaOeZG2+gOUnoTc7l6o6q1SwXfLvQALum4+a/nRTBBvOfK flYx11kw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmiwr-00050B-Lk; Tue, 08 Dec 2020 19:46:57 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org Subject: [RFC PATCH 01/11] mm: Introduce struct folio Date: Tue, 8 Dec 2020 19:46:43 +0000 Message-Id: <20201208194653.19180-2-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201208194653.19180-1-willy@infradead.org> References: <20201208194653.19180-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: We have trouble keeping track of whether we've already called compound_head() to ensure we're not operating on a tail page. Further, it's never clear whether we intend a struct page to refer to PAGE_SIZE bytes or page_size(compound_head(page)). Introduce a new type 'struct folio' that always refers to an entire (possibly compound) page, and points to the head page (or base page). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 5 +++++ include/linux/mm_types.h | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index d1f64744ace2..7db9a10f084b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -916,6 +916,11 @@ static inline unsigned int compound_order(struct pag= e *page) return page[1].compound_order; } =20 +static inline unsigned int folio_order(struct folio *folio) +{ + return compound_order(&folio->page); +} + static inline bool hpage_pincount_available(struct page *page) { /* diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 65df8abd90bd..d7e487d9998f 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -223,6 +223,23 @@ struct page { #endif } _struct_page_alignment; =20 +/* + * A struct folio is either a base (order-0) page or the head page of + * a compound page. + */ +struct folio { + struct page page; +}; + +static inline struct folio *page_folio(struct page *page) +{ + unsigned long head =3D READ_ONCE(page->compound_head); + + if (unlikely(head & 1)) + return (struct folio *)(head - 1); + return (struct folio *)page; +} + static inline atomic_t *compound_mapcount_ptr(struct page *page) { return &page[1].compound_mapcount; --=20 2.29.2