When a DAX / ndctl driver is builtin (not a loadable module),
daxctl_insert_kmod_for_mode() and __util_bind() still call
kmod_module_probe_insert_module() unconditionally. libkmod only
short-circuits builtin modules when it can find the modules.builtin
index; otherwise it falls through to init_module() and returns -ENOENT,
surfacing as a spurious "insert failure".
Pre-check kmod_module_get_initstate() and skip probe-insert when the
module is already BUILTIN or LIVE, matching the pattern used by ndctl's
own test/core.c.
Changes since v1 [1]:
- Patch 1/2 unchanged; collected Reviewed-by from Dave and Alison.
- Patch 2/2: factored the state check into a new helper
util_kmod_skip_probe_insert() in util/sysfs.{c,h} so both
daxctl_insert_kmod_for_mode() and __util_bind() share it. The
helper also returns the observed libkmod state via an out
parameter so the caller does not re-read /sys/module/<name>/
initstate to distinguish LIVE from BUILTIN.
- Patch 2/2: additionally treat KMOD_MODULE_COMING as builtin when
/sys/module/<name>/ exists but the initstate file does not. This
is the pattern libkmod's sysfs fallback emits for builtin drivers
when the modules.builtin index is missing (e.g. a kernel installed
without running modules_install). This was the case Jonathan hit
on a builtin DAX VM setup; rather than rely on a libkmod fix, ndctl
handles the corner case directly. Suggested by Alison [2].
[1]:
https://lore.kernel.org/nvdimm/[email protected]/
[2]: https://lore.kernel.org/nvdimm/[email protected]/
Chen Pei (2):
daxctl: fix kmod reference leak on probe-insert failure
daxctl, util/sysfs: skip module probe-insert when driver is builtin or
live
daxctl/lib/libdaxctl.c | 23 ++++++++++++++++++++--
util/sysfs.c | 44 +++++++++++++++++++++++++++++++++++++++++-
util/sysfs.h | 16 +++++++++++++++
3 files changed, 80 insertions(+), 3 deletions(-)
--
2.50.1