Skip to content

Commit 52fb87c

Browse files
David Hildenbrandtorvalds
authored andcommitted
mm/memory_hotplug: cleanup __remove_pages()
Let's drop the basically unused section stuff and simplify. Also, let's use a shorter variant to calculate the number of pages to the next section boundary. Link: http://lkml.kernel.org/r/20191006085646.5768-11-david@redhat.com Signed-off-by: David Hildenbrand <david@redhat.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Michal Hocko <mhocko@suse.com> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> Cc: Pavel Tatashin <pasha.tatashin@soleen.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Logan Gunthorpe <logang@deltatee.com> Cc: Pankaj Gupta <pagupta@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 5d12071 commit 52fb87c

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

‎mm/memory_hotplug.c‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -516,25 +516,20 @@ static void __remove_section(unsigned long pfn, unsigned long nr_pages,
516516
void __remove_pages(unsigned long pfn, unsigned long nr_pages,
517517
struct vmem_altmap *altmap)
518518
{
519+
const unsigned long end_pfn = pfn + nr_pages;
520+
unsigned long cur_nr_pages;
519521
unsigned long map_offset = 0;
520-
unsigned long nr, start_sec, end_sec;
521522

522523
map_offset = vmem_altmap_offset(altmap);
523524

524525
if (check_pfn_span(pfn, nr_pages, "remove"))
525526
return;
526527

527-
start_sec = pfn_to_section_nr(pfn);
528-
end_sec = pfn_to_section_nr(pfn + nr_pages - 1);
529-
for (nr = start_sec; nr <= end_sec; nr++) {
530-
unsigned long pfns;
531-
528+
for (; pfn < end_pfn; pfn += cur_nr_pages) {
532529
cond_resched();
533-
pfns = min(nr_pages, PAGES_PER_SECTION
534-
- (pfn & ~PAGE_SECTION_MASK));
535-
__remove_section(pfn, pfns, map_offset, altmap);
536-
pfn += pfns;
537-
nr_pages -= pfns;
530+
/* Select all remaining pages up to the next section boundary */
531+
cur_nr_pages = min(end_pfn - pfn, -(pfn | PAGE_SECTION_MASK));
532+
__remove_section(pfn, cur_nr_pages, map_offset, altmap);
538533
map_offset = 0;
539534
}
540535
}

0 commit comments

Comments
 (0)