On Mon, 18 May 2026 17:01:41 +0100, Jonathan Cameron wrote: > > I think this patch is worth you trying. In libmkmod code I'm looking at: > > It doesn't work - hence the reply! > > > > > https://github.com/lucasdemarchi/kmod/blob/master/libkmod/libkmod-module.c > > > > the "module directory exists but initstate cannot be opened" case returns > > KMOD_MODULE_BUILTIN, not KMOD_MODULE_COMING.
Hi Jonathan, Thanks for testing and the detailed analysis. I wasn't able to reproduce this on my setup because the modules.builtin index is correctly installed, so kmod_module_get_initstate() returns KMOD_MODULE_BUILTIN at the first step (via kmod_module_is_builtin()) without ever falling through to the sysfs path. That said, I understand the scenario ??? developing in a VM with CONFIG_DEV_DAX=y but without running modules_install is a perfectly reasonable workflow, and I agree it's worth addressing. However, I feel that the suggested workaround (adding a COMING + sysfs-dir-exists-without-initstate check in ndctl) is papering over what is fundamentally a libkmod issue. When a module is builtin and /sys/module/<name>/ exists without an initstate file, libkmod should not return KMOD_MODULE_COMING ??? that state implies a module is actively being loaded, which is not the case for a fully initialized builtin driver. The root cause is that kmod_module_is_builtin() fails when modules.builtin is missing, and the sysfs fallback doesn't distinguish "builtin without initstate" from "module in transition". I think the proper fix belongs in libkmod: the sysfs fallback in kmod_module_get_initstate() should return KMOD_MODULE_BUILTIN (or at least not COMING) when the directory exists but initstate does not. For now, would it be acceptable to keep this patch as-is (covering the BUILTIN and LIVE cases) and note in the commit message that the modules.builtin index must be properly installed for the builtin detection to work? If there is consensus that ndctl should carry the workaround regardless, I'm happy to send a v2 with the additional COMING handling. CC Alison. Thanks, Pei
