Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Usama Arif <usama.arif@linux.dev>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Usama Arif <usama.arif@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jane Chu <jane.chu@oracle.com>,
	linux-mm@kvack.org, Muchun Song <muchun.song@linux.dev>,
	Oscar Salvador <osalvador@suse.de>,
	David Hildenbrand <david@kernel.org>,
	Miaohe Lin <linmiaohe@huawei.com>,
	Naoya Horiguchi <nao.horiguchi@gmail.com>,
	Jan Kara <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org,
	Christian Brauner <christian@brauner.io>
Subject: Re: [PATCH v2 02/10] hugetlb: Mark some function arguments as const
Date: Fri, 10 Jul 2026 07:28:34 -0700	[thread overview]
Message-ID: <20260710142835.1099904-1-usama.arif@linux.dev> (raw)
In-Reply-To: <20260709184740.1286561-3-willy@infradead.org>

On Thu,  9 Jul 2026 19:47:30 +0100 "Matthew Wilcox (Oracle)" <willy@infradead.org> wrote:

> 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) <willy@infradead.org>
> ---
>  include/linux/hugetlb.h | 19 +++++++++----------
>  mm/hugetlb.c            |  2 +-
>  2 files changed, 10 insertions(+), 11 deletions(-)
> 

They all only seem to inspect state.

Acked-by: Usama Arif <usama.arif@linux.dev>


> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> index 2abaf99321e9..18661a7cdb37 100644
> --- a/include/linux/hugetlb.h
> +++ b/include/linux/hugetlb.h
> @@ -165,7 +165,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;
> @@ -292,8 +292,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;
>  }
> @@ -595,8 +594,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);		\
>  	}
>  
> @@ -616,7 +615,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)				\
> @@ -727,7 +726,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;
>  }
> @@ -857,7 +856,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));
> @@ -1088,7 +1087,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;
>  }
> @@ -1157,7 +1156,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
> 
> 


  reply	other threads:[~2026-07-10 14:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 18:47 [PATCH v2 00/10] Use generic_file_read_iter() in hugetlbfs Matthew Wilcox (Oracle)
2026-07-09 18:47 ` [PATCH v2 01/10] mm: Rename folio_contain_hwpoison_page() to folio_has_hwpoison_page() Matthew Wilcox (Oracle)
2026-07-10 14:27   ` Usama Arif
2026-07-09 18:47 ` [PATCH v2 02/10] hugetlb: Mark some function arguments as const Matthew Wilcox (Oracle)
2026-07-10 14:28   ` Usama Arif [this message]
2026-07-09 18:47 ` [PATCH v2 03/10] filemap: Remove checks in mapping_set_folio_order_range() Matthew Wilcox (Oracle)
2026-07-10 14:42   ` Usama Arif
2026-07-09 18:47 ` [PATCH v2 04/10] hugetlb: Set mapping folio order Matthew Wilcox (Oracle)
2026-07-10 14:49   ` Usama Arif
2026-07-09 18:47 ` [PATCH v2 05/10] memory-failure: Remove raw_hwp_list_head() Matthew Wilcox (Oracle)
2026-07-10 14:55   ` Usama Arif
2026-07-09 18:47 ` [PATCH v2 06/10] memory-failure: Prevent UAF in raw_hwp_page list Matthew Wilcox (Oracle)
2026-07-10 15:02   ` Usama Arif
2026-07-10 17:16     ` Matthew Wilcox
2026-07-09 18:47 ` [PATCH v2 07/10] mm: Handle hugetlb correctly in is_page_hwpoison() Matthew Wilcox (Oracle)
2026-07-09 18:47 ` [PATCH v2 08/10] filemap: Add hwpoison handling to filemap_read() Matthew Wilcox (Oracle)
2026-07-09 18:47 ` [PATCH v2 09/10] filemap: Add support for authoritative mappings Matthew Wilcox (Oracle)
2026-07-09 18:47 ` [PATCH v2 10/10] hugetlb: replace hugetlbfs_read_iter() with generic_file_read_iter() Matthew Wilcox (Oracle)
2026-07-09 19:19 ` [PATCH v2 00/10] Use generic_file_read_iter() in hugetlbfs Matthew Wilcox
2026-07-10 14:25 ` Usama Arif
2026-07-10 23:04 ` [syzbot ci] " syzbot ci

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260710142835.1099904-1-usama.arif@linux.dev \
    --to=usama.arif@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=christian@brauner.io \
    --cc=david@kernel.org \
    --cc=jack@suse.cz \
    --cc=jane.chu@oracle.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --cc=nao.horiguchi@gmail.com \
    --cc=osalvador@suse.de \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox