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 EDAE7C433EF for ; Fri, 4 Feb 2022 19:59:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C329A6B007E; Fri, 4 Feb 2022 14:59:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 750E46B0075; Fri, 4 Feb 2022 14:59:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E08B6B0073; Fri, 4 Feb 2022 14:59:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0001.hostedemail.com [216.40.44.1]) by kanga.kvack.org (Postfix) with ESMTP id 2B25B6B007D for ; Fri, 4 Feb 2022 14:59:05 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E1E76824C424 for ; Fri, 4 Feb 2022 19:59:04 +0000 (UTC) X-FDA: 79106161008.14.C398D8F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP id 8D6631C0006 for ; Fri, 4 Feb 2022 19:59:04 +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=dWpyn2grOZbdkVKfq1AQyk9euyCX9uRwjuX/Z2zFNP8=; b=IIkx0MGDdfq/Z2Hje/dD5In3xo 5RLRAtlsVK17eQ6leQRmuWVmLhUgRIZ3UNMsql8hGllsmJTC5KqvT2Cu2/tJfRPqmmOzM8xPavF7I Oiqo3heIu0zgrstAoKIS5pPumlBODsWJj953N0OBB8bhVhQGLn82xox7Dpx8x4M4kjVJc17tWA5XF A0YYRqXYJsh4ykbR6TQjS3WKCkM0M0x2snmyX+c+VmEWa7GkSeJL/RTjbg2cdwASk43rEjy5o/oFL YYeP6kslsXWFRCcQuufR/ZMwk4scTRWaF3U9NV3L3Ncsu7fsrx0WX3S3d2Um2C8kS4K9iWwe9WHkU zOjNDC2g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG4jW-007Lmf-WC; Fri, 04 Feb 2022 19:59:03 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org Subject: [PATCH 35/75] mm: Turn head_compound_mapcount() into folio_entire_mapcount() Date: Fri, 4 Feb 2022 19:58:12 +0000 Message-Id: <20220204195852.1751729-36-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220204195852.1751729-1-willy@infradead.org> References: <20220204195852.1751729-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 8D6631C0006 X-Stat-Signature: bcnjnean7bwbgtud6rdjmd5tdy8irrr4 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=IIkx0MGD; dmarc=none; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: nil X-HE-Tag: 1644004744-428193 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: Adjust documentation to be more clear. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 17 +++++++++++------ mm/debug.c | 6 ++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 6cb2651eccbe..6ddf655f9279 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -777,21 +777,26 @@ static inline int is_vmalloc_or_module_addr(const v= oid *x) } #endif =20 -static inline int head_compound_mapcount(struct page *head) +/* + * How many times the entire folio is mapped as a single unit (eg by a + * PMD or PUD entry). This is probably not what you want, except for + * debugging purposes; look at folio_mapcount() or page_mapcount() + * instead. + */ +static inline int folio_entire_mapcount(struct folio *folio) { - return atomic_read(compound_mapcount_ptr(head)) + 1; + VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); + return atomic_read(folio_mapcount_ptr(folio)) + 1; } =20 /* * Mapcount of compound page as a whole, does not include mapped sub-pag= es. * - * Must be called only for compound pages or any their tail sub-pages. + * Must be called only for compound pages. */ static inline int compound_mapcount(struct page *page) { - VM_BUG_ON_PAGE(!PageCompound(page), page); - page =3D compound_head(page); - return head_compound_mapcount(page); + return folio_entire_mapcount(page_folio(page)); } =20 /* diff --git a/mm/debug.c b/mm/debug.c index c4cf44266430..eeb7ea3ca292 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -48,7 +48,8 @@ const struct trace_print_flags vmaflag_names[] =3D { =20 static void __dump_page(struct page *page) { - struct page *head =3D compound_head(page); + struct folio *folio =3D page_folio(page); + struct page *head =3D &folio->page; struct address_space *mapping; bool compound =3D PageCompound(page); /* @@ -76,6 +77,7 @@ static void __dump_page(struct page *page) else mapping =3D (void *)(tmp & ~PAGE_MAPPING_FLAGS); head =3D page; + folio =3D (struct folio *)page; compound =3D false; } else { mapping =3D page_mapping(page); @@ -94,7 +96,7 @@ static void __dump_page(struct page *page) if (compound) { pr_warn("head:%p order:%u compound_mapcount:%d compound_pincount:%d\n"= , head, compound_order(head), - head_compound_mapcount(head), + folio_entire_mapcount(folio), head_compound_pincount(head)); } =20 --=20 2.34.1