Re: [PATCH] mm/sparse: correct init section annotations

Andrew Morton <[email protected]>
Newsgroups org.kvack.linux-mm
Message-ID <[email protected]>
On Sat,  1 Aug 2026 01:47:55 +0900 Sang-Heon Jeon <[email protected]> wrote:

> The !SPARSEMEM_EXTREME stub of sparse_index_init() has no annotation
> but the SPARSEMEM_EXTREME variant is __meminit. So mark the stub
> __meminit too.
> 
> mminit_validate_memmodel_limits() is only called by memory_present(),
> which is __init. So mark it __init.
> 
> sparse_usagebuf and sparse_usagebuf_end are only used by
> sparse_init_early_section(), sparse_usage_init() and sparse_usage_fini(),
> which are all __init. So mark them __initdata.
> 

lgtm, thanks.

> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -104,7 +104,7 @@ int __meminit sparse_index_init(unsigned long section_nr, int nid)
>  	return 0;
>  }
>  #else /* !SPARSEMEM_EXTREME */
> -int sparse_index_init(unsigned long section_nr, int nid)
> +int __meminit sparse_index_init(unsigned long section_nr, int nid)
>  {
>  	return 0;
>  }

We could make this

#ifndef CONFIG_SPARSEMEM_EXTREME
static inline int __meminit sparse_index_init(unsigned long section_nr, int nid)
{
	return 0;
}
#endif

in a header and make it go away altogether.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.