From: Bart Van Assche <bvanassche@acm.org>
To: Danilo Krummrich <dakr@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
driver-core@lists.linux.dev, Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Aaron Tomlin <atomlin@atomlin.com>,
Igor Pylypiv <ipylypiv@google.com>,
Chung-Kai Mei <chungkai@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] drivers: base: Set mod->async_probe_requested if needed
Date: Tue, 28 Apr 2026 12:39:49 -0700 [thread overview]
Message-ID: <2fc4a2af-a4bb-4797-87eb-e95b835aa673@acm.org> (raw)
In-Reply-To: <DI4ZX1HOWDNH.3G36YTI0MYC76@kernel.org>
On 4/28/26 11:22 AM, Danilo Krummrich wrote:
> What if userspace did explicitly pass async_probe=0?
Does this mean that what the user has configured should take precedence,
as in the untested patch below?
Thanks,
Bart.
diff --git a/drivers/base/module.c b/drivers/base/module.c
index 218aaa096455..86f1f21a3d23 100644
--- a/drivers/base/module.c
+++ b/drivers/base/module.c
@@ -39,6 +39,10 @@ int module_add_driver(struct module *mod, const
struct device_driver *drv)
if (!drv)
return 0;
+ if (mod && drv->probe_type == PROBE_PREFER_ASYNCHRONOUS &&
+ mod->async_probe_requested == PROBE_TYPE_NOT_SET)
+ mod->async_probe_requested = PROBE_ASYNCHRONOUSLY;
+
if (mod)
mk = &mod->mkobj;
else if (drv->mod_name) {
diff --git a/include/linux/module.h b/include/linux/module.h
index 7566815fabbe..a946ad88c925 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -394,6 +394,12 @@ struct klp_modinfo {
};
#endif
+enum async_probe_type {
+ PROBE_TYPE_NOT_SET = 0,
+ PROBE_SYNCHRONOUSLY,
+ PROBE_ASYNCHRONOUSLY,
+} __packed;
+
struct module {
enum module_state state;
@@ -442,7 +448,7 @@ struct module {
bool sig_ok;
#endif
- bool async_probe_requested;
+ enum async_probe_type async_probe_requested;
/* Exception table */
unsigned int num_exentries;
@@ -760,7 +766,7 @@ extern void print_modules(void);
static inline bool module_requested_async_probing(struct module *module)
{
- return module && module->async_probe_requested;
+ return module && module->async_probe_requested == PROBE_ASYNCHRONOUSLY;
}
static inline bool is_livepatch_module(struct module *mod)
diff --git a/kernel/module/main.c b/kernel/module/main.c
index 46dd8d25a605..9e2d9c9f65fa 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -3065,8 +3065,30 @@ void flush_module_init_free_work(void)
#undef MODULE_PARAM_PREFIX
#define MODULE_PARAM_PREFIX "module."
/* Default value for module->async_probe_requested */
-static bool async_probe;
-module_param(async_probe, bool, 0644);
+static enum async_probe_type async_probe;
+
+static int async_probe_set(const char *val, const struct kernel_param *kp)
+{
+ bool async;
+ int ret;
+
+ ret = kstrtobool(val, &async);
+ if (ret)
+ return ret;
+ async_probe = async ? PROBE_ASYNCHRONOUSLY : PROBE_SYNCHRONOUSLY;
+ return 0;
+}
+
+static int async_probe_get(char *buffer, const struct kernel_param *kp)
+{
+ return sysfs_emit(buffer, "%d", async_probe == PROBE_ASYNCHRONOUSLY);
+}
+
+static struct kernel_param_ops async_probe_ops = {
+ .set = async_probe_set,
+ .get = async_probe_get,
+};
+module_param_cb(async_probe, &async_probe_ops, &async_probe, 0644);
/*
* This is where the real work happens.
@@ -3135,7 +3157,7 @@ static noinline int do_init_module(struct module *mod)
* See commit 0fdff3ec6d87 ("async, kmod: warn on synchronous
* request_module() from async workers") for more details.
*/
- if (!mod->async_probe_requested)
+ if (mod->async_probe_requested != PROBE_ASYNCHRONOUSLY)
async_synchronize_full();
ftrace_free_mem(mod, mod->mem[MOD_INIT_TEXT].base,
@@ -3366,12 +3388,16 @@ static int prepare_coming_module(struct module *mod)
static int unknown_module_param_cb(char *param, char *val, const char
*modname,
void *arg)
{
+ bool async_probe_requested;
struct module *mod = arg;
int ret;
if (strcmp(param, "async_probe") == 0) {
- if (kstrtobool(val, &mod->async_probe_requested))
- mod->async_probe_requested = true;
+ if (kstrtobool(val, &async_probe_requested))
+ async_probe_requested = true;
+ mod->async_probe_requested = async_probe_requested ?
+ PROBE_ASYNCHRONOUSLY :
+ PROBE_SYNCHRONOUSLY;
return 0;
}
next prev parent reply other threads:[~2026-04-28 19:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 16:05 [PATCH] drivers: base: Set mod->async_probe_requested if needed Bart Van Assche
2026-04-28 18:22 ` Danilo Krummrich
2026-04-28 19:39 ` Bart Van Assche [this message]
2026-04-29 21:41 ` Danilo Krummrich
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=2fc4a2af-a4bb-4797-87eb-e95b835aa673@acm.org \
--to=bvanassche@acm.org \
--cc=atomlin@atomlin.com \
--cc=chungkai@google.com \
--cc=da.gomez@kernel.org \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=ipylypiv@google.com \
--cc=mcgrof@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=rafael@kernel.org \
--cc=samitolvanen@google.com \
--cc=stable@vger.kernel.org \
/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