Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/sparse: remove WARN_ONs from (online|offline)_mem_sections()

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>

authored by

David Hildenbrand (Arm) and committed by
Andrew Morton
e66383b6 9d80de66

+2 -15
+2 -15
mm/sparse.c
··· 638 638 639 639 for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { 640 640 unsigned long section_nr = pfn_to_section_nr(pfn); 641 - struct mem_section *ms; 641 + struct mem_section *ms = __nr_to_section(section_nr); 642 642 643 - /* onlining code should never touch invalid ranges */ 644 - if (WARN_ON(!valid_section_nr(section_nr))) 645 - continue; 646 - 647 - ms = __nr_to_section(section_nr); 648 643 ms->section_mem_map |= SECTION_IS_ONLINE; 649 644 } 650 645 } ··· 651 656 652 657 for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { 653 658 unsigned long section_nr = pfn_to_section_nr(pfn); 654 - struct mem_section *ms; 659 + struct mem_section *ms = __nr_to_section(section_nr); 655 660 656 - /* 657 - * TODO this needs some double checking. Offlining code makes 658 - * sure to check pfn_valid but those checks might be just bogus 659 - */ 660 - if (WARN_ON(!valid_section_nr(section_nr))) 661 - continue; 662 - 663 - ms = __nr_to_section(section_nr); 664 661 ms->section_mem_map &= ~SECTION_IS_ONLINE; 665 662 } 666 663 }