diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2009-02-08 13:42:01 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-03-30 22:35:35 -0400 |
commit | acae05156551fd7528fbb616271e672789388e3c (patch) | |
tree | 71cb528037776997aea4d5a3128bd9c2ea723ba1 /kernel/kmod.c | |
parent | 8c8ef42aee8fcfb4128bb94c50d55c9f80ade525 (diff) |
module: create a request_module_nowait()
There seems to be a common pattern in the kernel where drivers want to
call request_module() from inside a module_init() function. Currently
this would deadlock.
As a result, several drivers go through hoops like scheduling things via
kevent, or creating custom work queues (because kevent can deadlock on them).
This patch changes this to use a request_module_nowait() function macro instead,
which just fires the modprobe off but doesn't wait for it, and thus avoids the
original deadlock entirely.
On my laptop this already results in one less kernel thread running..
(Includes Jiri's patch to use enum umh_wait)
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (bool-ified)
Cc: Jiri Slaby <jirislaby@gmail.com>
Diffstat (limited to 'kernel/kmod.c')
-rw-r--r-- | kernel/kmod.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/kernel/kmod.c b/kernel/kmod.c index f0c8f545180d..b750675251e5 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
@@ -50,7 +50,8 @@ static struct workqueue_struct *khelper_wq; | |||
50 | char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe"; | 50 | char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe"; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * request_module - try to load a kernel module | 53 | * __request_module - try to load a kernel module |
54 | * @wait: wait (or not) for the operation to complete | ||
54 | * @fmt: printf style format string for the name of the module | 55 | * @fmt: printf style format string for the name of the module |
55 | * @...: arguments as specified in the format string | 56 | * @...: arguments as specified in the format string |
56 | * | 57 | * |
@@ -63,7 +64,7 @@ char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe"; | |||
63 | * If module auto-loading support is disabled then this function | 64 | * If module auto-loading support is disabled then this function |
64 | * becomes a no-operation. | 65 | * becomes a no-operation. |
65 | */ | 66 | */ |
66 | int request_module(const char *fmt, ...) | 67 | int __request_module(bool wait, const char *fmt, ...) |
67 | { | 68 | { |
68 | va_list args; | 69 | va_list args; |
69 | char module_name[MODULE_NAME_LEN]; | 70 | char module_name[MODULE_NAME_LEN]; |
@@ -108,11 +109,12 @@ int request_module(const char *fmt, ...) | |||
108 | return -ENOMEM; | 109 | return -ENOMEM; |
109 | } | 110 | } |
110 | 111 | ||
111 | ret = call_usermodehelper(modprobe_path, argv, envp, 1); | 112 | ret = call_usermodehelper(modprobe_path, argv, envp, |
113 | wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC); | ||
112 | atomic_dec(&kmod_concurrent); | 114 | atomic_dec(&kmod_concurrent); |
113 | return ret; | 115 | return ret; |
114 | } | 116 | } |
115 | EXPORT_SYMBOL(request_module); | 117 | EXPORT_SYMBOL(__request_module); |
116 | #endif /* CONFIG_MODULES */ | 118 | #endif /* CONFIG_MODULES */ |
117 | 119 | ||
118 | struct subprocess_info { | 120 | struct subprocess_info { |