lkml.org 
[lkml]   [2021]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v8 4/8] mm,memory_hotplug: Allocate memmap from the added memory range
From
Date

> -int __ref online_pages(unsigned long pfn, unsigned long nr_pages,
> - int online_type, int nid)
> +int mhp_init_memmap_on_memory(unsigned long pfn, unsigned long nr_pages,
> + struct zone *zone)
> +{
> + unsigned long end_pfn = pfn + nr_pages;
> + int ret;
> +
> + ret = kasan_add_zero_shadow(__va(PFN_PHYS(pfn)), PFN_PHYS(nr_pages));
> + if (ret)
> + return ret;
> +
> + /*
> + * Initialize vmemmap pages with the corresponding node, zone links set.

The "set" sounds weird. I'd remove that comment completely.

> + */
> + move_pfn_range_to_zone(zone, pfn, nr_pages, NULL, MIGRATE_UNMOVABLE);
> +
> + /*
> + * It might be that the vmemmap_pages fully span sections. If that is
> + * the case, mark those sections online here as otherwise they will be
> + * left offline.
> + */
> + if (nr_pages >= PAGES_PER_SECTION)
> + online_mem_sections(pfn, ALIGN_DOWN(end_pfn, PAGES_PER_SECTION));
> +
> + return ret;
> +}
> +
> +void mhp_deinit_memmap_on_memory(unsigned long pfn, unsigned long nr_pages)
> +{
> + unsigned long end_pfn = pfn + nr_pages;
> + /*
> + * The pages associated with this vmemmap have been offlined, so
> + * we can reset its state here.
> + */
> + remove_pfn_range_from_zone(page_zone(pfn_to_page(pfn)), pfn, nr_pages);
> + kasan_remove_zero_shadow(__va(PFN_PHYS(pfn)), PFN_PHYS(nr_pages));
> +
> + /*
> + * It might be that the vmemmap_pages fully span sections. If that is
> + * the case, mark those sections offline here as otherwise they will be
> + * left online.
> + */
> + if (nr_pages >= PAGES_PER_SECTION)
> + offline_mem_sections(pfn, ALIGN_DOWN(end_pfn, PAGES_PER_SECTION));

It's usually best if you undo stuff in the complete opposite order. For
example at this point, the memmap might already have been poisoned, yet
pfn_to_online_page() would return true. You should do that first.

Apart from that, nothing jumped at me :)

Reviewed-by: David Hildenbrand <david@redhat.com>

--
Thanks,

David / dhildenb

\
 
 \ /
  Last update: 2021-04-16 13:08    [W:0.053 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site