From nobody Sat Jul 25 02:12:51 2026 Received: from canpmsgout01.his.huawei.com (canpmsgout01.his.huawei.com [113.46.200.216]) (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 E211D3AFCE5 for ; Mon, 20 Jul 2026 14:29:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784557753; cv=none; b=rbznyB2ONTYWUXedxd3dpuB8hp+in162j31EbUKWADDWsUaoPunY0EjBZwAXah5ArMmRI6RrzK9qaC0da226K+m1o6vVSG+JZww6sJoO+lHzxdYllTAVfelwFJtYWqXKw/JP/XmJ+IHeYMUIldyisNTQHMtPmfqOLgO/8sprnWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784557753; c=relaxed/simple; bh=94g4l0Yvw6X+xh6jkknqJm2n+LNHMZ3C0NGQXjHmi94=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=tWKilFL1Rc7+NtBC3My+5d12hW55BKCeeqgtR8FFQp1raivLbD92+Jvgc0C6PXZ9fdxr8hu2aA408OofUnNgnzD5eUO8RXH2wkMZsX5V+LS2mm+mtcosrjsM6IbqDRP5qTfCDRgg9EyO6jf9FtGrfORE3GjSgzYXLedTG0BT8QA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=rVIwa0RG; arc=none smtp.client-ip=113.46.200.216 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="rVIwa0RG" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=DrkyWGZJvKpz1Y9hUbiad/mxBLk74eyl6ggh9U6vGD8=; b=rVIwa0RGo6cGzljxEKCvwxkHBm71KKmMyXECRod6E4mkEaj3QR8pW0nFK8EH6Pm7G4fUoAyVg Dd/qnBYUUkaSjqLHpooIKMJ3mx7f82I/ja1CSLn7amNOg6zRfnnU5dGhHjOC7anImB+SzrMTGxJ kHg/lO9AiNRt68+IHVfaWfQ= Received: from mail.maildlp.com (unknown [172.19.162.197]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4h3jML4r74z1T4GB; Mon, 20 Jul 2026 22:19:42 +0800 (CST) Received: from kwepemj500018.china.huawei.com (unknown [7.202.194.48]) by mail.maildlp.com (Postfix) with ESMTPS id AD4DC40579; Mon, 20 Jul 2026 22:29:00 +0800 (CST) Received: from huawei.com (10.50.85.128) by kwepemj500018.china.huawei.com (7.202.194.48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 20 Jul 2026 22:28:59 +0800 From: Li Xiasong To: Vlastimil Babka , Harry Yoo , Andrew Morton CC: Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Rasmus Villemoes , , , , , Subject: [PATCH] mm/slub: fix missing debugfs entries for caches created before sysfs init Date: Mon, 20 Jul 2026 22:51:24 +0800 Message-ID: <20260720145124.3684976-1-lixiasong1@huawei.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemj500018.china.huawei.com (7.202.194.48) Content-Type: text/plain; charset="utf-8" slab_debugfs_init() creates the slab debugfs root at device initcall time, while slab_sysfs_init() moves slab_state to FULL at late initcall time. SLAB_STORE_USER caches created in this window currently miss their debugfs entries because do_kmem_cache_create() skips debugfs_slab_add() when slab_state <=3D UP. This was observed with MPTCP's request_sock_subflow_v6 cache, whose slab debugfs directory was missing. The affected initcall window is: slab_debugfs_init() slab_debugfs_root =3D debugfs_create_dir(...) kmem_cache_create(..., SLAB_STORE_USER, ...) do_kmem_cache_create() if (slab_state <=3D UP) return without debugfs entries slab_sysfs_init() slab_state =3D FULL Run slab_debugfs_init() after slab_sysfs_init() and protect its scan of slab_caches with slab_mutex. Fixes: 1a5ad30b89b4 ("mm: slub: make slab_sysfs_init() a late_initcall") Signed-off-by: Li Xiasong --- mm/slub.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index 9ec774dc7009..d35e40c7a7ba 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -9992,16 +9992,23 @@ static int __init slab_debugfs_init(void) { struct kmem_cache *s; =20 + mutex_lock(&slab_mutex); + slab_debugfs_root =3D debugfs_create_dir("slab", NULL); =20 list_for_each_entry(s, &slab_caches, list) if (s->flags & SLAB_STORE_USER) debugfs_slab_add(s); =20 + mutex_unlock(&slab_mutex); return 0; =20 } -__initcall(slab_debugfs_init); +/* + * This must be after slab_sysfs_init(), otherwise caches created between + * the debugfs scan and slab_state reaching FULL miss their debugfs entrie= s. + */ +late_initcall(slab_debugfs_init); #endif /* * The /proc/slabinfo ABI --=20 2.34.1