Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2081737ybi; Mon, 1 Jul 2019 05:56:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkTNuzVcN91UFb7yXXjLLyNo0fS2i4LyKGikImyCpaFVWRpRQXKt5BL8ryPpkDEC0ZAQL/ X-Received: by 2002:a17:90a:8c06:: with SMTP id a6mr31776158pjo.45.1561985766102; Mon, 01 Jul 2019 05:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561985766; cv=none; d=google.com; s=arc-20160816; b=bs/xdjUY7NzA5C8SWVyMnaDqkFXelKAEoRfsTSQA24GhtgNaQXhtod14tdh6b3O04N h9P4S5qRN6J7ptGAZ/3W7edrun0HaRejS8iRmAN93Cj2dxqewmnxuso5LQ3Zqoz/tzBg 1OylP804vGaNgUeaYFGvBQf2yQ5ZB2b35d5Cx1Iqyr8VjpD+LtzHI8VXIpElutBtNzqk 4xgRGKxFYXd2AvV9hN6taOoVrYEZGpxJk7JZT7YDKQc4OW15VHzwRajmp6FsI3WXaP9l sNh9lHcpzpkE6dA0JTA0hVJzXBjJCJlV312WUilWdyyXfpCvSeET1iYoXLpYJQmBvZqh Fxyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=FWFHLEgXAwZyHnduMfur4d50bMeZGwi4UgUyPe2mriQ=; b=zeU64WbxXeQwwm7kxVNf82w7MvzglclOC7SEyI2beCcEIT4BTxtjgNvNfgl+sUk76c TUB6p9AVsj4iu/w/7rqQwyLaGTje6V8U8YTkmFaE74oa+sST0hYenAcmoINIX0nx2FE4 bryz7ynBtfIZfuNiVFPEkWoTDwYVBm5qKQ6O0pKRsv8zhbAmxzPiltQHPR6L9/V4bcUw QMrDHO+qkoekWuKajB4+wgyGiUPpSJx/MIJ5io11QP4BiW+ew203C2foJy47Yv0oGiuN Ew51rqxE30xCKtI6Y1kkx/Y07O3eRAAh+QwFiZVdpoFXbtIG+UcaVl2aafY8ibRq0Xgp iHWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bg11si10684973pjb.72.2019.07.01.05.55.49; Mon, 01 Jul 2019 05:56:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728192AbfGAMsM (ORCPT + 99 others); Mon, 1 Jul 2019 08:48:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:51130 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727479AbfGAMsM (ORCPT ); Mon, 1 Jul 2019 08:48:12 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 80FCEAF2C; Mon, 1 Jul 2019 12:48:10 +0000 (UTC) Date: Mon, 1 Jul 2019 14:48:09 +0200 From: Michal Hocko To: David Hildenbrand Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, Dan Williams , Wei Yang , Igor Mammedov , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Chintan Pandya , Mike Rapoport , Jun Yao , Yu Zhao , Robin Murphy , Anshuman Khandual Subject: Re: [PATCH v3 04/11] arm64/mm: Add temporary arch_remove_memory() implementation Message-ID: <20190701124809.GV6376@dhcp22.suse.cz> References: <20190527111152.16324-1-david@redhat.com> <20190527111152.16324-5-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190527111152.16324-5-david@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Cc: Will Deacon > Cc: Mark Rutland > Cc: Andrew Morton > Cc: Ard Biesheuvel > Cc: Chintan Pandya > Cc: Mike Rapoport > Cc: Jun Yao > Cc: Yu Zhao > Cc: Robin Murphy > Cc: Anshuman Khandual > Signed-off-by: David Hildenbrand > --- > 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