Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,7 @@ void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
{
struct pglist_data *pgdat = zone->zone_pgdat;
int nid = pgdat->node_id;
const enum zone_contig_state contiguous_state =
zone_contig_state_after_growing(zone, start_pfn, nr_pages);

clear_zone_contiguous(zone);

if (zone_is_empty(zone))
Expand Down Expand Up @@ -833,8 +832,6 @@ void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
memmap_init_range(nr_pages, nid, zone_idx(zone), start_pfn, 0,
MEMINIT_HOTPLUG, altmap, migratetype,
isolate_pageblock);

set_zone_contiguous(zone, contiguous_state);
}

struct auto_movable_stats {
Expand Down Expand Up @@ -1143,6 +1140,7 @@ int mhp_init_memmap_on_memory(unsigned long pfn, unsigned long nr_pages,
{
unsigned long end_pfn = pfn + nr_pages;
int ret, i;
enum zone_contig_state contiguous_state = ZONE_CONTIG_NO;

ret = kasan_add_zero_shadow(__va(PFN_PHYS(pfn)), PFN_PHYS(nr_pages));
if (ret)
Expand All @@ -1157,6 +1155,10 @@ int mhp_init_memmap_on_memory(unsigned long pfn, unsigned long nr_pages,
if (mhp_off_inaccessible)
page_init_poison(pfn_to_page(pfn), sizeof(struct page) * nr_pages);

if (IS_ALIGNED(end_pfn, PAGES_PER_SECTION))
contiguous_state = zone_contig_state_after_growing(zone, pfn,
nr_pages);

move_pfn_range_to_zone(zone, pfn, nr_pages, NULL, MIGRATE_UNMOVABLE,
false);

Expand All @@ -1175,6 +1177,7 @@ int mhp_init_memmap_on_memory(unsigned long pfn, unsigned long nr_pages,
if (nr_pages >= PAGES_PER_SECTION)
online_mem_sections(pfn, ALIGN_DOWN(end_pfn, PAGES_PER_SECTION));

set_zone_contiguous(zone, contiguous_state);
return ret;
}

Expand Down Expand Up @@ -1213,6 +1216,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages,
};
const int nid = zone_to_nid(zone);
int need_zonelists_rebuild = 0;
enum zone_contig_state contiguous_state = ZONE_CONTIG_NO;
unsigned long flags;
int ret;

Expand All @@ -1227,6 +1231,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages,
!IS_ALIGNED(pfn + nr_pages, PAGES_PER_SECTION)))
return -EINVAL;

contiguous_state = zone_contig_state_after_growing(zone, pfn, nr_pages);

/* associate pfn range with the zone */
move_pfn_range_to_zone(zone, pfn, nr_pages, NULL, MIGRATE_MOVABLE,
Expand Down Expand Up @@ -1265,6 +1270,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages,
}

online_pages_range(pfn, nr_pages);
set_zone_contiguous(zone, contiguous_state);
adjust_present_page_count(pfn_to_page(pfn), group, nr_pages);

if (node_arg.nid >= 0)
Expand Down