On Mon 27-05-19 13:11:45, David Hildenbrand wrote:
> A proper arch_remove_memory() implementation is on its way, which also
> cleanly removes page tables in arch_add_memory() in case something goes
> wrong.
> 
> As we want to use arch_remove_memory() in case something goes wrong
> during memory hotplug after arch_add_memory() finished, let's add
> a temporary hack that is sufficient enough until we get a proper
> implementation that cleans up page table entries.
> 
> We will remove CONFIG_MEMORY_HOTREMOVE around this code in follow up
> patches.

I would drop this one as well (like s390 counterpart).
 
> Cc: Catalin Marinas <catalin.mari...@arm.com>
> Cc: Will Deacon <will.dea...@arm.com>
> Cc: Mark Rutland <mark.rutl...@arm.com>
> Cc: Andrew Morton <a...@linux-foundation.org>
> Cc: Ard Biesheuvel <ard.biesheu...@linaro.org>
> Cc: Chintan Pandya <cpan...@codeaurora.org>
> Cc: Mike Rapoport <r...@linux.ibm.com>
> Cc: Jun Yao <yaojun8558...@gmail.com>
> Cc: Yu Zhao <yuz...@google.com>
> Cc: Robin Murphy <robin.mur...@arm.com>
> Cc: Anshuman Khandual <anshuman.khand...@arm.com>
> Signed-off-by: David Hildenbrand <da...@redhat.com>
> ---
>  arch/arm64/mm/mmu.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index a1bfc4413982..e569a543c384 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -1084,4 +1084,23 @@ int arch_add_memory(int nid, u64 start, u64 size,
>       return __add_pages(nid, start >> PAGE_SHIFT, size >> PAGE_SHIFT,
>                          restrictions);
>  }
> +#ifdef CONFIG_MEMORY_HOTREMOVE
> +void arch_remove_memory(int nid, u64 start, u64 size,
> +                     struct vmem_altmap *altmap)
> +{
> +     unsigned long start_pfn = start >> PAGE_SHIFT;
> +     unsigned long nr_pages = size >> PAGE_SHIFT;
> +     struct zone *zone;
> +
> +     /*
> +      * FIXME: Cleanup page tables (also in arch_add_memory() in case
> +      * adding fails). Until then, this function should only be used
> +      * during memory hotplug (adding memory), not for memory
> +      * unplug. ARCH_ENABLE_MEMORY_HOTREMOVE must not be
> +      * unlocked yet.
> +      */
> +     zone = page_zone(pfn_to_page(start_pfn));
> +     __remove_pages(zone, start_pfn, nr_pages, altmap);
> +}
> +#endif
>  #endif
> -- 
> 2.20.1

-- 
Michal Hocko
SUSE Labs

Reply via email to