aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2009-02-08 13:42:01 -0500
committerRusty Russell <rusty@rustcorp.com.au>2009-03-30 22:35:35 -0400
commitacae05156551fd7528fbb616271e672789388e3c (patch)
tree71cb528037776997aea4d5a3128bd9c2ea723ba1 /include/linux
parent8c8ef42aee8fcfb4128bb94c50d55c9f80ade525 (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 'include/linux')
-rw-r--r--include/linux/kmod.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index 92213a9194e1..d5fa565086d1 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -29,10 +29,15 @@
29#ifdef CONFIG_MODULES 29#ifdef CONFIG_MODULES
30/* modprobe exit status on success, -ve on error. Return value 30/* modprobe exit status on success, -ve on error. Return value
31 * usually useless though. */ 31 * usually useless though. */
32extern int request_module(const char * name, ...) __attribute__ ((format (printf, 1, 2))); 32extern int __request_module(bool wait, const char *name, ...) \
33#define try_then_request_module(x, mod...) ((x) ?: (request_module(mod), (x))) 33 __attribute__((format(printf, 2, 3)));
34#define request_module(mod...) __request_module(true, mod)
35#define request_module_nowait(mod...) __request_module(false, mod)
36#define try_then_request_module(x, mod...) \
37 ((x) ?: (__request_module(false, mod), (x)))
34#else 38#else
35static inline int request_module(const char * name, ...) { return -ENOSYS; } 39static inline int request_module(const char *name, ...) { return -ENOSYS; }
40static inline int request_module_nowait(const char *name, ...) { return -ENOSYS; }
36#define try_then_request_module(x, mod...) (x) 41#define try_then_request_module(x, mod...) (x)
37#endif 42#endif
38 43