From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
To: Chen Pei <cp0613@linux.alibaba.com>
Cc: alison.schofield@intel.com, dave.jiang@intel.com,
jic23@kernel.org, nvdimm@lists.linux.dev, guoren@kernel.org,
linux-cxl@vger.kernel.org
Subject: Re: [ndctl PATCH v3 2/2] daxctl, util/sysfs: skip module probe-insert when driver is builtin or live
Date: Thu, 9 Jul 2026 16:03:03 -0700 [thread overview]
Message-ID: <20260709160303.000031bc@oss.qualcomm.com> (raw)
In-Reply-To: <20260618090653.8983-3-cp0613@linux.alibaba.com>
On Thu, 18 Jun 2026 17:06:53 +0800
Chen Pei <cp0613@linux.alibaba.com> wrote:
> kmod_module_probe_insert_module() is supposed to return 0 for builtin
> modules, but only when libkmod can locate the modules.builtin index. If
> the index is missing (e.g. a kernel built with the driver as builtin
> but installed without running modules_install), libkmod falls through
> to the real init_module() syscall and returns an error such as -ENOENT,
> producing a spurious "insert failure" even though the driver is already
> part of the running kernel.
>
> Add a helper util_kmod_skip_probe_insert() that returns true when the
> module state is KMOD_MODULE_BUILTIN or KMOD_MODULE_LIVE. As an
> additional heuristic, treat KMOD_MODULE_COMING as builtin when
> /sys/module/<name>/ exists but the initstate file does not - this is
> the exact pattern libkmod's sysfs fallback emits for builtin drivers
> when the modules.builtin index is unavailable. The pattern mirrors the
> KMOD_MODULE_LIVE / KMOD_MODULE_BUILTIN check already used by ndctl's
> own test/core.c (see test/core.c:218-236).
>
> The helper also returns the observed libkmod state via an out parameter
> so daxctl_insert_kmod_for_mode() can distinguish LIVE (retain the kmod
> reference in dev->module) from BUILTIN (drop it, since builtin drivers
> cannot be unloaded) without re-reading /sys/module/<name>/initstate.
> __util_bind() passes NULL since it does not need the state.
>
> Reported-by: Jonathan Cameron <jic23@kernel.org>
> Suggested-by: Alison Schofield <alison.schofield@intel.com>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
I'm not set up to test this right now but fix looks good to me.
So a tentative
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
prev parent reply other threads:[~2026-07-09 23:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-18 9:06 [ndctl PATCH v3 0/2] daxctl, util/sysfs: fix builtin-driver false failure on enable Chen Pei
2026-06-18 9:06 ` [ndctl PATCH v3 1/2] daxctl: fix kmod reference leak on probe-insert failure Chen Pei
2026-06-18 9:06 ` [ndctl PATCH v3 2/2] daxctl, util/sysfs: skip module probe-insert when driver is builtin or live Chen Pei
2026-07-09 23:03 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260709160303.000031bc@oss.qualcomm.com \
--to=jonathan.cameron@oss.qualcomm.com \
--cc=alison.schofield@intel.com \
--cc=cp0613@linux.alibaba.com \
--cc=dave.jiang@intel.com \
--cc=guoren@kernel.org \
--cc=jic23@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox