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 60828C5479D for ; Wed, 11 Jan 2023 14:29:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1E4E940007; Wed, 11 Jan 2023 09:29:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ED0EB8E000F; Wed, 11 Jan 2023 09:29:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CAABD940007; Wed, 11 Jan 2023 09:29:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B104E8E000F for ; Wed, 11 Jan 2023 09:29:16 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 89D251A022C for ; Wed, 11 Jan 2023 14:29:16 +0000 (UTC) X-FDA: 80342750712.11.D914025 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id 065BA40013 for ; Wed, 11 Jan 2023 14:29:14 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ZpsDp1ZU; dmarc=none; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673447355; 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=PWk3rt37uRiBd6nhhszu2D/+LUr+ocb9my4gOz9jlaI=; b=lsWkSh5Z98/IsHY973ueA306Z9Nul9HRYjxL3/LMBCc7DLXqeXe1kwSxCAMoqs97ljdl7x WmWv/tqpssM9F0zAvYsZK1Ms5QE+Vt2LQ71VNse563l1SFuXPhEE6v56oH7GUrFrq0d+Yq Gy8bBfkMNNbeFtWTVDRwhQtBtshom5U= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ZpsDp1ZU; dmarc=none; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673447355; a=rsa-sha256; cv=none; b=OWVUmWHAjrzAUnXNgVIezGSc8G0VcHqKa3KaxPWKLeZVaG6ICTIPaU4USsWkpH3Rq2SY2C j+70Z8KRjrTk63Y4m9ZbcAWJcOhsy8beGtVcuAFbWKiKCLx82GEKW9Edw4rHi/bp5bWplz +A42wl+ka5zJY7k86Dj2az3Rg5Gwoq4= 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=PWk3rt37uRiBd6nhhszu2D/+LUr+ocb9my4gOz9jlaI=; b=ZpsDp1ZUPNMWSo0GDMlRzA27vB VmgcHtEzOm2DuRtNqpaIvZe3JuYN46phjaE+cD+PuSMREJjWFF9HgcUMW9J0jrqJUF7tzaq0Ja5nd nppZl1Cm1749Y35o81K2yroIXsTf/9OK9dTHaRZnt5D/2LecRW00RXMoQoD/kR5JB/NnSTtYRZSWa T2h0KhfjFk7J7+WKrdqiLpl11CW+G12sw4SMLV7m0O9g6o2zQbfrJOS845oiMe/06YpS4dPAR142e Dnv/WbtGCelaAlzaJc8AzGvSQAPQ6sg09gzuW2bE7fXkYl01VDWbB7QtSNOfNMnMhIXDV87VNXTMC kjot5TsQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFc6O-004CY0-VM; Wed, 11 Jan 2023 14:29:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Hugh Dickins Subject: [PATCH 04/28] mm: Convert total_compound_mapcount() to folio_total_mapcount() Date: Wed, 11 Jan 2023 14:28:50 +0000 Message-Id: <20230111142915.1001531-5-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230111142915.1001531-1-willy@infradead.org> References: <20230111142915.1001531-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 065BA40013 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: nntymwydmzzt54peeenhacr4uh3p4o5j X-HE-Tag: 1673447354-892198 X-HE-Meta: U2FsdGVkX1+p7eWqc9ovTn86xoTPfI4gyPrpdAnP6D8EglmmKJrQzZ8nuIWAygn3xRN8DJiEDBgFoZk90MlDtw6bAOp8doT0U8oSjM0pRcsB280S7SZKOVbZU2J6R+OhEojTx9eThaaUeLHA4e6gr8EnswKiGyHt1N6ZsJIl/OvbSDEUN3Llo2If8JGOGhV7tnA7sEm+cz+3V5MzDa1eU+Ydb/wc51XH0/BchYJuViNvzR50NXKaqg7l8pPyNtDsKCkmS4Ebg5R7iel8XyFqGXYBxaNtK6XH3AnZ3IIPXwMs/Z7jup3i+ZPOLsB1xBVBDIDz5jeAR8KjYfYoDaNyg5EfcGLkqwr6nRRMWlGQF7n0ZzWph4UO40WkSYoJVaEw61NrSrWw+lR0AOkzvgwJky8P2gTdxzxVkkyN2sQakJwvXvWwv/1vHdpL/9wjWN8ryK3pIdFzO7FPF03l6ib58VaFeioWr39dFzsDAQGV0p74Fa1DXwshg/bcFVhyTIl39vF0MZYInpuRQNYL4+Bm6fsnARD9abyiLYdekcdoMwsy+c5drpb+zf1w0hHT9yLN2iuUSDjvuL5Z6hk5fO4kJWukgvTXBWmkZtN5OnIyHV6eqH+L4soa1SywytvaEA6b7r5oqtvnYVIjLP2u9Xdm6l1i6mvLPXRwFBCTmHHPziyL1fAlJIprnRgvUIh7WrQAnzbswkCwHwAle3zTvnWacWZaHQd/fC6VIPCF/fFt8ChAkYn/t43h5lVGTM8OIVMnhl0dEM7WTG2poyaxuVUmjY6YC1ewxhxdRue5AyrsPM56/W/Z5rGsAyFZrMq/6aR15GjW6cylt6r7ixQQj75wWbqUbci0KtqOl42qaQIvV2JbxI/EYPmimj+49E6MjoP1aFVPoOMBEwPYJotCbxqJWZZoVncjXdws0XbCZ9H3m6oqXnsYa7LL5g== 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 aa151e69416d..8bddc7810f78 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -871,7 +871,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. @@ -888,14 +888,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 aa2039f18f4d..a66054a9f0b6 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 f08685054d0a..675d8401c2da 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1078,27 +1078,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