From: "Li Zhe" <lizhe.67@bytedance.com>
To: <muchun.song@linux.dev>, <osalvador@suse.de>, <david@kernel.org>,
<akpm@linux-foundation.org>, <fvdl@google.com>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
<lizhe.67@bytedance.com>
Subject: [PATCH v2 6/8] mm/hugetlb: relocate the per-hstate struct kobject pointer
Date: Wed, 7 Jan 2026 19:31:28 +0800 [thread overview]
Message-ID: <20260107113130.37231-7-lizhe.67@bytedance.com> (raw)
In-Reply-To: <20260107113130.37231-1-lizhe.67@bytedance.com>
Relocate the per-hstate struct kobject pointer from struct node_hstate
into a standalone structure.
This change prepares for a future patch that adds epoll support to the
“zeroable_hugepages” interface. When a huge folio is freed we must emit
an event, yet the freeing context may be atomic; therefore the
notification will be delegated to a workqueue. Extracting the struct
kobject pointer allows the workqueue callback to obtain it effortlessly.
Signed-off-by: Li Zhe <lizhe.67@bytedance.com>
---
mm/hugetlb_sysfs.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/mm/hugetlb_sysfs.c b/mm/hugetlb_sysfs.c
index 3f25a24e27cf..03b774b1191a 100644
--- a/mm/hugetlb_sysfs.c
+++ b/mm/hugetlb_sysfs.c
@@ -338,6 +338,10 @@ static int hugetlb_sysfs_add_hstate(struct hstate *h, struct kobject *parent,
#ifdef CONFIG_NUMA
static bool hugetlb_sysfs_initialized __ro_after_init;
+struct node_hstate_item {
+ struct kobject *hstate_kobj;
+};
+
/*
* node_hstate/s - associate per node hstate attributes, via their kobjects,
* with node devices in node_devices[] using a parallel array. The array
@@ -347,7 +351,7 @@ static bool hugetlb_sysfs_initialized __ro_after_init;
*/
struct node_hstate {
struct kobject *hugepages_kobj;
- struct kobject *hstate_kobjs[HUGE_MAX_HSTATE];
+ struct node_hstate_item items[HUGE_MAX_HSTATE];
};
static struct node_hstate node_hstates[MAX_NUMNODES];
@@ -501,7 +505,7 @@ static struct hstate *kobj_to_node_hstate(struct kobject *kobj, int *nidp)
struct node_hstate *nhs = &node_hstates[nid];
int i;
for (i = 0; i < HUGE_MAX_HSTATE; i++)
- if (nhs->hstate_kobjs[i] == kobj) {
+ if (nhs->items[i].hstate_kobj == kobj) {
if (nidp)
*nidp = nid;
return &hstates[i];
@@ -526,7 +530,7 @@ void hugetlb_unregister_node(struct node *node)
for_each_hstate(h) {
int idx = hstate_index(h);
- struct kobject *hstate_kobj = nhs->hstate_kobjs[idx];
+ struct kobject *hstate_kobj = nhs->items[idx].hstate_kobj;
if (!hstate_kobj)
continue;
@@ -534,7 +538,7 @@ void hugetlb_unregister_node(struct node *node)
sysfs_remove_group(hstate_kobj, &hstate_demote_attr_group);
sysfs_remove_group(hstate_kobj, &per_node_hstate_attr_group);
kobject_put(hstate_kobj);
- nhs->hstate_kobjs[idx] = NULL;
+ nhs->items[idx].hstate_kobj = NULL;
}
kobject_put(nhs->hugepages_kobj);
@@ -565,7 +569,7 @@ void hugetlb_register_node(struct node *node)
for_each_hstate(h) {
err = hugetlb_sysfs_add_hstate(h, nhs->hugepages_kobj,
- &nhs->hstate_kobjs[hstate_index(h)],
+ &nhs->items[hstate_index(h)].hstate_kobj,
&per_node_hstate_attr_group);
if (err) {
pr_err("HugeTLB: Unable to add hstate %s for node %d\n",
--
2.20.1
next prev parent reply other threads:[~2026-01-07 11:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-07 11:31 [PATCH v2 0/8] Introduce a huge-page pre-zeroing mechanism Li Zhe
2026-01-07 11:31 ` [PATCH v2 1/8] mm/hugetlb: add pre-zeroed framework Li Zhe
2026-01-07 11:31 ` [PATCH v2 2/8] mm/hugetlb: convert to prep_account_new_hugetlb_folio() Li Zhe
2026-01-07 11:31 ` [PATCH v2 3/8] mm/hugetlb: move the huge folio to the end of the list during enqueue Li Zhe
2026-01-07 11:31 ` [PATCH v2 4/8] mm/hugetlb: introduce per-node sysfs interface "zeroable_hugepages" Li Zhe
2026-01-07 11:31 ` [PATCH v2 5/8] mm/hugetlb: simplify function hugetlb_sysfs_add_hstate() Li Zhe
2026-01-07 11:31 ` Li Zhe [this message]
2026-01-07 11:31 ` [PATCH v2 7/8] mm/hugetlb: add epoll support for interface "zeroable_hugepages" Li Zhe
2026-01-07 11:31 ` [PATCH v2 8/8] mm/hugetlb: limit event generation frequency of function do_zero_free_notify() Li Zhe
2026-01-07 16:19 ` [PATCH v2 0/8] Introduce a huge-page pre-zeroing mechanism Andrew Morton
2026-01-09 6:05 ` Muchun Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260107113130.37231-7-lizhe.67@bytedance.com \
--to=lizhe.67@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=fvdl@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox