[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251225082059.1632-7-lizhe.67@bytedance.com>
Date: Thu, 25 Dec 2025 16:20:57 +0800
From: 李喆 <lizhe.67@...edance.com>
To: <muchun.song@...ux.dev>, <osalvador@...e.de>, <david@...nel.org>,
<akpm@...ux-foundation.org>, <fvdl@...gle.com>
Cc: <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
<lizhe.67@...edance.com>
Subject: [PATCH 6/8] mm/hugetlb: relocate the per-hstate struct kobject pointer
From: Li Zhe <lizhe.67@...edance.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@...edance.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 87dcd3038abc..08ad39d3e022 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];
@@ -497,7 +501,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];
@@ -522,7 +526,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;
@@ -530,7 +534,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);
@@ -561,7 +565,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
Powered by blists - more mailing lists