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 3424FC54EE9 for ; Tue, 13 Sep 2022 09:57:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BECF8D0001; Tue, 13 Sep 2022 05:57:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76EC36B0073; Tue, 13 Sep 2022 05:57:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6364E8D0001; Tue, 13 Sep 2022 05:57:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 50F9D6B0072 for ; Tue, 13 Sep 2022 05:57:31 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2ADFC14042B for ; Tue, 13 Sep 2022 09:57:31 +0000 (UTC) X-FDA: 79906609902.11.DA30762 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf11.hostedemail.com (Postfix) with ESMTP id A33D84008E for ; Tue, 13 Sep 2022 09:57:29 +0000 (UTC) Content-Type: text/plain; charset=utf-8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1663063047; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r1q0gozH1CGMtQTZP+/A3s5oBG5/juquDr/kG+a4ih4=; b=da/832vr+4+Fd+hy0AkN9SdxZMSHXrOgsCZHiwKPf7uMt1bYrtaPJg+zJ/SdI1Om0GFoLL Z5OcdzG6MQyNXKplyutHDK4i9El5HLaEYnXKKU58ceANILY5hEJe+MzD65FawiHRkJ4uqK qznlprmsxFJ24juSypky/pVg0PgLF3I= MIME-Version: 1.0 Subject: Re: [PATCH v3] mm: hugetlb: eliminate memory-less nodes handling X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: Date: Tue, 13 Sep 2022 17:57:15 +0800 Cc: Muchun Song , Greg KH , rafael@kernel.org, Mike Kravetz , Andrew Morton , Oscar Salvador , ying.huang@intel.com, aneesh.kumar@linux.ibm.com, David Rientjes , linux-kernel@vger.kernel.org, Linux MM Content-Transfer-Encoding: quoted-printable Message-Id: References: <20220908075826.37094-1-songmuchun@bytedance.com> To: David Hildenbrand X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="da/832vr"; spf=pass (imf11.hostedemail.com: domain of muchun.song@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=muchun.song@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663063049; a=rsa-sha256; cv=none; b=sgaV8cDhqMiFzYfezp9HoEw188Cwo2AVP+RZul9o9/Up06JFtrHki5d1xIxQiNPTeygyQ2 Xo/pqR5xOuG0CA58x73sIaPJvULBvKogzwSTmuLG3joxtBScdp6cHxTv0WFGlWQOU3BGrB j4X6BwWFyKTfqPpyyiUyDxFzErhCBmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663063049; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=r1q0gozH1CGMtQTZP+/A3s5oBG5/juquDr/kG+a4ih4=; b=5w/P49kneOc2J3SbF+i2C6pxtm7GxeLKKR9GPraoCMXIGNVI1ds9VHmLiLph+HfTxupshA sQ288hr5/QbyJLghoVjBD92qTPTt1lDDv4Afy047ZJQFhbeyWig78lDoubnw1Ae0B3w2WQ CJE6CZz8JALRfU5awGDABTQ9WnLtSys= Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="da/832vr"; spf=pass (imf11.hostedemail.com: domain of muchun.song@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=muchun.song@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspamd-Server: rspam12 X-Stat-Signature: r1hcikjnstjad4y88uh7qckg6rzdd6ne X-Rspamd-Queue-Id: A33D84008E X-Rspam-User: X-HE-Tag: 1663063049-198377 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: > On Sep 8, 2022, at 20:21, David Hildenbrand wrote: >=20 > On 08.09.22 09:58, Muchun Song wrote: >> The memory-notify-based approach aims to handle meory-less nodes, = however, it just adds >> the complexity of code as pointed by David in thread [1]. The = handling of memory-less >> nodes is introduced by commit 4faf8d950ec4 ("hugetlb: handle memory = hot-plug events"). >> =46rom its commit message, we cannot find any necessity of handling = this case. So, we can >> simply register/unregister sysfs entries in = register_node/unregister_node to simlify the >> code. >> BTW, hotplug callback added because in hugetlb_register_all_nodes() = we register sysfs >> nodes only for N_MEMORY nodes, seeing commit 9b5e5d0fdc91, which said = it was a preparation >> for handling memory-less nodes via memory hotplug. Since we want to = remove memory hotplug, >> so make sure we only register per-node sysfs for online (N_ONLINE) = nodes in >> hugetlb_register_all_nodes(). >> = https://lore.kernel.org/linux-mm/60933ffc-b850-976c-78a0-0ee6e0ea9ef0@redh= at.com/ [1] >> Suggested-by: David Hildenbrand >> Signed-off-by: Muchun Song >> --- >> v3: >> - Fix 'struct node' is not declared reported by LTP. >> v2: >> - Move declaration of function related to hugetlb to hugetlb.h = (David). >> - Introduce hugetlb_sysfs_initialized() and call it from = hugetlb_sysfs_init() (David). >> - Move hugetlb_register_all_nodes() into hugetlb_sysfs_init() = (David). >> - Fix implicit-function-declaration reported by LKP. >> - Register per-node sysfs for online (N_ONLINE) nodes instead of = N_MEMORY (Aneesh). >> drivers/base/node.c | 8 +++-- >> include/linux/hugetlb.h | 14 +++++++++ >> mm/hugetlb.c | 81 = ++++++++++++++++++++++--------------------------- >> 3 files changed, 57 insertions(+), 46 deletions(-) >=20 >=20 >=20 >> --- a/mm/hugetlb.c >> +++ b/mm/hugetlb.c >> @@ -3880,24 +3880,14 @@ static int hugetlb_sysfs_add_hstate(struct = hstate *h, struct kobject *parent, >> return 0; >> } >> -static void __init hugetlb_sysfs_init(void) >> -{ >> - struct hstate *h; >> - int err; >> - >> - hugepages_kobj =3D kobject_create_and_add("hugepages", mm_kobj); >> - if (!hugepages_kobj) >> - return; >> +#ifdef CONFIG_NUMA >> +static bool hugetlb_sysfs_initialized __ro_after_init; >> - for_each_hstate(h) { >> - err =3D hugetlb_sysfs_add_hstate(h, hugepages_kobj, >> - hstate_kobjs, = &hstate_attr_group); >> - if (err) >> - pr_err("HugeTLB: Unable to add hstate %s", = h->name); >> - } >> +static inline void hugetlb_mark_sysfs_initialized(void) >> +{ >> + hugetlb_sysfs_initialized =3D true; >> } >=20 > Do we really need a separate function for this? Why not simply always = set that from hugetlb_sysfs_init() ? I can remove this helper. >=20 > I'm also not sure if we really want to optimize out one variable for = !CONFIG_NUMA. Either is fine to me. I think the optimization does not bring any = complexity. So I=E2=80=99ll keep it the same in the next version unless anyone is = against this. >=20 > Anyhow, in general >=20 > Acked-by: David Hildenbrand Thanks David. >=20 >=20 > --=20 > Thanks, >=20 > David / dhildenb >=20