From patchwork Tue Mar 26 17:10:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13604742 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 5386BC54E67 for ; Tue, 26 Mar 2024 17:11:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A5386B009F; Tue, 26 Mar 2024 13:10:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5984B6B00A3; Tue, 26 Mar 2024 13:10:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F70D6B009F; Tue, 26 Mar 2024 13:10:54 -0400 (EDT) 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 E942E6B009B for ; Tue, 26 Mar 2024 13:10:53 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id ACC22A0420 for ; Tue, 26 Mar 2024 17:10:53 +0000 (UTC) X-FDA: 81939829986.25.AD8A23E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 8578C180005 for ; Tue, 26 Mar 2024 17:10:51 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=NabuFMxU; dmarc=none; spf=none (imf24.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=1711473051; 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=4rsav8danrviXsQqOhqsj+Cnv5iqAQuNlq8PIWYIZQ0=; b=bgLbvRMHrlS3FJopb6BZAVWN8fJim67pNtEO9Llpr49v0qH+zvN27tAp3o7uSn/63uMju3 RxC8LcSuNcyxjEyDGcJSnsLxGfESOU2zbtw2537vmr9yixb/AZlbaea8D47uINKsKiAMtP UbUCkKKVmw/GOtDhNc7EYZ4QG8pLmDY= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=NabuFMxU; dmarc=none; spf=none (imf24.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=1711473051; a=rsa-sha256; cv=none; b=LGVAgJ1A1MCwBz+QM+kKjdDGZD87AMFlOQT4SBSCeU0uiJFJuWHuBMcabok1jw+C0xTviD Id4CQ/I6RY49itLoIpindYKFM5gYolxRlNOPXI3Jhr6JP9yPIsrPdTMrDDakkg37yE+9e0 TRNMfbqd7Djcl0zRT+cxcs9UvpgL7dk= 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=4rsav8danrviXsQqOhqsj+Cnv5iqAQuNlq8PIWYIZQ0=; b=NabuFMxUr9N12Q+IT4RcMSyJjt fePrd43vUYAPbwNtUMUGCdgCeOoVk8Lh1eQ8iKMOcFpTnQEEDLcxNkJpVZfP5RH63LzyPFuUqDIo2 zFlslJit2L9KPIVDzKyljnWdSmt6qdBWBojrFReviq0XJToPxUs922raT7AGb+rWgLy4oB4vBGAqP t3eesXRHkfJlWEC21jgrOQyWobwy7kiYP/LcKDsc++GX66+vCPKA3q1ifG7MK3aXH8unfzKBLZmo7 dVZlrlB1q0lrVdNCXtSpwSodrwKCFPwoC8OQpXpTINfgw5qf9Cl8IROC9l0ilC+axhnI/zXZVAq3o sd1XP04A==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpAK0-00000001isL-19qZ; Tue, 26 Mar 2024 17:10:48 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 06/10] mm: Make page_mapped() take a const argument Date: Tue, 26 Mar 2024 17:10:28 +0000 Message-ID: <20240326171045.410737-7-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326171045.410737-1-willy@infradead.org> References: <20240326171045.410737-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8578C180005 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: fa15gfgyhyffwto7ge1jphtcr97f7fkk X-HE-Tag: 1711473051-165031 X-HE-Meta: U2FsdGVkX1+hWLAJp2tNaKenLezvzIQLnjG4Gs1VaAb19HgeoNLm4gOwv0kkC6449WirhafacGDk4UTcfc5AbIOWGJr+qKtsl878ktI7VtP6jHxgRq0T40IZXWfYibJxcremAffEU8TywRgPIzxG8MwYFex7KULuWSFYrLPXeaiMQ1zEiQ92TsxAtyLHg1EqutpjBAdyYsTuKE/o9ZTKb7Z0w7tFqoJOxc41Fd/N/ln7XET5Sb2oUQYR8QDkOpqzekH/CEz1CrEDQDdfCsQ39b0Yte8DMcEgF24U4ta9pqSvK0q3d4nnLQVY5bbPCwxlVHr8/tsX9EI/dUsjm+YPutabJLR34LlFEMiOd+KpdC26dFGuc/riOkUBPU0zgoBo2+Xx95TDhD6GlvaYndpDZkRYeF8s+NiVtf+IySHRz3wXlk3bt9+ls/QSPvX61VB+s6XZwAboPbHVsOph3TaQWN0eqYjTaKsVTM8rmNt/Bnh/p2LJTWNFuPRfOu/EndMgW/tmZdcK6lO7y06Qj/XRBFUp5ti9EnpMPMdgtd0zOE04HX0opB7BiUcE0895dOdtWk54zTeQ7PPwqep1ZqUI7xpfKNZDLy72BWvBYUOPQriYqRAy/zYeahEFngkQ4R5cSlFwg4QzM3Tj1kvLSKZY/Qq+P0uG6UwFBVqRKRtAp1gdIkuRTDc4NR1hy5i2LzLT0z0JFQqXgnIJlZgTN7C3cVGqaugeISmTsOVEdI7/+8pEbrPte8Siyv/rSDe9x+qkdXfpCoNF0kstTnwtTC/1IkVgQWwtU4k2YupiOtQ2S9LWd5k4Z6YOisUBqe1OFaWt4dLa+zlGqimkcIAYuMX9tGsASHoGqqF/SRMhuGz3l9Hin27p8aelhE/O7eXXSKqB0h5j/jzVkY3oPt5zJwZIh2qx7czge6Gj7j87aDDuP2yvzLSmWYFYyRrTCMCtw4SD5VAS7pnqjK/CVb7Jcvy 8z0dLbRd ZV0ITfscbQ7teAjlJOjCvpV0gGj6986xpNsmVk2I3CrtzcijMa/+7WgY670YjKVe8ZbbqjsGzYgd4jlFdz2WwNzEK9kuK1/qrYPxyl6/KzukJT0jai/hOm1vIx51Ae4cj1avmtx6bquDjZEr3ay00bjN0jbyVqc0fie+OT5eaFBnhjEmIXwi1xaOvEsKqZpBcAc50mRSrNXka1zIfYworMIAfdGyCFQLoQ6Gp 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: List-Subscribe: List-Unsubscribe: None of the functions called by page_mapped() modify the page or folio, so mark them all as const. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 12 ++++++------ mm/internal.h | 7 ++++--- mm/rmap.c | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index e329f09fbb9c..d226c1929f98 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1200,7 +1200,7 @@ static inline int is_vmalloc_or_module_addr(const void *x) * debugging purposes - it does not include PTE-mapped sub-pages; look * at folio_mapcount() or page_mapcount() instead. */ -static inline int folio_entire_mapcount(struct folio *folio) +static inline int folio_entire_mapcount(const struct folio *folio) { VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); return atomic_read(&folio->_entire_mapcount) + 1; @@ -1240,7 +1240,7 @@ static inline int page_mapcount(struct page *page) return mapcount; } -int folio_total_mapcount(struct folio *folio); +int folio_total_mapcount(const struct folio *folio); /** * folio_mapcount() - Calculate the number of mappings of this folio. @@ -1253,14 +1253,14 @@ int folio_total_mapcount(struct folio *folio); * * Return: The number of times this folio is mapped. */ -static inline int folio_mapcount(struct folio *folio) +static inline int folio_mapcount(const struct folio *folio) { if (likely(!folio_test_large(folio))) return atomic_read(&folio->_mapcount) + 1; return folio_total_mapcount(folio); } -static inline bool folio_large_is_mapped(struct folio *folio) +static inline bool folio_large_is_mapped(const struct folio *folio) { /* * Reading _entire_mapcount below could be omitted if hugetlb @@ -1288,7 +1288,7 @@ static inline bool folio_mapped(struct folio *folio) * For compound page it returns true if any sub-page of compound page is mapped, * even if this particular sub-page is not itself mapped by any PTE or PMD. */ -static inline bool page_mapped(struct page *page) +static inline bool page_mapped(const struct page *page) { if (likely(!PageCompound(page))) return atomic_read(&page->_mapcount) >= 0; @@ -2070,7 +2070,7 @@ static inline void set_page_links(struct page *page, enum zone_type zone, * * Return: A positive power of two. */ -static inline long folio_nr_pages(struct folio *folio) +static inline long folio_nr_pages(const struct folio *folio) { if (!folio_test_large(folio)) return 1; diff --git a/mm/internal.h b/mm/internal.h index 5dbfa1c12e89..8e11f7b2da21 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -71,7 +71,7 @@ void page_writeback_init(void); * How many individual pages have an elevated _mapcount. Excludes * the folio's entire_mapcount. */ -static inline int folio_nr_pages_mapped(struct folio *folio) +static inline int folio_nr_pages_mapped(const struct folio *folio) { return atomic_read(&folio->_nr_pages_mapped) & FOLIO_PAGES_MAPPED; } @@ -81,7 +81,8 @@ static inline int folio_nr_pages_mapped(struct folio *folio) * folio. We cannot rely on folio->swap as there is no guarantee that it has * been initialized. Used for calling arch_swap_restore() */ -static inline swp_entry_t folio_swap(swp_entry_t entry, struct folio *folio) +static inline swp_entry_t folio_swap(swp_entry_t entry, + const struct folio *folio) { swp_entry_t swap = { .val = ALIGN_DOWN(entry.val, folio_nr_pages(folio)), @@ -90,7 +91,7 @@ static inline swp_entry_t folio_swap(swp_entry_t entry, struct folio *folio) return swap; } -static inline void *folio_raw_mapping(struct folio *folio) +static inline void *folio_raw_mapping(const struct folio *folio) { unsigned long mapping = (unsigned long)folio->mapping; diff --git a/mm/rmap.c b/mm/rmap.c index 3746a5531018..d52759aa3ff7 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1134,7 +1134,7 @@ int pfn_mkclean_range(unsigned long pfn, unsigned long nr_pages, pgoff_t pgoff, return page_vma_mkclean_one(&pvmw); } -int folio_total_mapcount(struct folio *folio) +int folio_total_mapcount(const struct folio *folio) { int mapcount = folio_entire_mapcount(folio); int nr_pages;