From nobody Tue Feb 10 00:58:40 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 4AD1630B50A for ; Thu, 25 Dec 2025 08:22:35 +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=1766650958; cv=none; b=N/kzkc8ccQyyhab4DMljtZKtkO1CRIrHjbT5hfTgDzALxjGpCx82mXHpefeDuVAIhRodjqPnTLitkCO8GWmZEf1T72OcWqaJXeDjw5hI80nRqiKH44VtJNqUFscU0ecXPo9UDG9pRJHNUA34TKdN2nQIHCnIClI87lsrkUEeACM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766650958; c=relaxed/simple; bh=KNT3yuKR2PFsAjZaEUwiJhekKytBLPgdBQY+cLK2jrY=; h=Subject:Content-Type:To:Message-Id:In-Reply-To:References:From: Date:Mime-Version:Cc; b=in5ludMocJYcRmymtcuRof0+rlbaQ53sSWtx7BhE1kQ8LXMdYrFemXO6GHV53tXGYtwFIwMgDNRjGhVPlLo90vLeozOTQHh333Dkx0vNVWhUOf+MxWADGye1y3aHpp5RcPmKTElQ5XPLtVwtgnIs9QMzH5UCDoWwCn2+MMaPet8= 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=h6o3xmqD; 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="h6o3xmqD" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1766650950; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=x60aj7gnZL//ydPkRsAnsXmDZpL6pv5KHgFx5n1s35I=; b=h6o3xmqDft/dybsqQitwfvYQlBt/IiZOxNOz3EpMcNQTS3pnD/vVZf8XiL8YqDyslnDCCl G6+MqlP+yAZy1ZxyLFv4oPJNbCTYC5rlT+yzQciIzpTDSLbKJURJBuHUsgTiD/xweEvYdm Rj4pLj1BEat7/ZLuow8LaVSGEvuBTa1gp/Dux3bRQnmXD2opUbHtUh+5XjebSNroRmksKt BQW4h9U459+R3+QvLdlOgUd/gmH7iMWp8JJgbKTilqiuAvSwHq9NWban5oaFCKyQrAL5zJ 0wgqfsA0xD/u4C//nlvAtwzleKVl7OLJ6GQlITQpdleTd5Ty3BcSHItX8mx0VA== Subject: [PATCH 5/8] mm/hugetlb: simplify function hugetlb_sysfs_add_hstate() X-Original-From: lizhe.67@bytedance.com X-Mailer: git-send-email 2.45.2 To: , , , , Message-Id: <20251225082059.1632-6-lizhe.67@bytedance.com> In-Reply-To: <20251225082059.1632-1-lizhe.67@bytedance.com> References: <20251225082059.1632-1-lizhe.67@bytedance.com> X-Lms-Return-Path: From: =?utf-8?q?=E6=9D=8E=E5=96=86?= Date: Thu, 25 Dec 2025 16:20:56 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Cc: , , Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Li Zhe The third parameter of hugetlb_sysfs_add_hstate() is currently an array of struct kobject *, yet the function only ever uses a single element. This patch narrows the argument to a pointer to that specific member, eliminating the unused array. Signed-off-by: Li Zhe --- mm/hugetlb_sysfs.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/mm/hugetlb_sysfs.c b/mm/hugetlb_sysfs.c index 8c3e433209c3..87dcd3038abc 100644 --- a/mm/hugetlb_sysfs.c +++ b/mm/hugetlb_sysfs.c @@ -304,31 +304,30 @@ static const struct attribute_group hstate_demote_att= r_group =3D { }; =20 static int hugetlb_sysfs_add_hstate(struct hstate *h, struct kobject *pare= nt, - struct kobject **hstate_kobjs, + struct kobject **hstate_kobj, const struct attribute_group *hstate_attr_group) { int retval; - int hi =3D hstate_index(h); =20 - hstate_kobjs[hi] =3D kobject_create_and_add(h->name, parent); - if (!hstate_kobjs[hi]) + *hstate_kobj =3D kobject_create_and_add(h->name, parent); + if (!*hstate_kobj) return -ENOMEM; =20 - retval =3D sysfs_create_group(hstate_kobjs[hi], hstate_attr_group); + retval =3D sysfs_create_group(*hstate_kobj, hstate_attr_group); if (retval) { - kobject_put(hstate_kobjs[hi]); - hstate_kobjs[hi] =3D NULL; + kobject_put(*hstate_kobj); + *hstate_kobj =3D NULL; return retval; } =20 if (h->demote_order) { - retval =3D sysfs_create_group(hstate_kobjs[hi], + retval =3D sysfs_create_group(*hstate_kobj, &hstate_demote_attr_group); if (retval) { pr_warn("HugeTLB unable to create demote interfaces for %s\n", h->name); - sysfs_remove_group(hstate_kobjs[hi], hstate_attr_group); - kobject_put(hstate_kobjs[hi]); - hstate_kobjs[hi] =3D NULL; + sysfs_remove_group(*hstate_kobj, hstate_attr_group); + kobject_put(*hstate_kobj); + *hstate_kobj =3D NULL; return retval; } } @@ -562,8 +561,8 @@ 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, - &per_node_hstate_attr_group); + &nhs->hstate_kobjs[hstate_index(h)], + &per_node_hstate_attr_group); if (err) { pr_err("HugeTLB: Unable to add hstate %s for node %d\n", h->name, node->dev.id); @@ -610,7 +609,7 @@ void __init hugetlb_sysfs_init(void) =20 for_each_hstate(h) { err =3D hugetlb_sysfs_add_hstate(h, hugepages_kobj, - hstate_kobjs, &hstate_attr_group); + &hstate_kobjs[hstate_index(h)], &hstate_attr_group); if (err) pr_err("HugeTLB: Unable to add hstate %s\n", h->name); } --=20 2.20.1