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 2D739C54EE9 for ; Thu, 8 Sep 2022 12:21:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 72A5C6B0072; Thu, 8 Sep 2022 08:21:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D9DB8D0001; Thu, 8 Sep 2022 08:21:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57C926B0074; Thu, 8 Sep 2022 08:21:39 -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 495E26B0072 for ; Thu, 8 Sep 2022 08:21:39 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 192E51603BB for ; Thu, 8 Sep 2022 12:21:39 +0000 (UTC) X-FDA: 79888829118.17.17B7953 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id A629710007F for ; Thu, 8 Sep 2022 12:21:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662639697; 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=c1bOOozDQ+6EDEHi9rJz7Dh4D3HKy76AxnObw13WaRU=; b=aeQmwvwNX/uPYcPzG+WRmB7sUjSbVx1PAtnmRlO1QjBWxubJW7ISN9XNekFhE9eVMlwu7C z5Z0hAHIS7v7/ycCL0Bo2zYzcIuv7gNhL+60cpN0cb7nkKjSfeci/in15HK1WMj3NW2Uep 3atCt7X6jKjZtiX63EtVatMfcQbXC9I= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-110-gpjoFi0aPF6Th0BWSJK_bw-1; Thu, 08 Sep 2022 08:21:36 -0400 X-MC-Unique: gpjoFi0aPF6Th0BWSJK_bw-1 Received: by mail-wm1-f71.google.com with SMTP id bg2-20020a05600c3c8200b003b33080cff8so307237wmb.0 for ; Thu, 08 Sep 2022 05:21:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date; bh=c1bOOozDQ+6EDEHi9rJz7Dh4D3HKy76AxnObw13WaRU=; b=lr0luoUhD4kfFjDgliYDdo+rFgTsZN7GDQz5srvezx5pBH92lDAGCsjjjriWY+mkcW PCr72Uc4cepsdI7aoJNc/GC1L4jRjrqTSWdI0ZDB5EMptLnphXHU6HdV4+bItO955N17 Jx69Ea1xmfAC5Hn6XexQWqkVkx+ZpkJ4niOI96WPekKvXZGwerv9hpaP1G1RlcD7M92m wEgszIwfC5hajdMMIa7PYbY28wpbAyoQ3y0Jep79RR6D8V7qRQ2MYwjOQbCLtG1MeyjH e6+kpYswCTk+PXZ/AxBiHoNAvv/BNKEARTeOFDstv3o9PSsgzETGWz48iKDNDPPfJPn9 7wuw== X-Gm-Message-State: ACgBeo3zRkuFONQzVDvx6SZMBctL+Y+a89FdwF0XglgUQKx8/hXbLAQ5 c8iMQsju36ceh6bLgqQzJy/J2a/ZQDvpbF5jZVtY7S6NkaAiQJS9ORUDO9mg1ioZIg6ZMATIj93 XA/gtXGy4+X4= X-Received: by 2002:a05:6000:1564:b0:226:dece:5630 with SMTP id 4-20020a056000156400b00226dece5630mr5182613wrz.294.1662639695866; Thu, 08 Sep 2022 05:21:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR4qTefM7C3hOHDgloIGu2LGoG5IyZ+iOfAi4b8sZRRTGe5uPr30mRtiOdC5OIy+Gk9Cj4U/Yg== X-Received: by 2002:a05:6000:1564:b0:226:dece:5630 with SMTP id 4-20020a056000156400b00226dece5630mr5182595wrz.294.1662639695579; Thu, 08 Sep 2022 05:21:35 -0700 (PDT) Received: from ?IPV6:2003:d8:2f0d:ba00:c951:31d7:b2b0:8ba0? (p200300d82f0dba00c95131d7b2b08ba0.dip0.t-ipconnect.de. [2003:d8:2f0d:ba00:c951:31d7:b2b0:8ba0]) by smtp.gmail.com with ESMTPSA id m18-20020adff392000000b00228b3ff1f5dsm16175779wro.117.2022.09.08.05.21.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Sep 2022 05:21:35 -0700 (PDT) Message-ID: Date: Thu, 8 Sep 2022 14:21:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 To: Muchun Song , gregkh@linuxfoundation.org, rafael@kernel.org, mike.kravetz@oracle.com, akpm@linux-foundation.org, osalvador@suse.de, ying.huang@intel.com, aneesh.kumar@linux.ibm.com, rientjes@google.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, muchun.song@linux.dev References: <20220908075826.37094-1-songmuchun@bytedance.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v3] mm: hugetlb: eliminate memory-less nodes handling In-Reply-To: <20220908075826.37094-1-songmuchun@bytedance.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662639698; a=rsa-sha256; cv=none; b=CSjqZ5P1UQIMBodBODe6ICAlhkhevlmPvBC4KGQwU/iucCUXr+olA5BJ4DH2imAX3S+0KI h7bbn/X0XSNrlZK+hwXigucdhDYmSuIvuEShaYiFiVjKvC0E+ccV0kRaZ6kiIivDRSPvkK phdPuRrpPH9amo0WMzJcWF3bDnJUe6k= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=aeQmwvwN; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662639698; 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=c1bOOozDQ+6EDEHi9rJz7Dh4D3HKy76AxnObw13WaRU=; b=csT18FQzh+9FW6CZQCT9WQ8HM2QSn+yxa00bEZ6rLZQqWvjXRXf7gXYzls7zBJZbPgCz4j fg5zUYqdSDLheEAt9qomUKLSeWqU2iMe88zfZK6wl6dlAwyrAIV8pVp69F+qD3lk/s0Y8y bWZplmMQA/gQXFesje5x1jcIukk89y0= X-Stat-Signature: id3tkw6tm7bi3f4wiqx9su6gcpnzcixm X-Rspam-User: X-Rspamd-Queue-Id: A629710007F X-Rspamd-Server: rspam07 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=aeQmwvwN; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1662639698-817925 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 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"). > From 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@redhat.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(-) > --- 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 = 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 = 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 = true; > } Do we really need a separate function for this? Why not simply always set that from hugetlb_sysfs_init() ? I'm also not sure if we really want to optimize out one variable for !CONFIG_NUMA. Anyhow, in general Acked-by: David Hildenbrand -- Thanks, David / dhildenb