Skip to contentSkip to conversation

mm/sparse: correct init section annotations

PATCH Applied Sang-Heon Jeon 5 participants 5 messages Jul 31 – Aug 3

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/sparse: correct init section annotations

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.

---
 mm/sparse.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
mm/sparse.c +4 -4
index 704a9dec2b9a..67fa192d4289 100644
@@ -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;
 }
@@ -127,7 +127,7 @@ static inline int sparse_early_nid(struct mem_section *section)
 }
 
 /* Validate the physical addressing limitations of the model */
-static void __meminit mminit_validate_memmodel_limits(unsigned long *start_pfn,
+static void __init mminit_validate_memmodel_limits(unsigned long *start_pfn,
 						unsigned long *end_pfn)
 {
 	unsigned long max_sparsemem_pfn = (DIRECT_MAP_PHYSMEM_END + 1) >> PAGE_SHIFT;
@@ -249,8 +249,8 @@ void __weak __meminit vmemmap_populate_print_last(void)
 {
 }
 
-static void *sparse_usagebuf __meminitdata;
-static void *sparse_usagebuf_end __meminitdata;
+static void *sparse_usagebuf __initdata;
+static void *sparse_usagebuf_end __initdata;
 
 /*
  * Helper function that is used for generic section initialization, and
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 11 lines · 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.

mm/sparse.c int __meminit sparse_index_init(unsigned long section_nr, int nid) · line 110

Quoted 11 lines
mm/sparse.c +1 -1
@@ -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.

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Sang-Heon Jeon
Quoted 7 lines · Sang-Heon Jeon

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.

Quoted 6 lines

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.

---

Signature · 3 lines
Cheers,

David
reviewer Acked-by on v1 1/1
#3 lore raw
In reply to Sang-Heon Jeon
Quoted 4 lines · Sang-Heon Jeon

The !SPARSEMEM_EXTREME stub of sparse_index_init() has no annotation but the SPARSEMEM_EXTREME variant is __meminit. So mark the stub __meminit too.

Quoted 8 lines

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.

Signature · 2 lines
Sincerely yours,
Mike.
Reviewed-by on v1 1/1
#4 lore raw
In reply to Sang-Heon Jeon
Quoted 4 lines · Sang-Heon Jeon

The !SPARSEMEM_EXTREME stub of sparse_index_init() has no annotation but the SPARSEMEM_EXTREME variant is __meminit. So mark the stub __meminit too.

Quoted 8 lines

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.

Quoted 41 lines
---
 mm/sparse.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
mm/sparse.c +4 -4
index 704a9dec2b9a..67fa192d4289 100644
@@ -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;
 }
@@ -127,7 +127,7 @@ static inline int sparse_early_nid(struct mem_section *section)
 }
 
 /* Validate the physical addressing limitations of the model */
-static void __meminit mminit_validate_memmodel_limits(unsigned long *start_pfn,
+static void __init mminit_validate_memmodel_limits(unsigned long *start_pfn,
 						unsigned long *end_pfn)
 {
 	unsigned long max_sparsemem_pfn = (DIRECT_MAP_PHYSMEM_END + 1) >> PAGE_SHIFT;
@@ -249,8 +249,8 @@ void __weak __meminit vmemmap_populate_print_last(void)
 {
 }
 
-static void *sparse_usagebuf __meminitdata;
-static void *sparse_usagebuf_end __meminitdata;
+static void *sparse_usagebuf __initdata;
+static void *sparse_usagebuf_end __initdata;
 
 /*
  * Helper function that is used for generic section initialization, and
Signature · 1 line
2.43.0