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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85890C3DA7A for ; Sat, 31 Dec 2022 21:46:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DCF88E000F; Sat, 31 Dec 2022 16:46:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F04A8E0001; Sat, 31 Dec 2022 16:46:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9AF58E000F; Sat, 31 Dec 2022 16:46:24 -0500 (EST) 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 CBDBB8E0001 for ; Sat, 31 Dec 2022 16:46:24 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A94A81A05A5 for ; Sat, 31 Dec 2022 21:46:24 +0000 (UTC) X-FDA: 80303935488.08.5E3282C Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP id 2169220005 for ; Sat, 31 Dec 2022 21:46:22 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bI0pe4Vg; spf=none (imf13.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672523183; a=rsa-sha256; cv=none; b=SvRTZSXcN6IXkbkBFiO1rRh2mks3BtG8M9tfCa8rkzwAp8MGXPvP6LLIJDGcAMkG/G/hQs FU7DP+ELfwRchhB/6h8Hffw/y0g1Gk8DkCKU3r5Kv8az++vxCOCkug67d5kGjJnOneA6N5 KR0sTbyZYiOVxqUGTyNRUfilj5TIYio= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bI0pe4Vg; spf=none (imf13.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672523183; 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=JanrAscp8O841ylPQVyLGAsbvT0lHRCieI9tsy6zFJ4=; b=G6Z/bG/TDYVsnQHflPPglg+JO/z7XRs4k2K335VRqcJ2xCaIlQy6fnOIZkpMPt+uETg7Yl me40qONBRgMSDZ7sIVl/Urg2d9xK5KHo0cgl+HPeeDg3fS7a/9wjwSm/320/wF/hXNRv8B 9tIqPgvFSXvd7lszibHPoPOPiLD1zLo= 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=JanrAscp8O841ylPQVyLGAsbvT0lHRCieI9tsy6zFJ4=; b=bI0pe4VgdNMI7TXhPTmWe2qvYd uHR7EeMrbPJiZBmMr24bdgYy1vup4hrj/x1//HFdb4endlIaQt6pqkAyoM6Qwg8WFvfeGcoT0K6wg OWhJ2Ux/kAA899G9qG+EdxPuytg1D1RCre75HQVa4UdXLyA85qlJPy3jxYAeE6Cy8ElQhDMaDaVWs AkPKjZhQVdTXMtj/0aVsUX4FFHN+DId320c8luzin5Lnxf8gHSIH+KMI0q5jyLYSmNNki3gZhMcsx mW4Hs5JAUo4abUD8tLdZaZONMScIsnePYUGcA3lLWB03b0Pgtjkgns0/Lyz8jA2ntxfuWupYlQRNq xZukq1Rg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pBjgE-00Bkaz-2X; Sat, 31 Dec 2022 21:46:14 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Hugh Dickins Subject: [PATCH 17/22] mm: Reimplement compound_nr() Date: Sat, 31 Dec 2022 21:46:05 +0000 Message-Id: <20221231214610.2800682-18-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20221231214610.2800682-1-willy@infradead.org> References: <20221231214610.2800682-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 2169220005 X-Stat-Signature: txsrz7btnipdgi17jjhs1qqogq5b9trc X-HE-Tag: 1672523182-387163 X-HE-Meta: U2FsdGVkX19NHhN+yIqPtrfmwH83LchZhWw0qJ+lPgIvWY8aykeXmlLLrI1mQue8RI1I16wDqSQTk1yw0RV152hn+6Ohgx9S3U1/yseP8k9uqD3kcYotsg04pHwoBSIlgaXSS6PImUQOBSEWc6nlyRWAI000zS2Qz9x/qTeIkpZsI1pd4+aWFE1LRBnfSYiamZRbGXkiT7IeF2LEbS1NtS/KYNkjWzgsoNeKSlW9RTdRjtZq/UfMLTIPhq2XjU/IjLGSXgaslcnLM8M2Yvqv7N/raXPuNz/wGXgihREowYdADy1KbbSThR5uY1gTuZLfiVSBAGIsL2YUQuYSDaGybJikVaVLpQaNUMzD53hZoVgv5917146zUBjngekw+Pk7guUmR4lguxvb/tKYT9CbNuGwQaNFvKXwmHQZafUD4sfxv8F5TDPwZ2+3+nyNNkZmMv3javao40pBmxq6UKZhPg0536vICrL9vuGVxnMtGgck/WT+SfKi5AeCpANwawHX/dHZB0z6R6k8QpiDOunaHgvMl8GpC2LZg6hFAW4B0liZ1tUM2Ee5de0GEXCHiElWKiEMFOgNjNvC0mJmSTzdoqZuUa+KAfX9i61PHoX9ESjuiQ9KiIgrzG3ss4RjwvUXbOe0BLHq99cYzTjkNyD/6H6Wje+OrochEzxBeHoa05JKes0Lz2cYNIecTHuPZOv6VK1AFbZH+7c6JPWp0/SvfgE4odN0Ux48mO073MKqg75utGzjxHlxtHEKNMcIR3TuPsAoSNO+t6UULrynxbx7LkGKKfDnPp04i0bEDU1Flv3nx44IATcnAjzIuLvTXMlyZHub2ElzBvtlajWeHag+Wv8egT7INAi6kbCympByxlM7ysXL51vCDS0yDwL7Go38Mgdu4Zep5EwOEU6bkg55OY6kee+m9l0Hwbvv5wYt1yQl8TmJ3T6a1g== 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: Turn compound_nr() into a wrapper around folio_nr_pages(). Similarly to compound_order(), casting the struct page directly to struct folio preserves the existing behaviour, while calling page_folio() would change the behaviour. Move thp_nr_pages() down in the file so that compound_nr() can be after folio_nr_pages(). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 19bdb4b0e00a..75054fce8ec6 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1016,18 +1016,6 @@ static inline void folio_set_compound_order(struct folio *folio, #endif } -/* Returns the number of pages in this potentially compound page. */ -static inline unsigned long compound_nr(struct page *page) -{ - if (!PageHead(page)) - return 1; -#ifdef CONFIG_64BIT - return page[1].compound_nr; -#else - return 1UL << compound_order(page); -#endif -} - /* Returns the number of bytes in this potentially compound page. */ static inline unsigned long page_size(struct page *page) { @@ -1050,16 +1038,6 @@ static inline unsigned int thp_order(struct page *page) return compound_order(page); } -/** - * thp_nr_pages - The number of regular pages in this huge page. - * @page: The head page of a huge page. - */ -static inline int thp_nr_pages(struct page *page) -{ - VM_BUG_ON_PGFLAGS(PageTail(page), page); - return compound_nr(page); -} - /** * thp_size - Size of a transparent huge page. * @page: Head page of a transparent huge page. @@ -1754,6 +1732,22 @@ static inline long folio_nr_pages(struct folio *folio) #endif } +/* Returns the number of pages in this potentially compound page. */ +static inline unsigned long compound_nr(struct page *page) +{ + return folio_nr_pages((struct folio *)page); +} + +/** + * thp_nr_pages - The number of regular pages in this huge page. + * @page: The head page of a huge page. + */ +static inline int thp_nr_pages(struct page *page) +{ + VM_BUG_ON_PGFLAGS(PageTail(page), page); + return compound_nr(page); +} + /** * folio_next - Move to the next physical folio. * @folio: The folio we're currently operating on. -- 2.35.1