[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b0f5f87c-af03-173c-17e3-ccf15ccb9cb1@redhat.com>
Date: Fri, 16 Apr 2021 13:07:06 +0200
From: David Hildenbrand <david@...hat.com>
To: Oscar Salvador <osalvador@...e.de>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Michal Hocko <mhocko@...nel.org>,
Anshuman Khandual <anshuman.khandual@....com>,
Pavel Tatashin <pasha.tatashin@...een.com>,
Vlastimil Babka <vbabka@...e.cz>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v8 4/8] mm,memory_hotplug: Allocate memmap from the added
memory range
> -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@...hat.com>
--
Thanks,
David / dhildenb
Powered by blists - more mailing lists