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 71B84C4167B for ; Sat, 31 Dec 2022 21:46:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44E4E8E0014; Sat, 31 Dec 2022 16:46:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 249068E0018; Sat, 31 Dec 2022 16:46:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F35738E0016; Sat, 31 Dec 2022 16:46:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D54538E0001 for ; Sat, 31 Dec 2022 16:46:36 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B82ADA02F8 for ; Sat, 31 Dec 2022 21:46:36 +0000 (UTC) X-FDA: 80303935992.22.717EC64 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf09.hostedemail.com (Postfix) with ESMTP id 3FC1814000D for ; Sat, 31 Dec 2022 21:46:34 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TUtKBu96; spf=none (imf09.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=1672523195; a=rsa-sha256; cv=none; b=dT67iXGoVC9+nnd2UmBSS7bYQPY+OrW25mHFYDCgM7L7SfqqIhc+JXWXvrwMQrIAmdjOVe 8HGbciYjy/hu9juDou81BWVYLetoim2cgvSj/IWn4capD63UXBULQfQxHtY1UPBAtTwTxV vKxk8G38COAOo/8tXY4dgQX6Dil2aCg= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TUtKBu96; spf=none (imf09.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=1672523195; 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=QgsvB1oN/cnvlW92dNAD5N+075D0L1/Jt0SsBfnWtRI=; b=7Us0r5NDlYNiOpmFYIaooMhLgTxip0WnNtRd+UoTnvWk2qOYegpHehTij8mjpA1+zP1mNN mH4LX3b+mdXUCt0B1BP1XjGFG0Ujq2TqVwW592mQiK13W4c47JDevYO88QrgFaMOmNqZWE z5EnRBTvRDcZeZKmcudc0fcUJlTXq88= 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=QgsvB1oN/cnvlW92dNAD5N+075D0L1/Jt0SsBfnWtRI=; b=TUtKBu96fL6cDaIJjMTPFnnqLn LHj7U+ypDA2HdpRiO8J2L6d+lOYUekHy0GPF6y6YOJMYi50/kelJ+Wu13FekUJitHJl/i7YLNX2BR 2OBWq+T1sDYZu+eVK2qacKAA+goAlalruABUqrTQC0YjlQAb4GO6A58bs7ObirjFfByPPtKi1osVU wSPbSh9B1anf9oN0zSHU+C+G3tDOyEOyLBMYBoQQfBzeo+KlUpj0pYyGx7YWyIsv9xWlfqPuDTyVi loIa4yhTAKOJjsTzY6RHSB7qocKs3MJHAAQghY4FKU7eVZyJdl2rz8xrhvB9Nrv9F8wG6xlk+l4RW ywky6Cgg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pBjgD-00BkaZ-1D; Sat, 31 Dec 2022 21:46:13 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Hugh Dickins Subject: [PATCH 04/22] mm: Convert total_compound_mapcount() to folio_total_mapcount() Date: Sat, 31 Dec 2022 21:45:52 +0000 Message-Id: <20221231214610.2800682-5-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: 3FC1814000D X-Stat-Signature: uz6oie7prckscx1aa5ws8gyxayfwmjf8 X-HE-Tag: 1672523194-653342 X-HE-Meta: U2FsdGVkX1+44BxTXoeRz2w27m4KBSGKEXLgVS/JHdNK5q31H9HD+eZtJvssZLtu8eBCu/RQl166ssxTo+C0w1SggwJAqd/HnuCMPW12VvlYOOHLNatcIJysUoT1jzDWwk1UzATBONTqFkNjtTfUaRI2mEjD09NftTHBv1lMztuUJ4orP+GQKsoPDutRb3GFIOgB2jQD50kYUbNTSOjQSAI5prrEmhXpSvvRNY/ed6tRcPt2ddEqMADmCMcv5/k6yj93FqG+H87Cnijtl93VTBSGovBtPXbLNiDcx8NSI89HA36ok+DXrRH3em/NGfZuzwI+Hw33eNv4yimFsQZ+6jAZKAqFWKNMUV7p6fIxaXFHkw8LrFDYfDan49Iqt2EEFzdoOih0tYyl+8+Syp9HJePjins3zsLOQS39zF4QyiMddpEq53d0LTWTyyV/qr3kAjjSnOpGKeHOWORgoUAAqAoJhuODQ0eJTvwiIvNNzj2rrXUgJDUrTdn65a12mXvbn5Vz86K2qkxaUv3Vn6m6WaYyJ2R0ny9obc/Y/DxmSPqU6WQPZF3SqtKWlfiyzaF7XMWgDCaOoCoFr0PMFxs4XfjBYuhR/pwaS4oLQn8t/nU4nhiYGy02GihEWLD150RhnIP9hwY8Mo6ApKK0bLifJPUM5SXVcbYopEFhltx1M7ETpWFkvyt6pazQih5irOOQNEzJmvA+nYwJ38RzkScBoGrJyYnRscuLYY/sMszcOmEJIV9AahbHozS678ZZ1EO3MyYkMOf5zMw52RRCoQ2aM1ctSYNHpIn1XFjZBQJ1tAsKn4ru4jlqpkoZJy3+Oo7RWnJ6MsJBJKiTQMMTbqXEnfSbzot/JYE75j6cl/t0wgCIoMw57IVviG2b2UD6tiDvBEbhi2OdwzUBiRPFVmTHHDcTyqeNidW/c8Ed+27JOj9Wjd/LdVgLWQ== 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: Instead of enforcing that the argument must be a head page by naming, enforce it with the compiler by making it a folio. Also rename the counter in struct folio from _compound_mapcount to _entire_mapcount. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 6 +++--- include/linux/mm_types.h | 6 +++--- mm/rmap.c | 21 ++++++++++----------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 7ee1938278f5..0079f779da47 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -866,7 +866,7 @@ static inline int page_mapcount(struct page *page) return head_compound_mapcount(page) + mapcount; } -int total_compound_mapcount(struct page *head); +int folio_total_mapcount(struct folio *folio); /** * folio_mapcount() - Calculate the number of mappings of this folio. @@ -883,14 +883,14 @@ static inline int folio_mapcount(struct folio *folio) { if (likely(!folio_test_large(folio))) return atomic_read(&folio->_mapcount) + 1; - return total_compound_mapcount(&folio->page); + return folio_total_mapcount(folio); } static inline int total_mapcount(struct page *page) { if (likely(!PageCompound(page))) return atomic_read(&page->_mapcount) + 1; - return total_compound_mapcount(compound_head(page)); + return folio_total_mapcount(page_folio(page)); } static inline bool folio_large_is_mapped(struct folio *folio) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index fc44d5bab7b8..15cfb0e24e84 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -306,7 +306,7 @@ static inline struct page *encoded_page_ptr(struct encoded_page *page) * @_head_1: Points to the folio. Do not use. * @_folio_dtor: Which destructor to use for this folio. * @_folio_order: Do not use directly, call folio_order(). - * @_compound_mapcount: Do not use directly, call folio_entire_mapcount(). + * @_entire_mapcount: Do not use directly, call folio_entire_mapcount(). * @_nr_pages_mapped: Do not use directly, call folio_mapcount(). * @_pincount: Do not use directly, call folio_maybe_dma_pinned(). * @_folio_nr_pages: Do not use directly, call folio_nr_pages(). @@ -360,7 +360,7 @@ struct folio { unsigned long _head_1; unsigned char _folio_dtor; unsigned char _folio_order; - atomic_t _compound_mapcount; + atomic_t _entire_mapcount; atomic_t _nr_pages_mapped; atomic_t _pincount; #ifdef CONFIG_64BIT @@ -403,7 +403,7 @@ FOLIO_MATCH(flags, _flags_1); FOLIO_MATCH(compound_head, _head_1); FOLIO_MATCH(compound_dtor, _folio_dtor); FOLIO_MATCH(compound_order, _folio_order); -FOLIO_MATCH(compound_mapcount, _compound_mapcount); +FOLIO_MATCH(compound_mapcount, _entire_mapcount); FOLIO_MATCH(subpages_mapcount, _nr_pages_mapped); FOLIO_MATCH(compound_pincount, _pincount); #ifdef CONFIG_64BIT diff --git a/mm/rmap.c b/mm/rmap.c index 09f4d260a46c..17984eb9f990 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1085,27 +1085,26 @@ int pfn_mkclean_range(unsigned long pfn, unsigned long nr_pages, pgoff_t pgoff, return page_vma_mkclean_one(&pvmw); } -int total_compound_mapcount(struct page *head) +int folio_total_mapcount(struct folio *folio) { - struct folio *folio = (struct folio *)head; - int mapcount = head_compound_mapcount(head); - int nr_subpages; + int mapcount = folio_entire_mapcount(folio); + int nr_pages; int i; - /* In the common case, avoid the loop when no subpages mapped by PTE */ + /* In the common case, avoid the loop when no pages mapped by PTE */ if (folio_nr_pages_mapped(folio) == 0) return mapcount; /* - * Add all the PTE mappings of those subpages mapped by PTE. - * Limit the loop, knowing that only subpages_mapcount are mapped? + * Add all the PTE mappings of those pages mapped by PTE. + * Limit the loop to folio_nr_pages_mapped()? * Perhaps: given all the raciness, that may be a good or a bad idea. */ - nr_subpages = thp_nr_pages(head); - for (i = 0; i < nr_subpages; i++) - mapcount += atomic_read(&head[i]._mapcount); + nr_pages = folio_nr_pages(folio); + for (i = 0; i < nr_pages; i++) + mapcount += atomic_read(&folio_page(folio, i)->_mapcount); /* But each of those _mapcounts was based on -1 */ - mapcount += nr_subpages; + mapcount += nr_pages; return mapcount; } -- 2.35.1