Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3679766ybi; Mon, 27 May 2019 04:15:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzX4SlkfWQwTISePrOj0dRNpjt9W7OWiK/K8Z9LxLrVvc6+2Bfp0BsD7Bpq1905iymYdUXJ X-Received: by 2002:aa7:804c:: with SMTP id y12mr60392994pfm.94.1558955714762; Mon, 27 May 2019 04:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558955714; cv=none; d=google.com; s=arc-20160816; b=ME6+OYi/ecsP7hTu4eKsMURWcTaXDGsdaj7ydeXLL6nz5DAP0FPkmLDMbIXz9177CJ JWVA7dDvKMS1iwPiUu3XemczvJnRcjxqlhKT8hzoKEAo/pcjANHn1Xp6pRpzfH5T4nVZ 7TEHB7j4dsrUt1lhoMphqkro3PXmT6fEFY6FRM8mLO7atZCm9ncu087C4MiPz6CYrIkg YaZmDdwI1G6xc7De3P34jV+0XgDvd6n2j84VCz0FFJ7zdOqTvG0eYi2DPsm+RcQfK0Sx mkmSaKSjVmSVnw869t2xDlCviKp7SGOzr2y8/iuSujmJ+8aJYmcl8maHp2i3BRi8m2+D 75vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rSz3Zt/+BgR8xImgIVcrGb75Z6CG2oL9X/qCww6Ms78=; b=q7eJeaJA/7ROo958pDTxn4qnWCiaVC1LvYr4cNkgrPCXvl8OKoivTslTnafPdjrqZ1 Lvn2CcpMq3QRUsYuA5ApRGsetvrEwJIzs1MWHxONEcORYb+5Jy11j3gjTz05qGJKyXFa 7peTIJ2CzUEPT2V1R7dxIkR5ZrM+K92+eaEB15MyixMgrrOTmQ5C7xqVQwXwWUh6apxb NoU/IrWHdnKTV0X4mo5Jd1My34UzWWAMyWe5tDBJNsxGoogFamAZvs5X13TfA41YaPHs z3Vob1EDxYNvl+WpL13YF1h4LntpTdIgpMJAvWBBFAj0bMMLnAZSleoyP+v3d6ztrR7C phQw== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si16758298pfr.277.2019.05.27.04.14.58; Mon, 27 May 2019 04:15:14 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726968AbfE0LM3 (ORCPT + 99 others); Mon, 27 May 2019 07:12:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41410 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726887AbfE0LM2 (ORCPT ); Mon, 27 May 2019 07:12:28 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AADC387621; Mon, 27 May 2019 11:12:27 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id B59CC2AA83; Mon, 27 May 2019 11:12:23 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: 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 , David Hildenbrand , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Chintan Pandya , Mike Rapoport , Jun Yao , Yu Zhao , Robin Murphy , Anshuman Khandual Subject: [PATCH v3 04/11] arm64/mm: Add temporary arch_remove_memory() implementation Date: Mon, 27 May 2019 13:11:45 +0200 Message-Id: <20190527111152.16324-5-david@redhat.com> In-Reply-To: <20190527111152.16324-1-david@redhat.com> References: <20190527111152.16324-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 27 May 2019 11:12:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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