From nobody Tue Feb 10 03:45:01 2026 Received: from sg-1-100.ptr.blmpb.com (sg-1-100.ptr.blmpb.com [118.26.132.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5064A54723 for ; Wed, 7 Jan 2026 11:33:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.26.132.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767785640; cv=none; b=rnA/VhhY6OkOVZyuzaAkXkehpCkgp05LuQeQARz86TVnN1cFz3KmW0CVIxHpu3IOIxSwzVKYBgEoGSNmIbhGRaItw2JwZjXJIksFKyECTZso3NEFvXFyepD1CIkmCi5dq3kD6faHJvDwpl8duj+v63WeLSbqYAzSP+SDx13F/hk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767785640; c=relaxed/simple; bh=2DNV6OIRO0yNVj81jfDIqsXe19Agb673z0F3uqObgKg=; h=Subject:Date:In-Reply-To:Mime-Version:References:To:Cc:From: Message-Id:Content-Type; b=r6GufcSSZOCAoTYoH8dBmuyav6qtbhUU2eVNhtX+4/WWIsDKPS903jSv2K1CY1GIfZ6GPVpHhIRUqL5Ya4hnT2tgXY1Zid55+8ouLzWhZyBik31bYP24cJ7OZ24j+QLjo6Od18IhDSmxnG8omwAvsUW/dFGyx5VBQ2t01BFEr7k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=MEWQooMw; arc=none smtp.client-ip=118.26.132.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="MEWQooMw" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1767785634; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=vqgHPcDteXeYtkcevndtOM5gbTYMZ0McWPYXT6sbL+I=; b=MEWQooMwwf387pl7+RcGoJSDMD39jWPto0yhnWCCSFVjoDtsKPQ4G5hMoSIImK2jLeVHI4 EAevE6s3DtUImwb2xvXnZD2xmYjsfz9ApykwzFtODPNCzMYX/QH0aKGKDbWxQZj1d921ql V2+XLpBPBWbHrgI1K9TFLLabhVfEE93EFBi6DgT+fFRGdCNyiBgTJDbDO92YFkcUEwh9A8 fAZvdx1uQ5FjJVS499gRpTe9bc019rf3wousP6eylUmrAB0fyMCOp4hXmROmIAq5XK9kIx 0u/vvkvIf6QZnDiGehDMowsTkr+nkgILj6hhCfju/jIenLYzuixD1OPbOVNQNA== Subject: [PATCH v2 6/8] mm/hugetlb: relocate the per-hstate struct kobject pointer Date: Wed, 7 Jan 2026 19:31:28 +0800 X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260107113130.37231-1-lizhe.67@bytedance.com> Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260107113130.37231-1-lizhe.67@bytedance.com> X-Lms-Return-Path: To: , , , , Cc: , , From: "Li Zhe" Message-Id: <20260107113130.37231-7-lizhe.67@bytedance.com> X-Original-From: Li Zhe Content-Type: text/plain; charset="utf-8" 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 =E2=80=9Czeroable_hugepages=E2=80=9D 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 --- 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; =20 +struct node_hstate_item { + struct kobject *hstate_kobj; +}; + /* * node_hstate/s - associate per node hstate attributes, via their kobject= s, * 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]; =20 @@ -501,7 +505,7 @@ static struct hstate *kobj_to_node_hstate(struct kobjec= t *kobj, int *nidp) struct node_hstate *nhs =3D &node_hstates[nid]; int i; for (i =3D 0; i < HUGE_MAX_HSTATE; i++) - if (nhs->hstate_kobjs[i] =3D=3D kobj) { + if (nhs->items[i].hstate_kobj =3D=3D kobj) { if (nidp) *nidp =3D nid; return &hstates[i]; @@ -526,7 +530,7 @@ void hugetlb_unregister_node(struct node *node) =20 for_each_hstate(h) { int idx =3D hstate_index(h); - struct kobject *hstate_kobj =3D nhs->hstate_kobjs[idx]; + struct kobject *hstate_kobj =3D nhs->items[idx].hstate_kobj; =20 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] =3D NULL; + nhs->items[idx].hstate_kobj =3D NULL; } =20 kobject_put(nhs->hugepages_kobj); @@ -565,7 +569,7 @@ void hugetlb_register_node(struct node *node) =20 for_each_hstate(h) { err =3D 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", --=20 2.20.1