Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A8DB421227 for ; Wed, 5 Aug 2026 21:06:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785963983; cv=none; b=uw/SHNNNW6imU50qO1JG1bIwS/2qtqjF2hYC22gSZPI1aSZJ4QBEUxoTCkxSsKaPu9F93Papo7US0MnbXcn2st6xpt+QEmPfFAZz0BdngjnVGA6JHYhP30G/WT8Kae/N3iaCzYJUamexvtIEJ2BiswUyMcUOlPLkyY/Bi001j34= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785963983; c=relaxed/simple; bh=0HMwglx75QDuJSUjOtcP10enYCP67YLtRracPXWCwlA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V21zpMPhzb0bD86geRjk1cv1SHcD40eLsrV37c3vtglYPU+oZ5hMaIUZ3vnLsK6mPFDwCvZYPblvaesg/rQMsWXUgGSIUbJwZ32FfaRXZ81yeS6PZCmG6/Xf5L8hfjqNgVXcH+/EEW+36KKXfwzCC+L7I8Cud4JIXgBKxOqiZrA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=JicgyhLh; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="JicgyhLh" 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=hAHwpiH4yYWNgumGaMK1j2M65MBFePIvlnZqmKRnndU=; b=JicgyhLhS91OIiO6kYmPLd/lcy cE/FRzVTJARf24S7+jwlC/6xruwWjPjfwmgKoqSDA8mA0SsEr3czuY3pzxJqrMZZl2BFkTOEDlbUs H5h5LTwQvFs59vLBfvsxyr3eEmt5pcTX7sLaQI5Fdn5VzWOsYQH4yqWY2HT7ypafHkAk7AOIDntYn TrKftvnMUrW/4HmH+RkjPOj3ATCNZ9YqRXyt27gtHgSYG4jB0C8Z7tkCE0hw5zSFG97aPFH6XGnqD s0TOCwto9bTtiRTuZd1EDvvP1TAlIg26ndJl69lMuKd/HY6zvgh0DJRY9ytbmkag5fbUeOB1+/LNq 26iL/D9Q==; Received: from willy by casper.infradead.org with local (Exim 4.99.1 #2 (Red Hat Linux)) id 1wrioJ-00000004h6B-2kv3; Wed, 05 Aug 2026 21:05:59 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , Jane Chu , linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Muchun Song , Oscar Salvador , David Hildenbrand , Miaohe Lin , Naoya Horiguchi , Jan Kara , linux-fsdevel@vger.kernel.org, Christian Brauner , Jiaqi Yan , Usama Arif , Gregory Price Subject: [PATCH v9 04/15] hugetlb: Mark some function arguments as const Date: Wed, 5 Aug 2026 22:05:44 +0100 Message-ID: <20260805210557.1118966-5-willy@infradead.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260805210557.1118966-1-willy@infradead.org> References: <20260805210557.1118966-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit These functions do not modify their folio argument, so we can mark them as being const which will allow for some minor optimisations and let us mark other function arguments as being const in the future. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Usama Arif Reviewed-by: Gregory Price Reviewed-by: Miaohe Lin Reviewed-by: Jane Chu --- include/linux/hugetlb.h | 19 +++++++++---------- mm/hugetlb.c | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 50eab2c23299..e200c93088bc 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -176,7 +176,7 @@ bool hugetlbfs_pagecache_present(struct hstate *h, struct vm_area_struct *vma, unsigned long address); -struct address_space *hugetlb_folio_mapping_lock_write(struct folio *folio); +struct address_space *hugetlb_folio_mapping_lock_write(const struct folio *folio); extern int movable_gigantic_pages __read_mostly; extern int sysctl_hugetlb_shm_group __read_mostly; @@ -311,8 +311,7 @@ static inline unsigned long hugetlb_total_pages(void) return 0; } -static inline struct address_space *hugetlb_folio_mapping_lock_write( - struct folio *folio) +static inline struct address_space *hugetlb_folio_mapping_lock_write(const struct folio *folio) { return NULL; } @@ -614,8 +613,8 @@ enum hugetlb_page_flags { #ifdef CONFIG_HUGETLB_PAGE #define TESTHPAGEFLAG(uname, flname) \ static __always_inline \ -bool folio_test_hugetlb_##flname(struct folio *folio) \ - { void *private = &folio->private; \ +bool folio_test_hugetlb_##flname(const struct folio *folio) \ + { const void *private = &folio->private; \ return test_bit(HPG_##flname, private); \ } @@ -635,7 +634,7 @@ void folio_clear_hugetlb_##flname(struct folio *folio) \ #else #define TESTHPAGEFLAG(uname, flname) \ static inline bool \ -folio_test_hugetlb_##flname(struct folio *folio) \ +folio_test_hugetlb_##flname(const struct folio *folio) \ { return 0; } #define SETHPAGEFLAG(uname, flname) \ @@ -746,7 +745,7 @@ static inline struct hugepage_subpool *subpool_inode(struct inode *inode) return HUGETLBFS_SB(inode->i_sb)->spool; } -static inline struct hugepage_subpool *hugetlb_folio_subpool(struct folio *folio) +static inline struct hugepage_subpool *hugetlb_folio_subpool(const struct folio *folio) { return folio->_hugetlb_subpool; } @@ -876,7 +875,7 @@ static inline bool arch_has_huge_bootmem_alloc(void) } #endif -static inline struct hstate *folio_hstate(struct folio *folio) +static inline struct hstate *folio_hstate(const struct folio *folio) { VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio); return size_to_hstate(folio_size(folio)); @@ -1107,7 +1106,7 @@ static inline unsigned long huge_page_mask_align(struct file *file) return 0; } -static inline struct hugepage_subpool *hugetlb_folio_subpool(struct folio *folio) +static inline struct hugepage_subpool *hugetlb_folio_subpool(const struct folio *folio) { return NULL; } @@ -1176,7 +1175,7 @@ static inline struct hstate *hstate_vma(struct vm_area_struct *vma) return NULL; } -static inline struct hstate *folio_hstate(struct folio *folio) +static inline struct hstate *folio_hstate(const struct folio *folio) { return NULL; } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 571212b80835..cc8d98399913 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1775,7 +1775,7 @@ void init_new_hugetlb_folio(struct folio *folio) * stable. Due to locking order, we can only trylock_write. If we can * not get the lock, simply return NULL to caller. */ -struct address_space *hugetlb_folio_mapping_lock_write(struct folio *folio) +struct address_space *hugetlb_folio_mapping_lock_write(const struct folio *folio) { struct address_space *mapping = folio_mapping(folio); -- 2.47.3