From nobody Mon Feb 9 19:25:27 2026 Received: from sg-1-101.ptr.blmpb.com (sg-1-101.ptr.blmpb.com [118.26.132.101]) (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 EB3D42E8B9B for ; Thu, 25 Dec 2025 08:22:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.26.132.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766650976; cv=none; b=PA0ky/DEIpHERdgiqZbiLnUkbuxWcoiIRzm8R+YqzaYWKgPW+Jkiqzf3ObkoHTh67gXRNb7Eq88+VjZQVwEBfn1pCIdmkbsoNa580su5ErX+jAhfmQ/a7HI4/xaVoIYW9ELIKns+EQoHk+j+9HdMO+BNC4HwNwNvCYHBIN7Egcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766650976; c=relaxed/simple; bh=06rh8Joms93QDBNUBZb2zYmICCnqR+1B4l3kJbSTg1E=; h=Mime-Version:Subject:Message-Id:Date:Content-Type:To:From:Cc: In-Reply-To:References; b=a7K+1ZOiTqbpWEXY7KgiHvicTrWWnP1qm9XWMs0vZbzYdJjhOgitFJmgl7VQCwfphcr6CUvUvnu4AQpeLdCVnyMFcKnxs7DnruSq7qa0dfzAmukB8weipvP5TOItkPWtTG2BuIncJMEkOl7z2vikZDYQE54NO7FjOIViodoEK+w= 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=aazWuKjP; arc=none smtp.client-ip=118.26.132.101 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="aazWuKjP" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1766650961; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=8ttJk0p7bBgZoxWv2A6j13QFJkQF0RozkKQHOvbY4aE=; b=aazWuKjPLSwoZ+++jhTiQ1QBD2pTOYVlO5Rn7L25rQVSb2K1T8nOV7zZ+sJ36DF3KTyUlW PkCxTHJTF8G8GU/0iSLg1POffx9sZhgONYuG3v3qYK1SBGjwpnI7GMzygRC7yJTD6F0DXl 8D/cGNpJBpvFWrJi62qzkU5Ur1tLv9STdDvEJPgd8YIRg5w82wrwD5T6PiL+6Ep7yWOmuZ wUxv1jxqu5hKVNnl2FzIEnWyCaolqq0Zd5StYr2yZl9I+g/9XKerjNnDRef0ylO0TTRG5Y DN3Qd+obFfEtQLyn1ojFc40Of2QMvUtWTl+MgKonLBb8ET4Sfntphy2niVHiCQ== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Subject: [PATCH 6/8] mm/hugetlb: relocate the per-hstate struct kobject pointer Message-Id: <20251225082059.1632-7-lizhe.67@bytedance.com> Date: Thu, 25 Dec 2025 16:20:57 +0800 X-Mailer: git-send-email 2.45.2 Content-Transfer-Encoding: quoted-printable X-Original-From: lizhe.67@bytedance.com To: , , , , From: =?utf-8?q?=E6=9D=8E=E5=96=86?= Cc: , , In-Reply-To: <20251225082059.1632-1-lizhe.67@bytedance.com> X-Lms-Return-Path: References: <20251225082059.1632-1-lizhe.67@bytedance.com> Content-Type: text/plain; charset="utf-8" From: Li Zhe 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 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; =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 @@ -497,7 +501,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]; @@ -522,7 +526,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; @@ -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] =3D NULL; + nhs->items[idx].hstate_kobj =3D NULL; } =20 kobject_put(nhs->hugepages_kobj); @@ -561,7 +565,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