Re: [PATCH] debugfs: warn if file creation failed due to uninitialized debugfs

From: Mikhail Gavrilov

Date: Thu Sep 03 2026 - 08:54:39 EST


On Sat, Jun 13, 2026 at 06:45:53PM +0900, Yohei Kojima wrote:
> > While I understand your frustration when adding new code to the kernel
> > that would trigger this, does it actually fail on a normal boot today?
>
> No. As far as I tested, no existing code faied there.

It does, with CONFIG_REF_TRACKER=y and CONFIG_DEBUG_FS=y. Since this
commit every boot here prints:

debugfs: Unable to create file 'net_refcnt@(____ptrval____)',
debugfs is not initialized yet
debugfs: Unable to create file 'net_notrefcnt@(____ptrval____)',
debugfs is not initialized yet

This is not a race. net_ns_init() is called directly from start_kernel(),
before any initcall runs, and debugfs_init() is a core_initcall, so
init_net's two ref_tracker directories always miss. Nothing is actually
lost - net/core/net_namespace.c re-registers them from a late_initcall(),
and both files are present under /sys/kernel/debug/ref_tracker/ once the
system is up - but the error is printed before that happens.

I bisected it to this commit and sent a fix that keeps the warning for the
case you were after:

https://lore.kernel.org/all/20260903115135.63210-1-mikhail.v.gavrilov@xxxxxxxxx/

--
Thanks,
Mikhail