Re: [v4 6/6] mm/memory_hotplug: optimize memory hotplug

From: Michal Hocko
Date: Mon Feb 19 2018 - 08:42:50 EST


On Thu 15-02-18 11:59:20, Pavel Tatashin wrote:
[...]
> @@ -260,21 +260,12 @@ static int __meminit __add_section(int nid, unsigned long phys_start_pfn,
> return ret;
>
> /*
> - * Make all the pages reserved so that nobody will stumble over half
> - * initialized state.
> - * FIXME: We also have to associate it with a node because page_to_nid
> - * relies on having page with the proper node.
> + * The first page in every section holds node id, this is because we
> + * will need it in online_pages().
> */
> - for (i = 0; i < PAGES_PER_SECTION; i++) {
> - unsigned long pfn = phys_start_pfn + i;
> - struct page *page;
> - if (!pfn_valid(pfn))
> - continue;
> -
> - page = pfn_to_page(pfn);
> - set_page_node(page, nid);
> - SetPageReserved(page);
> - }
> + page = pfn_to_page(phys_start_pfn);
> + mm_zero_struct_page(page);
> + set_page_node(page, nid);

I really dislike this part. It is just too subtle assumption. We can
safely store the node id into memory_block and push it down the way to
online. Or am I missing something?

Btw. the rest of the series seem good as is so I would go with it and
keep this last patch aparat and make sure to do it properly rather than
add more hacks.

> if (!want_memblock)
> return 0;
--
Michal Hocko
SUSE Labs