On Tue, 19 May 2026 11:48:47 +0800 Chen Pei <[email protected]> wrote:
> 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". Agreed. I'm curious why it was built that way. I scraped an email address that is hopefully the right Lucas from another thread. +CC Brief summary is that this series was trying to avoid a message when module load fails due to it already being loaded, or built in but some of the files are missing (as say no modules installed). If modules.builtin isn't there we get return value of KMOD_MODULE_COMING as the extra is it loaded heuristic doesn't work because the initstate file isn't there at all. My suspicion is this is papering over a race condition that occurs in a normal module load - it may not be possible to tell the difference between COMMING and BUILTIN reliably. > > 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. This is indeed better than current situation and given it's ultimately a case of message suppression that seems harmless. So I don't mind this if handing the corner case I hit is too complex. Jonathan > > Thanks, > Pei
