]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm/sparse: remove WARN_ONs from (online|offline)_mem_sections()
authorDavid Hildenbrand (Arm) <david@kernel.org>
Fri, 20 Mar 2026 22:13:35 +0000 (23:13 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 5 Apr 2026 20:53:31 +0000 (13:53 -0700)
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.
Link: https://lkml.kernel.org/r/20260320-sparsemem_cleanups-v2-3-096addc8800d@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Wei Xu <weixugc@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/sparse.c

index dfabe554adf87b2d5eaf9297b1417922c91034b6..93252112860e3116f362c7061d5849ef1aadaa7e 100644 (file)
@@ -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;
        }
 }