Re: [PATCH v8 04/15] hugetlb: Mark some function arguments as const
[email protected] Mon, 3 Aug 2026 23:41:52 -0700
| Newsgroups | gmane.linux.file-systems,gmane.linux.kernel.mm |
|---|---|
| Message-ID | <[email protected]> |
On 7/31/2026 1:07 PM, Matthew Wilcox (Oracle) wrote: > These functions do not modify their folio argument, so we can mark them=20 > as being const which will allow for some minor optimisations and let us=20 > mark other function arguments as being const in the future. Signed-off-=20 > by: Matthew Wilcox (Oracle) >=20 >=20 > 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. >=20 > Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> > Acked-by: Usama Arif <[email protected]> > Reviewed-by: Gregory Price <[email protected]> > Reviewed-by: Miaohe Lin <[email protected]> > --- > include/linux/hugetlb.h | 19 +++++++++---------- > mm/hugetlb.c | 2 +- > 2 files changed, 10 insertions(+), 11 deletions(-) >=20 > 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); > =20 > -struct address_space *hugetlb_folio_mapping_lock_write(struct folio *fol= io); > +struct address_space *hugetlb_folio_mapping_lock_write(const struct foli= o *folio); > =20 > 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; > } > =20 > -static inline struct address_space *hugetlb_folio_mapping_lock_write( > - struct folio *folio) > +static inline struct address_space *hugetlb_folio_mapping_lock_write(con= st 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 =3D &folio->private; \ > +bool folio_test_hugetlb_##flname(const struct folio *folio) \ > + { const void *private =3D &folio->private; \ > return test_bit(HPG_##flname, private); \ > } > =20 > @@ -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; } > =20 > #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; > } > =20 > -static inline struct hugepage_subpool *hugetlb_folio_subpool(struct foli= o *folio) > +static inline struct hugepage_subpool *hugetlb_folio_subpool(const struc= t folio *folio) > { > return folio->_hugetlb_subpool; > } > @@ -876,7 +875,7 @@ static inline bool arch_has_huge_bootmem_alloc(void) > } > #endif > =20 > -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(st= ruct file *file) > return 0; > } > =20 > -static inline struct hugepage_subpool *hugetlb_folio_subpool(struct foli= o *folio) > +static inline struct hugepage_subpool *hugetlb_folio_subpool(const struc= t folio *folio) > { > return NULL; > } > @@ -1176,7 +1175,7 @@ static inline struct hstate *hstate_vma(struct vm_a= rea_struct *vma) > return NULL; > } > =20 > -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 *fol= io) > +struct address_space *hugetlb_folio_mapping_lock_write(const struct foli= o *folio) > { > struct address_space *mapping =3D folio_mapping(folio); > =20 > --=20 > 2.47.3 >=20 Reviewed-by: Jane Chu <[email protected]> thanks, -jane