From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BF0EC2BB85 for ; Thu, 16 Apr 2020 10:47:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3C8B921973 for ; Thu, 16 Apr 2020 10:47:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fCUAz1Fq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C8B921973 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9F0438E00A2; Thu, 16 Apr 2020 06:47:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 97AAF8E0001; Thu, 16 Apr 2020 06:47:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81A388E00A2; Thu, 16 Apr 2020 06:47:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0140.hostedemail.com [216.40.44.140]) by kanga.kvack.org (Postfix) with ESMTP id 665B38E0001 for ; Thu, 16 Apr 2020 06:47:22 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2E2CD2816 for ; Thu, 16 Apr 2020 10:47:22 +0000 (UTC) X-FDA: 76713391524.03.pot94_617c2c591a32 X-HE-Tag: pot94_617c2c591a32 X-Filterd-Recvd-Size: 5641 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Apr 2020 10:47:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587034041; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nfpjA4Z9KH1cEGlN2CGAspzLvogXdOWrRg0QkkSUUkM=; b=fCUAz1FqN4GLbWFhFgPqkPALPIdiPEP2L5r4LpnY+hqWa/Bkq00RiUDN+NzshG3+vF4/42 WYddp9p72+Mm150icz245mkIkrBj0qLHrRgopT/RC4CEe4oXANkmjcBvuHeccptSJpHozp gLywKZSyuTNItIQThkoT7Ujn1qdJX6U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-190-uk7XGjooNvuOMtWoppfoxQ-1; Thu, 16 Apr 2020 06:47:19 -0400 X-MC-Unique: uk7XGjooNvuOMtWoppfoxQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0EC5D8018A2; Thu, 16 Apr 2020 10:47:18 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-9.ams2.redhat.com [10.36.114.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFC641036D03; Thu, 16 Apr 2020 10:47:15 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Michal Hocko , Baoquan He , Oscar Salvador , Pankaj Gupta , Mike Rapoport , Anshuman Khandual Subject: [PATCH RFC 2/2] mm/memory_hotplug: handle memblocks only with CONFIG_ARCH_KEEP_MEMBLOCK Date: Thu, 16 Apr 2020 12:47:07 +0200 Message-Id: <20200416104707.20219-3-david@redhat.com> In-Reply-To: <20200416104707.20219-1-david@redhat.com> References: <20200416104707.20219-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The comment in add_memory_resource() is stale: hotadd_new_pgdat() will no longer call get_pfn_range_for_nid(), as a hotadded pgdat will simply span no pages at all, until memory is moved to the zone/node via move_pfn_range_to_zone() - e.g., when onlining memory blocks. The only archs that care about memblocks for hotplugged memory (either for iterating over all system RAM or testing for memory validity) are arm64, s390x, and powerpc - due to CONFIG_ARCH_KEEP_MEMBLOCK. Without CONFIG_ARCH_KEEP_MEMBLOCK, we can simply stop messing with memblocks. For s390x, it seems to be fairly easy to avoid CONFIG_ARCH_KEEP_MEMBLOCK. arm64 could rework most code (esp., pfn_valid(), valid_phys_addr_range() and kexec_file_load()) to not require memblocks for hotplugged memory. E.g., as hotplugged memory has no holes and can be identified using !early_section(), arm64's variant of pfn_valid() could be reworked fairly easily to not require memblocks for hotadded memory. powerpc might be more involed. Cc: Andrew Morton Cc: Michal Hocko Cc: Baoquan He Cc: Oscar Salvador Cc: Pankaj Gupta Cc: Mike Rapoport Cc: Anshuman Khandual Signed-off-by: David Hildenbrand --- mm/Kconfig | 3 +++ mm/memory_hotplug.c | 13 +++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index c1acc34c1c35..a063fd9cdff4 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -136,6 +136,9 @@ config HAVE_FAST_GUP depends on MMU bool =20 +# Don't discard allocated memory used to track "memory" and "reserved" m= emblocks +# after early boot, so it can still be used to test for validity of memo= ry. +# Also, memblocks are updated with memory hot(un)plug. config ARCH_KEEP_MEMBLOCK bool =20 diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 9b15ce465be2..104285ee9ae8 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1020,13 +1020,9 @@ int __ref add_memory_resource(int nid, struct reso= urce *res) =20 mem_hotplug_begin(); =20 - /* - * Add new range to memblock so that when hotadd_new_pgdat() is called - * to allocate new pgdat, get_pfn_range_for_nid() will be able to find - * this new range and calculate total pages correctly. The range will - * be removed at hot-remove time. - */ +#ifdef CONFIG_ARCH_KEEP_MEMBLOCK memblock_add_node(start, size, nid); +#endif =20 ret =3D __try_online_node(nid, false); if (ret < 0) @@ -1075,7 +1071,9 @@ int __ref add_memory_resource(int nid, struct resou= rce *res) /* rollback pgdat allocation and others */ if (new_node) rollback_node_hotadd(nid); +#ifdef CONFIG_ARCH_KEEP_MEMBLOCK memblock_remove(start, size); +#endif mem_hotplug_done(); return ret; } @@ -1751,8 +1749,11 @@ static int __ref try_remove_memory(int nid, u64 st= art, u64 size) mem_hotplug_begin(); =20 arch_remove_memory(nid, start, size, NULL); + +#ifdef CONFIG_ARCH_KEEP_MEMBLOCK memblock_free(start, size); memblock_remove(start, size); +#endif __release_memory_resource(start, size); =20 try_offline_node(nid); --=20 2.25.1