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=unavailable 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 0F66FC54FCB for ; Wed, 22 Apr 2020 15:54:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C50E820776 for ; Wed, 22 Apr 2020 15:54:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="F1u3E5q7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C50E820776 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 5181F8E000D; Wed, 22 Apr 2020 11:54:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49E978E0003; Wed, 22 Apr 2020 11:54:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 340BC8E000D; Wed, 22 Apr 2020 11:54:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0249.hostedemail.com [216.40.44.249]) by kanga.kvack.org (Postfix) with ESMTP id 0EC6A8E0003 for ; Wed, 22 Apr 2020 11:54:08 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B95555DF3 for ; Wed, 22 Apr 2020 15:54:07 +0000 (UTC) X-FDA: 76735937334.09.car26_7b4cbc0aec910 X-HE-Tag: car26_7b4cbc0aec910 X-Filterd-Recvd-Size: 6230 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Wed, 22 Apr 2020 15:54:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587570846; 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=JCIBxqQ98eHRn3Mzi9AyOTGU0OOVL2DFdvaTq6bk3Hg=; b=F1u3E5q7LuwkSc7PKr9NFaJpXZHPWK7jvWmRfwWGwCv8xTYx+I7kSFsSCA3biXlquqagu4 KZ5K96NAV59H1ixmUj0lU517JLXbaQDBCBrSflLrXIe+9JhcrUY2OveulOkg1QngPX1aaa J2w9QKyc152mq8pYWxqctBBbunMqT7E= 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-316-QZyRluTLNJel7kvn3BudXg-1; Wed, 22 Apr 2020 11:54:02 -0400 X-MC-Unique: QZyRluTLNJel7kvn3BudXg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ACCF41084424; Wed, 22 Apr 2020 15:54:01 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-57.ams2.redhat.com [10.36.114.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id E64CC5D706; Wed, 22 Apr 2020 15:53:59 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Pankaj Gupta , Andrew Morton , Michal Hocko , Baoquan He , Oscar Salvador Subject: [PATCH v1 1/2] mm/memory_hotplug: set node_start_pfn of hotadded pgdat to 0 Date: Wed, 22 Apr 2020 17:53:52 +0200 Message-Id: <20200422155353.25381-2-david@redhat.com> In-Reply-To: <20200422155353.25381-1-david@redhat.com> References: <20200422155353.25381-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: A hotadded node/pgdat will span no pages at all, until memory is moved to the zone/node via move_pfn_range_to_zone() -> resize_pgdat_range - e.g., when onlining memory blocks. We don't have to initialize the node_start_pfn to the memory we are adding. Especially, there is an inconsistency: - Hotplugging memory to a memory-less node with cpus: node_start_pf =3D=3D= 0 - Offlining and removing last memory from a node: node_start_pfn =3D=3D 0 - Hotplugging memory to a memory-less node without cpus: node_start_pfn != =3D0 As soon as memory is onlined, node_start_pfn is overwritten with the actual start. E.g., when adding two DIMMs but only onlining one of both, only that DIMM (with online memory blocks) is spanned by the node. Currently, the validity of node_start_pfn really is linked to node_spanned_pages !=3D 0. With node_spanned_pages =3D=3D 0 (e.g., before onlining memory), it has no meaning. So let's stop setting node_start_pfn, just to be overwritten via move_pfn_range_to_zone(). This avoids confusion when looking at the code, wondering which magic will be performed with the node_start_pfn in this function, when hotadding a pgdat. Acked-by: Pankaj Gupta Cc: Andrew Morton Cc: Michal Hocko Cc: Baoquan He Cc: Oscar Salvador Cc: Pankaj Gupta Signed-off-by: David Hildenbrand --- mm/memory_hotplug.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index b65e0d1c9812..4dc263d2525a 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -866,10 +866,9 @@ static void reset_node_present_pages(pg_data_t *pgda= t) } =20 /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLU= G */ -static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) +static pg_data_t __ref *hotadd_new_pgdat(int nid) { struct pglist_data *pgdat; - unsigned long start_pfn =3D PFN_DOWN(start); =20 pgdat =3D NODE_DATA(nid); if (!pgdat) { @@ -899,9 +898,8 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64= start) } =20 /* we can use NODE_DATA(nid) from here */ - pgdat->node_id =3D nid; - pgdat->node_start_pfn =3D start_pfn; + pgdat->node_start_pfn =3D 0; =20 /* init node's zones as empty zones, we don't have any present pages.*/ free_area_init_core_hotplug(nid); @@ -936,7 +934,6 @@ static void rollback_node_hotadd(int nid) /** * try_online_node - online a node if offlined * @nid: the node ID - * @start: start addr of the node * @set_node_online: Whether we want to online the node * called by cpu_up() to online a node without onlined memory. * @@ -945,7 +942,7 @@ static void rollback_node_hotadd(int nid) * 0 -> the node is already online * -ENOMEM -> the node could not be allocated */ -static int __try_online_node(int nid, u64 start, bool set_node_online) +static int __try_online_node(int nid, bool set_node_online) { pg_data_t *pgdat; int ret =3D 1; @@ -953,7 +950,7 @@ static int __try_online_node(int nid, u64 start, bool= set_node_online) if (node_online(nid)) return 0; =20 - pgdat =3D hotadd_new_pgdat(nid, start); + pgdat =3D hotadd_new_pgdat(nid); if (!pgdat) { pr_err("Cannot online node %d due to NULL pgdat\n", nid); ret =3D -ENOMEM; @@ -977,7 +974,7 @@ int try_online_node(int nid) int ret; =20 mem_hotplug_begin(); - ret =3D __try_online_node(nid, 0, true); + ret =3D __try_online_node(nid, true); mem_hotplug_done(); return ret; } @@ -1036,7 +1033,7 @@ int __ref add_memory_resource(int nid, struct resou= rce *res) */ memblock_add_node(start, size, nid); =20 - ret =3D __try_online_node(nid, start, false); + ret =3D __try_online_node(nid, false); if (ret < 0) goto error; new_node =3D ret; --=20 2.25.3