]> www.infradead.org Git - users/willy/linux.git/commit
mm, memory_hotplug: move zone/pages handling to offline stage
authorOscar Salvador <osalvador@suse.com>
Wed, 5 Dec 2018 00:13:50 +0000 (11:13 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 5 Dec 2018 00:13:50 +0000 (11:13 +1100)
commitdd99d07f818b399089ea15ec21d65f55dc458219
tree4497ab1c732bc561bc91362687b0b88c089e7aee
parentda091b9e3d1e83c5e8a9bafb8b79e3d1cc8737d4
mm, memory_hotplug: move zone/pages handling to offline stage

The current implementation accesses pages during hot-remove stage in order
to get the zone linked to this memory-range.  We use that zone for a)
check if the zone is ZONE_DEVICE and b) to shrink the zone's spanned
pages.

Accessing pages during this stage is problematic, as we might be accessing
pages that were not initialized if we did not get to online the memory
before removing it.

The only reason to check for ZONE_DEVICE in __remove_pages is to bypass
the call to release_mem_region_adjustable(), since these regions are
removed with devm_release_mem_region.

With patch#2, this is no longer a problem so we can safely call
release_mem_region_adjustable().  release_mem_region_adjustable() will
spot that the region we are trying to remove was acquired by means of
devm_request_mem_region, and will back off safely.

This allows us to remove all zone-related operations from hot-remove
stage.

Because of this, zone's spanned pages are shrinked during the offlining
stage in shrink_zone_pgdat().  It would have been great to decrease also
the spanned page for the node there, but we need them in
try_offline_node().  So we still decrease spanned pages for the node in
the hot-remove stage.

The only particularity is that now
find_smallest_section_pfn/find_biggest_section_pfn, when called from
shrink_zone_span, will now check for online sections and not valid
sections instead.  To make this work with devm/HMM code, we need to call
offline_mem_sections and online_mem_sections in that code path when we are
adding memory.

Link: http://lkml.kernel.org/r/20181127162005.15833-4-osalvador@suse.de
Signed-off-by: Oscar Salvador <osalvador@suse.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
arch/powerpc/mm/mem.c
arch/sh/mm/init.c
arch/x86/mm/init_32.c
arch/x86/mm/init_64.c
include/linux/memory_hotplug.h
kernel/memremap.c
mm/memory_hotplug.c
mm/sparse.c