[PATCH 02/14] mm/sparse: remove WARN_ONs from (online|offline)_mem_sections()
From: David Hildenbrand (Arm)
Date: Tue Mar 17 2026 - 13:06:52 EST
We do not allow offlining of memory with memory holes, and always
hotplug memory without holes.
Consequently, we cannot end up onlining or offlining memory sections that
have holes (including invalid sections). That's also why these
WARN_ONs never fired.
Let's remove the WARN_ONs along with the TODO regarding double-checking.
Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
---
mm/sparse.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/mm/sparse.c b/mm/sparse.c
index dfabe554adf8..93252112860e 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -638,13 +638,8 @@ void online_mem_sections(unsigned long start_pfn, unsigned long end_pfn)
for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
unsigned long section_nr = pfn_to_section_nr(pfn);
- struct mem_section *ms;
-
- /* onlining code should never touch invalid ranges */
- if (WARN_ON(!valid_section_nr(section_nr)))
- continue;
+ struct mem_section *ms = __nr_to_section(section_nr);
- ms = __nr_to_section(section_nr);
ms->section_mem_map |= SECTION_IS_ONLINE;
}
}
@@ -656,16 +651,8 @@ void offline_mem_sections(unsigned long start_pfn, unsigned long end_pfn)
for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
unsigned long section_nr = pfn_to_section_nr(pfn);
- struct mem_section *ms;
+ struct mem_section *ms = __nr_to_section(section_nr);
- /*
- * TODO this needs some double checking. Offlining code makes
- * sure to check pfn_valid but those checks might be just bogus
- */
- if (WARN_ON(!valid_section_nr(section_nr)))
- continue;
-
- ms = __nr_to_section(section_nr);
ms->section_mem_map &= ~SECTION_IS_ONLINE;
}
}
--
2.43.0