Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6372305rwn; Tue, 13 Sep 2022 03:22:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Q0fhZcOSa2mO8usOydRvBA36DW6lGZcoocT8Db1Fn6kNNRxTpPIaXS0/N8yFLxOuEW4De X-Received: by 2002:a65:6e9a:0:b0:435:6009:4b62 with SMTP id bm26-20020a656e9a000000b0043560094b62mr23583569pgb.596.1663064540011; Tue, 13 Sep 2022 03:22:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663064540; cv=none; d=google.com; s=arc-20160816; b=OeTqmzARQOGISZG89Iw7d9+6WeIZp2HtwS05MDSbJDSoZfjSP1WChoaCfz/dp0c40m SAnK2ACb99S0XcxXJKvw9BETU+hdqtE3+xnn+sX4B0jUm7acWJF13XP93K9UbkHNqz29 WvGXLOD8yih3DbtStjvJ8glHpg7qI8hATRtJIk2EqTuwXyTpyvc5m/ETfKhfeaZbZtV3 w6yWgQkouzKq2m61gse8nWDK4J4uU0Axa9P1awvf5VLplYEZbDF1hBJM4x47fNrCfP1T UkIm1sV1uEncsIcMLzGvzWzBGdbuoYYdDN9+yWuInpWafj5QMKmEorGUZj756CmMd4jH SVpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=r1q0gozH1CGMtQTZP+/A3s5oBG5/juquDr/kG+a4ih4=; b=BOMBsYRM9e8k3RMvG/eZBwB2JNo4hkC7XM9/1aD3QF7hd7NI2Mqbtak9j8sw0Itdde ovOE5WgwxlqZyCpVaCzhPl+StMJGRN/mgs7CflYtf8S2512DEayRfPEtxpg4ZZ5lYBxe 5QOf3LkW/i6vXw9f7RBT9CK5Yjaput/+NVobhjVZTFYqNLh5dPDQ5TtFRMHCRr7B6cU/ b20K55JjN5fakocDJ8jF+Sd/ou0wDy8ax/5LRSlCH0yi36GeGpfKUFmUMfDsPCSjmI2+ LrpnCZJlGPv0cATbSdeAAp32RdGzrAujyr+Y369oHKZwAC6CWilizDNwaH+Qjd+OPRnT k/XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="da/832vr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a63e746000000b0041a11845a19si11257579pgk.703.2022.09.13.03.22.06; Tue, 13 Sep 2022 03:22:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="da/832vr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230293AbiIMJ5d (ORCPT + 99 others); Tue, 13 Sep 2022 05:57:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbiIMJ5b (ORCPT ); Tue, 13 Sep 2022 05:57:31 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7B744B4B5 for ; Tue, 13 Sep 2022 02:57:29 -0700 (PDT) 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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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