From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D82E7377543 for ; Mon, 23 Feb 2026 21:37:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771882669; cv=none; b=S+zJ5C9wcyexDjrLuMWu60k/emqtZKGCJvp6mfspj3ilUyfNcKzK7vRcvPY3iZLjRqdBwxtbww+J3VQ5Oi8hz3wUBZq8XH8uSO12Vb9391ahe9ddcJ47Z6Jejsh9vr2Bpf4nSSZbThAgUWbcck4gkntbHI0jGalnwvbALE7lkhw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771882669; c=relaxed/simple; bh=MYpqUxMpYwkhOju+gnYcw1HvuKIFM971ic1B7jd/Brw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RsGRFdO5KKwl0oTX/tK8RJ8CTc8loIhbVZj4SyyBGU3FvVUwjyQj4tw6JFxZvZhxWQ/pT+wdz9Vfa1NowUlmPbmYSUGg+eEKucIdZk8QLCkrNbEzfnW0Emo1qFYB+ra0ObkcHKMftVAtBlCbLG4nSw08wPs0E6l5ezLkU524mWg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=B2O+We8Q; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="B2O+We8Q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1771882665; bh=MYpqUxMpYwkhOju+gnYcw1HvuKIFM971ic1B7jd/Brw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=B2O+We8QVKlqiwrYw1bgfyEGqJ3qyfEPJj6t6ORYSOU4opLdaD4SmhZzbeUd1bXTb PKhx3eHWL/P9cZedfnY6wTvmg13gqacE2zrpXvzNYlRAV+1AB/pvEVYRUsC+1jMDD2 PpKPMZ9rW2xRULSw87FSAuBhPcyxfvFRXiBD6qT4= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 23 Feb 2026 22:37:43 +0100 Subject: [PATCH 1/2] mm/slab: create sysfs attribute through default_groups Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260223-sysfs-const-slub-v1-1-ff86ffc26fff@weissschuh.net> References: <20260223-sysfs-const-slub-v1-0-ff86ffc26fff@weissschuh.net> In-Reply-To: <20260223-sysfs-const-slub-v1-0-ff86ffc26fff@weissschuh.net> To: Vlastimil Babka , Andrew Morton , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771882664; l=1444; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=MYpqUxMpYwkhOju+gnYcw1HvuKIFM971ic1B7jd/Brw=; b=2eAT+dOKGjcpux56nH0MXkeFoQtqbS2Y00d00OObMhUZobtW3Q17HQO1d+0UoK6pohgLM3RAL xEwsxVXTZVuC8J+T90hT6NavcrMaO9vogEZZm4Iu3QQNfwZb4gITgPB X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The driver core can automatically create custom type attributes. This makes the code and error-handling shorter. Signed-off-by: Thomas Weißschuh --- mm/slub.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 862642c165ed..a48ea23b1728 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -9317,9 +9317,7 @@ static struct attribute *slab_attrs[] = { NULL }; -static const struct attribute_group slab_attr_group = { - .attrs = slab_attrs, -}; +ATTRIBUTE_GROUPS(slab); static ssize_t slab_attr_show(struct kobject *kobj, struct attribute *attr, @@ -9366,6 +9364,7 @@ static const struct sysfs_ops slab_sysfs_ops = { static const struct kobj_type slab_ktype = { .sysfs_ops = &slab_sysfs_ops, .release = kmem_cache_release, + .default_groups = slab_groups, }; static struct kset *slab_kset; @@ -9453,10 +9452,6 @@ static int sysfs_slab_add(struct kmem_cache *s) if (err) goto out; - err = sysfs_create_group(&s->kobj, &slab_attr_group); - if (err) - goto out_del_kobj; - if (!unmergeable) { /* Setup first alias */ sysfs_slab_alias(s, s->name); @@ -9465,9 +9460,6 @@ static int sysfs_slab_add(struct kmem_cache *s) if (!unmergeable) kfree(name); return err; -out_del_kobj: - kobject_del(&s->kobj); - goto out; } void sysfs_slab_unlink(struct kmem_cache *s) -- 2.53.0