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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC6DECD11C2 for ; Wed, 10 Apr 2024 03:35:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20DBA6B0082; Tue, 9 Apr 2024 23:35:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 196E36B0083; Tue, 9 Apr 2024 23:35:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 037A56B0085; Tue, 9 Apr 2024 23:35:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D7C7E6B0082 for ; Tue, 9 Apr 2024 23:35:44 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4EB604061B for ; Wed, 10 Apr 2024 03:35:44 +0000 (UTC) X-FDA: 81992207808.04.18DB792 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 51B7D120005 for ; Wed, 10 Apr 2024 03:35:42 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Y/zSn6rX"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712720142; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9ISipRl2/c7y+xtoTNwmy7RWvYoe0ftI8x+5f7xjKD8=; b=C3XLDHgSjfDEJzbyJpEVZuxGSZika11FqTUiC7NCQNBuDubbchmadGCSGYCvBPbIxVcGqS w+Sj9KjkG+iSn6XQtMeEJPBTy8UkBGqNW7eLqZqiX3Ovls5vsrITfEhHuEax4W2R9vVqcK UfhpG1+uppas5+ww5f/h9rgiPygf7AU= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Y/zSn6rX"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712720142; a=rsa-sha256; cv=none; b=P1EclJ561gLXKrFTu0fd53TDaVkZhP+o9+s4zxlXpYckAgHChOLmGzBi4eydU4dXc/kxDT B8dcK301n6W02Q6KnwVGqJS1P7mgx7t+bMIg6RTaD92W38env8hRx9qtOfn3EtCsKKm7Ks Kf1OAqWJYTn8EtO4nik95LlRin0+pMk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712720141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9ISipRl2/c7y+xtoTNwmy7RWvYoe0ftI8x+5f7xjKD8=; b=Y/zSn6rXb25+P0iNpU/Nh8z02/ocM/GIebOMoApDyNPS2ByJ0/jV0gVDushfIt0fp9Um6p YMb5XYPznnYbLCSun68Cadr8irYuQ/UDLO0YgF/KVpNcu1OiqtmYOuhtftwIqlQtBAvzVG N9eKHdcjvnCJ/FNAwGuaNHj8In4cfFE= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-696-0QDw3M7pNVq1wl54wuRaLQ-1; Tue, 09 Apr 2024 23:35:37 -0400 X-MC-Unique: 0QDw3M7pNVq1wl54wuRaLQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BD65C1C05190; Wed, 10 Apr 2024 03:35:36 +0000 (UTC) Received: from localhost (unknown [10.72.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 065052026D1F; Wed, 10 Apr 2024 03:35:35 +0000 (UTC) Date: Wed, 10 Apr 2024 11:35:29 +0800 From: Baoquan He To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, rppt@kernel.org, mgorman@suse.de Subject: Re: [PATCH v2 2/7] mm/init: remove the unnecessary special treatment for memory-less node Message-ID: References: <20240326061134.1055295-1-bhe@redhat.com> <20240326061134.1055295-3-bhe@redhat.com> MIME-Version: 1.0 In-Reply-To: <20240326061134.1055295-3-bhe@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 51B7D120005 X-Stat-Signature: duzquxnh5ufazwuwa7n3gfp8xm7sai68 X-HE-Tag: 1712720142-473738 X-HE-Meta: U2FsdGVkX1+vrtIbHrxrA6V6n/v+L709N8YzcF7U4ho4kw867pBgBBbE3Qfw+JopygOX59QtLRBPPP6O12Lx/aUDPwSHMEG1Py8tgIp4TUqMU50p1DqAeeMjXYTy33ruPjjbMYYUOTGKxiYx76ysuRRN+ylPJUshQKqBCrQJJx935BuJWW96NTtzMy3fEmRHZ3sILcpFuzRV7QZMZgUH4+d/21Gvkovlg0OHJiOd/lXwOdTkzKGUx7HVRX+ciwzar8OZ5KUcYdtjYO50dI7JMvzB3+GPu5YS1XE97tXNjkMdWbKtaazx5xVLRUe3/gqkTMBWyId7+aMQosEgOcVKGuZ5G+geF3sZofaXowxaQ1v0db/lAidGGFHq/7NdgukHhUTjSZ/16z2edulCjUGrcrd7m6sAU2pMPK7v4aysWBRunxiga4W6gACTgeMpRtsvFdKzUxxcS0RSezkykTQxBCb+awPYzwQqHYyc2xjb0C+8BLx5N0zbvCHoqy0ACrX703PEZI/JMX2tgnGiGA+fZ+U51pvvsimnFQHqtK1s2HILi05aR/RlsFdXWpMSRmq00LRMAuO1Z2LCdG3zlcQo2acnExhDlSMos7j+kM87FiqB05dm7/PWuI8IU5VUB7fEIzE2UWcX3+vqU1qydNYRPqV1Z1axWjJrIfu8D6EMoaUEA2fA44m014sKVixKA2otV/tA5AH4LuCgCn3U5CQkioTIyQMBAkRlXOmzIQTaYzkjjTocYigTgJt29sEH4RufxrKKMYLvzqMN+26yA8slrwdRKA8SxttwVy+q4zqSvduZhilvz95rxaxtrix+aGpevzNQHLG3W9ItGFLsnB/JWZbAqYNOcOUeUp9NwvcfdyjZg+rfmsYwsov5V2of6GtsZzakDOc4R9P66YfUamjBsS7ZofRUf43pKPGdA0lILYWGKCmFJgwXkprQ3oi/CcWf+ZIHC+MAUs+3LJNwbur 49tMinZf I879ogF5LoA/2zzUUqIviUdLKqWuhrbRczH4XnSch5eVpCKEpfLlqbKJzz2lkr4E6/BKRkbUvJ5wH6cBGizW9ry886FTjw0lmMqxWKcOFGsGExUKAf71Sl7TzS1slqkWwjazT9EvKae9KOHNyJQ2IegU/x3mR4VDZH4JZ4itqHE47afuwg8N0dX+La99ArGi/0yjeSnYg/Iu3l34tDUCBnlXTuy5bDNA2+MNL 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: List-Subscribe: List-Unsubscribe: Because memory-less node's ->node_present_pages and its zone's ->present_pages are all 0, the judgement before calling node_set_state() to set N_MEMORY, N_HIGH_MEMORY, N_NORMAL_MEMORY for node is enough to skip memory-less node. The 'continue;' statement inside for_each_node() loop of free_area_init() is gilding the lily. Here, remove the special handling to make memory-less node share the same code flow as normal node. And also rephrase the code comments above the 'continue' statement and move them above above line 'if (pgdat->node_present_pages)'. Signed-off-by: Baoquan He --- v1->v2: - As Mike suggested, the old code comments above the 'continue' statement is still useful for easier understanding code and system behaviour. So rephrase and move them above line 'if (pgdat->node_present_pages)'. Thanks to Mike. mm/mm_init.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index 2016ca8031e9..32ede966e609 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1834,28 +1834,23 @@ void __init free_area_init(unsigned long *max_zone_pfn) panic("Cannot allocate %zuB for node %d.\n", sizeof(*pgdat), nid); arch_refresh_nodedata(nid, pgdat); - free_area_init_node(nid); - - /* - * We do not want to confuse userspace by sysfs - * files/directories for node without any memory - * attached to it, so this node is not marked as - * N_MEMORY and not marked online so that no sysfs - * hierarchy will be created via register_one_node for - * it. The pgdat will get fully initialized by - * hotadd_init_pgdat() when memory is hotplugged into - * this node. - */ - continue; } pgdat = NODE_DATA(nid); free_area_init_node(nid); - /* Any memory on that node */ - if (pgdat->node_present_pages) + /* + * No sysfs hierarcy will be created via register_one_node() + *for memory-less node because here it's not marked as N_MEMORY + *and won't be set online later. The benefit is userspace + *program won't be confused by sysfs files/directories of + *memory-less node. The pgdat will get fully initialized by + *hotadd_init_pgdat() when memory is hotplugged into this node. + */ + if (pgdat->node_present_pages) { node_set_state(nid, N_MEMORY); - check_for_memory(pgdat); + check_for_memory(pgdat); + } } calc_nr_kernel_pages(); -- 2.41.0