From nobody Mon Feb 9 16:02:58 2026 Received: from sg-1-104.ptr.blmpb.com (sg-1-104.ptr.blmpb.com [118.26.132.104]) (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 E1300217705 for ; Wed, 7 Jan 2026 11:33:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.26.132.104 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767785630; cv=none; b=W6oeLdoJCwUY3cRV4ofwfJiJ9HEX0k30exWrmMRkwr8DHgXYRnQNgsDr9nrUPVltR839UD1Se9LKhusURXVseaWU/s15fdvlihklNuuaal2JMOew4TynMmYBx7hfTHZ0F/8Bx0seGztQPo2eAwYl/grd9Pw1b8eO8kbiKTSNxOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767785630; c=relaxed/simple; bh=6E2l99huuofYVdeeRyTPSErdtM6qWzOycD7weuOPC/c=; h=Content-Type:To:Cc:Date:In-Reply-To:Message-Id:Mime-Version:From: Subject:References; b=jCPMJM2hxfuUPVH3ywWB5VBHaHDruJeQ2t2YnVjkRTE4y9yU0zOJjdoRecpVNI94Tvuyq0ximIxDjN3zHMlj4oghZIrEtdrIJYdDcAW+YE/FLYw4V0mUBgYegY3WY+7IVWiITBvl4ER2OQ/uaV5SGgJi39lq6vcgGQ/yO0Kex+Y= 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=ZvYfk9rw; arc=none smtp.client-ip=118.26.132.104 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="ZvYfk9rw" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1767785624; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=cdN0DkMz/24rvpJgnVOmkfsKqwcFTBjxdUIoAY0F9to=; b=ZvYfk9rw748S528ePTp5+ANPl8/4majtRwWTrxEDtF32l5vH2D+EfeogWjyslfS31jH4OP yg4hZoQYP6GqH+Yz5hsLJPT3kT9gHidk1TzXeo+jD3kHFURneLCxLgEIFKa9xEuaeZ9DB2 OnxnYzxIgyuu5rD6DggpAwU3zzsdbqvcwJE8ionSwOvtyM+jxXUW6zUBUwnevRH3LaArDB y9F58i5/dEyAuXQnblGlR9ny+4L6xRnH+8YUzya3OZ35k3T572jT3vUHzngCWb+YaqRGCe d0YDTvILEQ6XH6Ut7J8Yw+WCCRJG8BRijyRwN+gHLunlS5cA9X2VZU2LpH1AiA== To: , , , , Cc: , , Date: Wed, 7 Jan 2026 19:31:27 +0800 X-Lms-Return-Path: In-Reply-To: <20260107113130.37231-1-lizhe.67@bytedance.com> X-Mailer: git-send-email 2.45.2 Message-Id: <20260107113130.37231-6-lizhe.67@bytedance.com> X-Original-From: Li Zhe Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 From: "Li Zhe" Subject: [PATCH v2 5/8] mm/hugetlb: simplify function hugetlb_sysfs_add_hstate() References: <20260107113130.37231-1-lizhe.67@bytedance.com> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 68a7372d3378..3f25a24e27cf 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; } } @@ -566,8 +565,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); @@ -614,7 +613,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