module and parameter patches
Subsystems (8)
The following changes since commit 0d34fb8e93ceba7b6dad0062dbb4a0813bacd75b:
Linus Torvalds (1):
Merge branch 'bzip2-lzma-for-linus' of git://git.kernel.org/.../x86/linux-2.6-tip
are available in the git repository at:
ssh://master.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-module-and-param.git master
Américo Wang (1):
kernel/module.c: fix an unused goto label
Anders Kaseorg (1):
Ksplice: Add functions for walking kallsyms symbols
Arjan van de Ven (3):
module: create a request_module_nowait()
use the new request_module_nowait() in the hid driver use the new request_module_nowait() in drivers/media
Rusty Russell (10):
param: fix charp parameters set via sysfs
module: __module_address
module: remove module_text_address()
module: clarify the force-loading taint message.
module: remove the SHF_ALLOC flag on the __versions section.
module: include other structures in module version check
module: don't use stop_machine on module load
arm: allow usage of string functions in linux/string.h
strstarts: helper function for !strncmp(str, prefix, strlen(prefix))
module: use strstarts()
Tim Abbott (2):
module: Make find_symbol return a struct kernel_symbol
module: Export symbols needed for Ksplice
arch/arm/boot/compressed/misc.c | 5 +- drivers/hid/hid-core.c | 19 +-- drivers/media/video/bt8xx/bttv-driver.c | 8 +- drivers/media/video/bt8xx/bttvp.h | 3 - drivers/media/video/cx88/cx88-mpeg.c | 14 +- drivers/media/video/cx88/cx88.h | 1 - drivers/media/video/em28xx/em28xx-cards.c | 17 +-- drivers/media/video/em28xx/em28xx.h | 2 - drivers/media/video/saa7134/saa7134-core.c | 19 +-- drivers/media/video/saa7134/saa7134.h | 2 - drivers/mtd/nand/nand_base.c | 4 +- include/linux/kallsyms.h | 15 ++ include/linux/kmod.h | 11 +- include/linux/module.h | 63 ++++++- include/linux/moduleparam.h | 10 + include/linux/string.h | 9 + kernel/extable.c | 6 +- kernel/kallsyms.c | 19 ++ kernel/kmod.c | 10 +- kernel/module.c | 274 ++++++++++++++++------------ kernel/params.c | 26 +++- scripts/mod/modpost.c | 4 +- 22 files changed, 334 insertions(+), 207 deletions(-)
commit 2fe667fa1bced0148826421aca4eb44833f2f577
Author: Rusty Russell <[email protected]> Date: Mon Mar 30 22:02:10 2009 -0600
param: fix charp parameters set via sysfs
Impact: fix crash on reading from /sys/module/.../ieee80211_default_rc_algo
The module_param type "charp" simply sets a char * pointer in the module to the parameter in the commandline string: this is why we keep the (mangled) module command line around. But when set via sysfs (as about 11 charp parameters can be) this memory is freed on the way out of the write(). Future reads hit random mem.
So we kstrdup instead: we have to check we're not in early commandline parsing, and we have to note when we've used it so we can reliably kfree the parameter when it's next overwritten, and also on module unload.
(Thanks to Randy Dunlap for CONFIG_SYSFS=n fixes)
include/linux/module.h | 4 ++++ include/linux/moduleparam.h | 10 ++++++++++ kernel/module.c | 14 ++++++++------ kernel/params.c | 26 +++++++++++++++++++++++++- 4 files changed, 47 insertions(+), 7 deletions(-)
commit b99d58d32fbaf50306e8f514393d2865b46d88bf
Author: Américo Wang <[email protected]> Date: Wed Mar 25 00:07:19 2009 +0800
kernel/module.c: fix an unused goto label
Impact: cleanup
Label 'free_init' is only used when defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP), so move it inside to shut up gcc.
kernel/module.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
commit 4859d6f3a8f8e60edb9ed390a2e9044ca0a4f2d2
Author: Tim Abbott <[email protected]> Date: Fri Dec 5 19:03:56 2008 -0500
module: Make find_symbol return a struct kernel_symbol
Impact: Cleanup, internal API change
Ksplice needs access to the kernel_symbol structure in order to support modifications to the exported symbol table.
kernel/module.c | 75 +++++++++++++++++++++++++++---------------------------- 1 files changed, 37 insertions(+), 38 deletions(-)
commit 6da318ebd26eef48738ede69ec0a65c86a3d278e
Author: Rusty Russell <[email protected]> Date: Mon Mar 30 22:02:15 2009 -0600
module: __module_address
Impact: New API, cleanup
ksplice wants to know the bounds of a module, not just the module text.
It makes sense to have __module_address. We then implement is_module_address and __module_text_address in terms of this (and change is_module_text_address() to bool while we're at it).
Also, add proper kerneldoc for them all.
include/linux/module.h | 20 +++++++++--- kernel/module.c | 76 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 73 insertions(+), 23 deletions(-)
commit a90b646caa84683c1526c75002303ab952e7dcb2
Author: Rusty Russell <[email protected]> Date: Mon Mar 30 22:02:17 2009 -0600
module: remove module_text_address()
Impact: Replace and remove risky (non-EXPORTed) API
module_text_address() returns a pointer to the module, which given locking improvements in module.c, is useless except to test for NULL:
1) If the module can't go away, use __module_text_address.
2) Otherwise, just use is_module_text_address().
drivers/mtd/nand/nand_base.c | 4 ++-- include/linux/module.h | 7 ------- kernel/extable.c | 6 +++--- kernel/module.c | 17 ++++------------- 4 files changed, 9 insertions(+), 25 deletions(-)
commit 61e666feaa61bfdeb721ffa048b1a41e6a16c13b
Author: Anders Kaseorg <[email protected]> Date: Fri Dec 5 19:03:58 2008 -0500
Ksplice: Add functions for walking kallsyms symbols
Impact: New API
kallsyms_lookup_name only returns the first match that it finds. Ksplice needs information about all symbols with a given name in order to correctly resolve local symbols.
kallsyms_on_each_symbol provides a generic mechanism for iterating over the kallsyms table.
include/linux/kallsyms.h | 15 +++++++++++++++ include/linux/module.h | 12 ++++++++++++ kernel/kallsyms.c | 19 +++++++++++++++++++ kernel/module.c | 19 +++++++++++++++++++ 4 files changed, 65 insertions(+), 0 deletions(-)
commit e7b7f2253592a38d046691360d9fcb49c6ae4a38
Author: Tim Abbott <[email protected]> Date: Fri Dec 5 19:03:59 2008 -0500
module: Export symbols needed for Ksplice
Impact: Expose some module.c symbols
Ksplice uses several functions from module.c in order to resolve symbols and implement dependency handling. Calling these functions requires holding module_mutex, so it is exported.
(This is just the module part of a bigger add-exports patch from Tim).
include/linux/module.h | 28 ++++++++++++++++++++++++++++ kernel/module.c | 43 +++++++++++++++++++------------------------ 2 files changed, 47 insertions(+), 24 deletions(-)
commit 3fc34f3c1939d173a7c7e3bfd946e6852c9a016a
Author: Rusty Russell <[email protected]> Date: Mon Mar 30 22:02:19 2009 -0600
module: clarify the force-loading taint message.
Impact: Message cleanup
Two of three callers of try_to_force_load() are not because of a missing version, so change the messages:
Old:
<modname>: no version for "magic" found: kernel tainted.
New:
<modname>: bad vermagic: kernel tainted.
Old:
<modname>: no version for "nocrc" found: kernel tainted.
New:
<modname>: no versions for exported symbols: kernel tainted.
Old:
<modname>: no version for "<symname>" found: kernel tainted.
New:
<modname>: <symname>: kernel tainted.
kernel/module.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
commit 212d604c4f542e780613656c8acdc035b3431f5f
Author: Rusty Russell <[email protected]> Date: Mon Mar 30 22:02:19 2009 -0600
module: remove the SHF_ALLOC flag on the __versions section.
Impact: reduce kernel memory usage
This patch just takes off the SHF_ALLOC flag on __versions so we don't keep them around after module load.
This saves about 7% of module memory if CONFIG_MODVERSIONS=y.
kernel/module.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
commit 7b87baad9307d2c7cbb56a61ae2471d927b06b5d
Author: Rusty Russell <[email protected]> Date: Mon Mar 30 22:02:20 2009 -0600
module: include other structures in module version check
With CONFIG_MODVERSIONS, we version 'struct module' using a dummy export, but other things matter too:
1) 'struct modversion_info' determines the layout of the __versions section,
2) 'struct kernel_param' determines the layout of the __params section,
3) 'struct kernel_symbol' determines __ksymtab*.
4) 'struct marker' determines __markers.
5) 'struct tracepoint' determines __tracepoints.
So we rename 'struct_module' to 'module_layout' and include these in the signature. Now it's general we can add others later on without confusion.
kernel/module.c | 18 +++++++++++++----- scripts/mod/modpost.c | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-)
commit 5ac4706bb09cdfc21ad94477462cd5fb74709062
Author: Arjan van de Ven <[email protected]> Date: Sun Feb 8 10:42:01 2009 -0800
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)
include/linux/kmod.h | 11 ++++++++--- kernel/kmod.c | 10 ++++++---- 2 files changed, 14 insertions(+), 7 deletions(-)
commit 743b7e3627cbcd5b04b2d1878b1c6b39e357173e
Author: Arjan van de Ven <[email protected]> Date: Sun Feb 8 10:42:40 2009 -0800
use the new request_module_nowait() in the hid driver
Now that there is a request_module_nowait(), use it in the hid driver. This gets rid of a kernel thread, and also greatly simplifies the code...
drivers/hid/hid-core.c | 19 +------------------ 1 files changed, 1 insertions(+), 18 deletions(-)
commit e777b1632850740b36d17ef86f4cc2882508fe94
Author: Arjan van de Ven <[email protected]> Date: Mon Mar 30 22:02:24 2009 -0600
use the new request_module_nowait() in drivers/media
Several drivers/media/video drivers use keventd to load modules to avoid the "load a module from the module init code" deadlock.
Now that we have request_module_nowait() this can be simplified greatly.
drivers/media/video/bt8xx/bttv-driver.c | 8 +------- drivers/media/video/bt8xx/bttvp.h | 3 --- drivers/media/video/cx88/cx88-mpeg.c | 14 +++----------- drivers/media/video/cx88/cx88.h | 1 - drivers/media/video/em28xx/em28xx-cards.c | 17 ++++------------- drivers/media/video/em28xx/em28xx.h | 2 -- drivers/media/video/saa7134/saa7134-core.c | 19 ++++++------------- drivers/media/video/saa7134/saa7134.h | 2 -- 8 files changed, 14 insertions(+), 52 deletions(-)
commit 9e7ea4956260af4ca7f1b3c2f9ef9957f0bf7dca
Author: Rusty Russell <[email protected]> Date: Mon Mar 30 22:02:29 2009 -0600
module: don't use stop_machine on module load
Kay Sievers <[email protected]> discovered that boot times are slowed by about half a second because all the stop_machine_create() calls, and he only probes about 40 modules (I have 125 loaded on this laptop).
We only do stop_machine_create() so we can unlink the module if something goes wrong, but it's overkill (and buggy anyway: if stop_machine_create() fails we still call stop_machine_destroy()).
Since we are only protecting against kallsyms (esp. oops) walking the list, synchronize_sched() is sufficient (synchronize_rcu() is probably sufficient, but we're not in a hurry).
Kay says of this patch:
... no module takes more than 40 millisecs to link now, most of them are between 3 and 8 millisecs.
That looks very different to the numbers without this patch and the otherwise same setup, where we get heavy noise in the traces and many delays of up to 200 millisecs until linking, most of them taking 30+ millisecs.
kernel/module.c | 12 +++--------- 1 files changed, 3 insertions(+), 9 deletions(-)
commit 8837424a91af312896ce8d436a81f3798f6ea0d8
Author: Rusty Russell <[email protected]> Date: Mon Mar 30 22:02:31 2009 -0600
arm: allow usage of string functions in linux/string.h
In introducing a trivial "strstarts()" function in linux/string.h, we hit:
arch/arm/boot/compressed/misc.o: In function `strstarts':
misc.c:(.text+0x368): undefined reference to strlen' misc.c:(.text+0x378): undefined reference to strncmp'
This is because of "CFLAGS_misc.o := -Dstatic=" in the Makefile. "static inline strstarts(...)" becomes non-inline, and refers to the other string ops.
The simplest workaround is to include asm/string.h. This makes sense anyway, since lib/string.c won't be linked against this so we can't use those functions anyway.
Compile tested here.
arch/arm/boot/compressed/misc.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
commit 7c315c7413b13c6b74f675b2d052021915534e4d
Author: Rusty Russell <[email protected]> Date: Mon Mar 30 22:02:32 2009 -0600
strstarts: helper function for !strncmp(str, prefix, strlen(prefix))
Impact: minor new API
ksplice added a "starts_with" function, which seems like a common need. When people open-code it they seem to use fixed numbers rather than strlen, so it's quite a readability win (also, strncmp() almost always wants != 0 on it).
So here's strstarts().
include/linux/string.h | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
commit fb9acaa4082e370256b997011d565d1259a71c0f
Author: Rusty Russell <[email protected]> Date: Mon Mar 30 22:02:32 2009 -0600
module: use strstarts()
Impact: minor cleanup.
I'm not going to neaten anyone else's code, but I'm happy to clean up my own.
kernel/module.c | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-)
arch/arm/boot/compressed/misc.c +4 -1
@@ -18,7 +18,10 @@unsigned int __machine_arch_type; -#include <linux/string.h> +#include <linux/compiler.h> /* for inline */ +#include <linux/types.h> /* for size_t */ +#include <linux/stddef.h> /* for NULL */ +#include <asm/string.h> #ifdef STANDALONE_DEBUG #define putstr printf
drivers/hid/hid-core.c +1 -18
@@ -1813,15 +1813,6 @@ void hid_unregister_driver(struct hid_driver *hdrv) }EXPORT_SYMBOL_GPL (hid_unregister_driver); -#ifdef CONFIG_HID_COMPAT -static void hid_compat_load (struct work_struct *ws) -{ -request_module ("hid-dummy" ); -} -static DECLARE_WORK(hid_compat_work, hid_compat_load); -static struct workqueue_struct *hid_compat_wq; -#endif -static int __init hid_init (void ) {int ret;
@@ -1837,12 +1828,7 @@ static int __init hid_init(void) goto err_bus;#ifdef CONFIG_HID_COMPAT - hid_compat_wq =create_singlethread_workqueue ("hid_compat" ); -if (!hid_compat_wq) { -hidraw_exit (); - goto err; - } -queue_work (hid_compat_wq, &hid_compat_work); +request_module_nowait ("hid-dummy" );#endif return 0 ;
@@ -1854,9 +1840,6 @@ err: static void __exit hid_exit(void) { -#ifdef CONFIG_HID_COMPAT -destroy_workqueue (hid_compat_wq); -#endif hidraw_exit ();bus_unregister (&hid_bus_type); }
drivers/media/video/bt8xx/bttv-driver.c +1 -7
@@ -175,15 +175,9 @@ static DEVICE_ATTR(card, S_IRUGO, show_card, NULL);/* ----------------------------------------------------------------------- */ /* dvb auto-load setup */ #if defined(CONFIG_MODULES ) && defined(MODULE ) -static void request_module_async (struct work_struct *work) -{ -request_module ("dvb-bt8xx" ); -} -static void request_modules (struct bttv *dev) { -INIT_WORK (&dev->request_module_wk, request_module_async); -schedule_work (&dev->request_module_wk); +request_module_nowait ("dvb-bt8xx" ); }#else #define request_modules (dev)
drivers/media/video/bt8xx/bttvp.h +0 -3
@@ -439,9 +439,6 @@ struct bttv {unsigned int users;struct bttv_fh init; -/* used to make dvb-bt8xx autoloadable */ -struct work_struct request_module_wk; -/* Default (0) and current (1) video capturing and overlay cropping parameters in bttv_tvnorm.cropcap units. Protected by bttv.lock. */
drivers/media/video/cx88/cx88-mpeg.c +3 -11
@@ -50,20 +50,12 @@ MODULE_PARM_DESC(debug,"enable debug messages [mpeg]"); printk(KERN_DEBUG "%s/2-mpeg: " fmt, core->name, ## arg) #if defined(CONFIG_MODULES) && defined(MODULE) -static void request_module_async (struct work_struct *work) +static void request_modules (struct cx8802_dev *dev) { - struct cx8802_dev *dev=container_of(work, struct cx8802_dev, request_module_wk); -if (dev->core->board.mpeg &CX88_MPEG_DVB ) -request_module ("cx88-dvb" ); +request_module_nowait ("cx88-dvb" );if (dev->core->board.mpeg &CX88_MPEG_BLACKBIRD ) -request_module ("cx88-blackbird" ); -} - -static void request_modules (struct cx8802_dev *dev) -{ -INIT_WORK (&dev->request_module_wk, request_module_async); -schedule_work (&dev->request_module_wk); +request_module_nowait ("cx88-blackbird" ); }#else #define request_modules (dev)
drivers/media/video/cx88/cx88.h +0 -1
@@ -510,7 +510,6 @@ struct cx8802_dev {/* List of attached drivers */ struct list_head drvlist; -struct work_struct request_module_wk; };/* ----------------------------------------------------------- */
drivers/media/video/em28xx/em28xx-cards.c +4 -13
@@ -1809,24 +1809,15 @@ void em28xx_card_setup(struct em28xx *dev)#if defined(CONFIG_MODULES ) && defined(MODULE ) -static void request_module_async (struct work_struct *work) +static void request_modules (struct em28xx *dev) { -struct em28xx *dev =container_of (work, - struct em28xx, request_module_wk); -if (dev->has_audio_class) -request_module ("snd-usb-audio" ); +request_module_nowait ("snd-usb-audio" );else if (dev->has_alsa_audio) -request_module ("em28xx-alsa" ); +request_module_nowait ("em28xx-alsa" );if (dev->board.has_dvb) -request_module ("em28xx-dvb" ); -} - -static void request_modules (struct em28xx *dev) -{ -INIT_WORK (&dev->request_module_wk, request_module_async); -schedule_work (&dev->request_module_wk); +request_module_nowait ("em28xx-dvb" ); }#else #define request_modules (dev)
drivers/media/video/em28xx/em28xx.h +0 -2
@@ -498,8 +498,6 @@ struct em28xx {enum em28xx_dev_state state;enum em28xx_io_method io; -struct work_struct request_module_wk; -/* locks */ struct mutex lock;struct mutex ctrl_urb_lock;/* protects urb_buf */
drivers/media/video/saa7134/saa7134-core.c +6 -13
@@ -149,23 +149,16 @@ void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value)/* delayed request_module */ #if defined(CONFIG_MODULES ) && defined(MODULE ) - -static void request_module_async (struct work_struct *work){ - struct saa7134_dev* dev = container_of(work, struct saa7134_dev, request_module_wk); +static void request_submodules (struct saa7134_dev *dev) +{if (card_is_empress (dev)) -request_module ("saa7134-empress" ); +request_module_nowait ("saa7134-empress" );if (card_is_dvb (dev)) -request_module ("saa7134-dvb" ); +request_module_nowait ("saa7134-dvb" );if (alsa) -request_module ("saa7134-alsa" ); +request_module_nowait ("saa7134-alsa" );if (oss) -request_module ("saa7134-oss" ); -} - -static void request_submodules (struct saa7134_dev *dev) -{ -INIT_WORK (&dev->request_module_wk, request_module_async); -schedule_work (&dev->request_module_wk); +request_module_nowait ("saa7134-oss" ); }#else
drivers/media/video/saa7134/saa7134.h +0 -2
@@ -482,8 +482,6 @@ struct saa7134_dev {struct mutex lock;spinlock_t slock;struct v4l2_prio_state prio; -/* workstruct for loading modules */ -struct work_struct request_module_wk;/* insmod option/autodetected */ int autodetected;
drivers/mtd/nand/nand_base.c +2 -2
@@ -2720,14 +2720,14 @@ int nand_scan_tail(struct mtd_info *mtd)return chip->scan_bbt (mtd); } -/* module_text_address() isn't exported, and it's mostly a pointless +/* is_module_text_address() isn't exported, and it's mostly a pointless test if this is a module _anyway_ -- they'd have to try _really_ hard to call us from in-kernel code if the core NAND support is modular. */ #ifdef MODULE #define caller_is_module () (1)#else #define caller_is_module () \ - module_text_address((unsigned long)__builtin_return_address(0)) + is_module_text_address((unsigned long)__builtin_return_address(0))#endif /**
include/linux/kallsyms.h +15 -0
@@ -13,10 +13,17 @@#define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1) +struct module ; +#ifdef CONFIG_KALLSYMS /* Lookup the address for a symbol. Returns 0 if not found. */ unsigned long kallsyms_lookup_name (const char *name); +/* Call a function on each kallsyms symbol in the core kernel */ +int kallsyms_on_each_symbol (int (*fn)(void *,const char *,struct module *, +unsigned long ), +void *data); +extern int kallsyms_lookup_size_offset (unsigned long addr,unsigned long *symbolsize,unsigned long *offset);
@@ -43,6 +50,14 @@ static inline unsigned long kallsyms_lookup_name(const char *name)return 0 ; } +static inline int kallsyms_on_each_symbol (int (*fn)(void *,const char *, +struct module *, +unsigned long ), +void *data) +{ +return 0 ; +} +static inline int kallsyms_lookup_size_offset (unsigned long addr,unsigned long *symbolsize,unsigned long *offset)
include/linux/kmod.h +8 -3
@@ -29,10 +29,15 @@#ifdef CONFIG_MODULES /* modprobe exit status on success, -ve on error. Return value * usually useless though. */ -extern int request_module (const char * name, ...) __attribute__ ((format (printf,1 ,2 ))); -#define try_then_request_module(x, mod...) ((x) ?: (request_module(mod), (x))) +extern int __request_module (bool wait,const char *name, ...) \ + __attribute__((format (printf,2 ,3 ))); +#define request_module(mod...) __request_module(true, mod) +#define request_module_nowait(mod...) __request_module(false, mod) +#define try_then_request_module(x, mod...) \ + ((x) ?: (__request_module(false, mod), (x)))#else -static inline int request_module (const char * name, ...) {return -ENOSYS ; } +static inline int request_module (const char *name, ...) {return -ENOSYS ; } +static inline int request_module_nowait (const char *name, ...) {return -ENOSYS ; } #define try_then_request_module(x, mod...) (x)#endif
include/linux/module.h +55 -8
122 lines not on this page · raw message
include/linux/moduleparam.h +10 -0
@@ -138,6 +138,16 @@ extern int parse_args(const char *name,unsigned num, int (*unknown)(char *param, char *val)); +/* Called by module remove. */ +#ifdef CONFIG_SYSFS +extern void destroy_params (const struct kernel_param *params,unsigned num); +#else +static inline void destroy_params (const struct kernel_param *params, +unsigned num) +{ +} +#endif /* !CONFIG_SYSFS */ +/* All the helper functions */ /* The macros to do compile-time type checking stolen from Jakub Jelinek, who IIRC came up with this idea for the 2.4 module init code. */
include/linux/string.h +9 -0
@@ -114,5 +114,14 @@ extern bool sysfs_streq(const char *s1, const char *s2);extern ssize_t memory_read_from_buffer (void *to,size_t count,loff_t *ppos,const void *from,size_t available); +/** +* strstarts - does @str start with @prefix? +* @str: string to examine +* @prefix: prefix to look for. +*/ +static inline bool strstarts (const char *str,const char *prefix) +{ +return strncmp (str, prefix,strlen (prefix)) ==0 ; +}#endif #endif /* _LINUX_STRING_H_ */
kernel/extable.c +3 -3
@@ -58,14 +58,14 @@ __notrace_funcgraph int __kernel_text_address(unsigned long addr) {if (core_kernel_text (addr))return 1 ; -return __module_text_address (addr) !=NULL ; +return is_module_text_address (addr); }int kernel_text_address (unsigned long addr) {if (core_kernel_text (addr))return 1 ; -return module_text_address (addr) !=NULL ; +return is_module_text_address (addr); }/*
@@ -81,5 +81,5 @@ int func_ptr_is_kernel_text(void *ptr) addr = (unsigned long )dereference_function_descriptor (ptr);if (core_kernel_text (addr))return 1 ; -return module_text_address (addr) !=NULL ; +return is_module_text_address (addr); }
kernel/kallsyms.c +19 -0
@@ -161,6 +161,25 @@ unsigned long kallsyms_lookup_name(const char *name)return module_kallsyms_lookup_name (name); } +int kallsyms_on_each_symbol (int (*fn)(void *,const char *,struct module *, +unsigned long ), +void *data) +{ +char namebuf[KSYM_NAME_LEN ]; +unsigned long i; +unsigned int off; +int ret; + +for (i =0 , off =0 ; i < kallsyms_num_syms; i++) { + off =kallsyms_expand_symbol (off, namebuf); + ret =fn (data, namebuf,NULL , kallsyms_addresses[i]); +if (ret !=0 ) +return ret; + } +return module_kallsyms_on_each_symbol (fn, data); +} +EXPORT_SYMBOL_GPL (kallsyms_on_each_symbol); +static unsigned long get_symbol_pos (unsigned long addr,unsigned long *symbolsize,unsigned long *offset)
kernel/kmod.c +6 -4
@@ -50,7 +50,8 @@ static struct workqueue_struct *khelper_wq;char modprobe_path[KMOD_PATH_LEN ] ="/sbin/modprobe" ;/** -* request_module - try to load a kernel module +* __request_module - try to load a kernel module +* @wait: wait (or not) for the operation to complete * @fmt: printf style format string for the name of the module * @...: arguments as specified in the format string *
@@ -63,7 +64,7 @@ char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe";* If module auto-loading support is disabled then this function * becomes a no-operation. */ -int request_module (const char *fmt, ...) +int __request_module (bool wait,const char *fmt, ...) {va_list args;char module_name[MODULE_NAME_LEN ];
@@ -108,11 +109,12 @@ int request_module(const char *fmt, ...) return -ENOMEM; } - ret =call_usermodehelper (modprobe_path, argv, envp,1 ); + ret =call_usermodehelper (modprobe_path, argv, envp, + wait ?UMH_WAIT_PROC :UMH_WAIT_EXEC );atomic_dec (&kmod_concurrent);return ret; } -EXPORT_SYMBOL (request_module); +EXPORT_SYMBOL (__request_module);#endif /* CONFIG_MODULES */ struct subprocess_info {
kernel/module.c +161 -113
567 lines not on this page · raw message
kernel/params.c +25 -1
@@ -24,6 +24,9 @@#include <linux/err.h> #include <linux/slab.h> +/* We abuse the high bits of "perm" to record whether we kmalloc'ed. */ +#define KPARAM_KMALLOCED 0x80000000 +#if 0 #define DEBUGP printk#else
@@ -217,7 +220,19 @@ int param_set_charp(const char *val, struct kernel_param *kp)return -ENOSPC ; } - *(char **)kp->arg = (char *)val; +if (kp->perm &KPARAM_KMALLOCED ) +kfree (*(char **)kp->arg); + +/* This is a hack. We can't need to strdup in early boot, and we +* don't need to; this mangled commandline is preserved. */ +if (slab_is_available ()) { + kp->perm |=KPARAM_KMALLOCED ; + *(char **)kp->arg =kstrdup (val,GFP_KERNEL ); +if (!kp->arg) +return -ENOMEM ; + }else + *(const char **)kp->arg = val; +return 0 ; }
@@ -571,6 +586,15 @@ void module_param_sysfs_remove(struct module *mod) }#endif +void destroy_params (const struct kernel_param *params,unsigned num) +{ +unsigned int i; + +for (i =0 ; i < num; i++) +if (params[i].perm &KPARAM_KMALLOCED ) +kfree (*(char **)params[i].arg); +} +static void __init kernel_add_sysfs_param (const char *name,struct kernel_param *kparam,unsigned int name_skip)
scripts/mod/modpost.c +2 -2
@@ -1607,12 +1607,12 @@ static void read_symbols(char *modname)parse_elf_finish (&info); -/* Our trick to get versioning for struct_module - it's +/* Our trick to get versioning for module struct etc. - it's * never passed as an argument to an exported function, so * the automatic versioning doesn't pick it up, but it's really * important anyhow */ if (modversions) - mod->unres =alloc_symbol ("struct_module" ,0 , mod->unres); + mod->unres =alloc_symbol ("module_layout" ,0 , mod->unres); }#define SZ 500
Quoted 11 lines · Rusty Russell
The following changes since commit
0d34fb8e93ceba7b6dad0062dbb4a0813bacd75b:
Linus Torvalds (1):Merge branch 'bzip2-lzma-for-linus' of git://git.kernel.org/.../x86/linux-2.6-tipare available in the git repository at:
ssh://master.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-module-and-param.git master
Arjan van de Ven (3):
module: create arequest_module_nowait()
use the newrequest_module_nowait()in the hid driver
[ ... ]
Quoted 6 lines
commit
743b7e3627cbcd5b04b2d1878b1c6b39e357173eAuthor: Arjan van de Ven <[email protected]> Date: Sun Feb 8 10:42:40 2009 -0800use the new
request_module_nowait()in the hid driver
Quoted 8 lines
Now that there is a
request_module_nowait(), use it in the hid driver. This gets rid of a kernel thread, and also greatly simplifies the code...Signed-off-by Arjan van de Ven <[email protected]>Signed-off-by Rusty Russell <[email protected]>drivers/hid/hid-core.c | 19 +------------------ 1 files changed, 1 insertions(+), 18 deletions(-)
Having noticed that Linus hasn't pulled this yet ... Rusty, you can safely drop this one. I am currently preparing pull request for HID, which will remove the whole hid-dummy stuff altogether, so all this will be removed anyway (this is what Stephen has his extra patch in linux-next).
So if you drop this before Linus pulls, it will save us one conflict.
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
Quoted 29 lines · On Tuesday 31 March 2009 06:42:42 Jiri Kosina wrote:
Quoted 11 lines · Rusty Russell
The following changes since commit
0d34fb8e93ceba7b6dad0062dbb4a0813bacd75b:
Linus Torvalds (1):Merge branch 'bzip2-lzma-for-linus' of git://git.kernel.org/.../x86/linux-2.6-tipare available in the git repository at:
ssh://master.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-module-and-param.git master
Arjan van de Ven (3):
module: create arequest_module_nowait()
use the newrequest_module_nowait()in the hid driver[ ... ]
Quoted 6 lines
commit
743b7e3627cbcd5b04b2d1878b1c6b39e357173eAuthor: Arjan van de Ven <[email protected]> Date: Sun Feb 8 10:42:40 2009 -0800use the new
request_module_nowait()in the hid driverQuoted 8 lines
Now that there is a
request_module_nowait(), use it in the hid driver. This gets rid of a kernel thread, and also greatly simplifies the code...Signed-off-by Arjan van de Ven <[email protected]>Signed-off-by Rusty Russell <[email protected]>drivers/hid/hid-core.c | 19 +------------------ 1 files changed, 1 insertions(+), 18 deletions(-)
Quoted 6 lines
Having noticed that Linus hasn't pulled this yet ... Rusty, you can safely drop this one. I am currently preparing pull request for HID, which will remove the whole hid-dummy stuff altogether, so all this will be removed anyway (this is what Stephen has his extra patch in linux-next).
So if you drop this before Linus pulls, it will save us one conflict.
Sure! The other use-request_module_nowait patch also has clashes, so I dropped that too.
Should be easy for Arjan to respin and re-send once request_module_nowait is in.
Thanks!
Rusty.
Rusty Russell
Tested-by Frederic Weisbecker Tested-by Christof Schmitt Tested-by Kay Sievers Acked-by Russell King[PULL] module and parameter patches (minus a couple of conflicting changes)
In reply to Jiri KosinaThe following changes since commit 15f7176eb1cccec0a332541285ee752b935c1c85:
Linus Torvalds (1):
Merge git://git.kernel.org/.../davem/net-2.6
are available in the git repository at:
ssh://master.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-module-and-param.git master
Américo Wang (1):
kernel/module.c: fix an unused goto label
Anders Kaseorg (1):
Ksplice: Add functions for walking kallsyms symbols
Arjan van de Ven (1):
module: create a request_module_nowait()
Rusty Russell (10):
param: fix charp parameters set via sysfs
module: __module_address
module: remove module_text_address()
module: clarify the force-loading taint message.
module: remove the SHF_ALLOC flag on the __versions section.
module: include other structures in module version check
module: don't use stop_machine on module load
arm: allow usage of string functions in linux/string.h
strstarts: helper function for !strncmp(str, prefix, strlen(prefix))
module: use strstarts()
Tim Abbott (2):
module: Make find_symbol return a struct kernel_symbol
module: Export symbols needed for Ksplice
arch/arm/boot/compressed/misc.c | 5 +- drivers/mtd/nand/nand_base.c | 4 +- include/linux/kallsyms.h | 15 ++ include/linux/kmod.h | 11 +- include/linux/module.h | 63 ++++++++- include/linux/moduleparam.h | 10 ++ include/linux/string.h | 9 ++ kernel/extable.c | 6 +- kernel/kallsyms.c | 19 +++ kernel/kmod.c | 10 +- kernel/module.c | 274 +++++++++++++++++++++++---------------- kernel/params.c | 26 ++++- scripts/mod/modpost.c | 4 +- 13 files changed, 319 insertions(+), 137 deletions(-)
commit e180a6b7759a99a28cbcce3547c4c80822cb6c2a
Author: Rusty Russell <[email protected]> Date: Tue Mar 31 13:05:29 2009 -0600
param: fix charp parameters set via sysfs
Impact: fix crash on reading from /sys/module/.../ieee80211_default_rc_algo
The module_param type "charp" simply sets a char * pointer in the module to the parameter in the commandline string: this is why we keep the (mangled) module command line around. But when set via sysfs (as about 11 charp parameters can be) this memory is freed on the way out of the write(). Future reads hit random mem.
So we kstrdup instead: we have to check we're not in early commandline parsing, and we have to note when we've used it so we can reliably kfree the parameter when it's next overwritten, and also on module unload.
(Thanks to Randy Dunlap for CONFIG_SYSFS=n fixes)
include/linux/module.h | 4 ++++ include/linux/moduleparam.h | 10 ++++++++++ kernel/module.c | 14 ++++++++------ kernel/params.c | 26 +++++++++++++++++++++++++- 4 files changed, 47 insertions(+), 7 deletions(-)
commit b10153fe31dde3805f8320b61ef147cebe379aee
Author: Américo Wang <[email protected]> Date: Wed Mar 25 00:07:19 2009 +0800
kernel/module.c: fix an unused goto label
Impact: cleanup
Label 'free_init' is only used when defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP), so move it inside to shut up gcc.
kernel/module.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
commit 414fd31b2553aaf160ca9b9afe45aa0372b01b92
Author: Tim Abbott <[email protected]> Date: Fri Dec 5 19:03:56 2008 -0500
module: Make find_symbol return a struct kernel_symbol
Impact: Cleanup, internal API change
Ksplice needs access to the kernel_symbol structure in order to support modifications to the exported symbol table.
kernel/module.c | 75 +++++++++++++++++++++++++++---------------------------- 1 files changed, 37 insertions(+), 38 deletions(-)
commit e610499e2656e61975affd0af56b26eb73964c84
Author: Rusty Russell <[email protected]> Date: Tue Mar 31 13:05:31 2009 -0600
module: __module_address
Impact: New API, cleanup
ksplice wants to know the bounds of a module, not just the module text.
It makes sense to have __module_address. We then implement is_module_address and __module_text_address in terms of this (and change is_module_text_address() to bool while we're at it).
Also, add proper kerneldoc for them all.
include/linux/module.h | 20 +++++++++--- kernel/module.c | 76 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 73 insertions(+), 23 deletions(-)
commit a6e6abd575fcbe6572ebc7a70ad616406d206fa8
Author: Rusty Russell <[email protected]> Date: Tue Mar 31 13:05:31 2009 -0600
module: remove module_text_address()
Impact: Replace and remove risky (non-EXPORTed) API
module_text_address() returns a pointer to the module, which given locking improvements in module.c, is useless except to test for NULL:
1) If the module can't go away, use __module_text_address.
2) Otherwise, just use is_module_text_address().
drivers/mtd/nand/nand_base.c | 4 ++-- include/linux/module.h | 7 ------- kernel/extable.c | 6 +++--- kernel/module.c | 17 ++++------------- 4 files changed, 9 insertions(+), 25 deletions(-)
commit 75a66614db21007bcc8c37f9c5d5b922981387b9
Author: Anders Kaseorg <[email protected]> Date: Fri Dec 5 19:03:58 2008 -0500
Ksplice: Add functions for walking kallsyms symbols
Impact: New API
kallsyms_lookup_name only returns the first match that it finds. Ksplice needs information about all symbols with a given name in order to correctly resolve local symbols.
kallsyms_on_each_symbol provides a generic mechanism for iterating over the kallsyms table.
include/linux/kallsyms.h | 15 +++++++++++++++ include/linux/module.h | 12 ++++++++++++ kernel/kallsyms.c | 19 +++++++++++++++++++ kernel/module.c | 19 +++++++++++++++++++ 4 files changed, 65 insertions(+), 0 deletions(-)
commit c6b37801911d7f4663c99cad8aa230bc934cea82
Author: Tim Abbott <[email protected]> Date: Fri Dec 5 19:03:59 2008 -0500
module: Export symbols needed for Ksplice
Impact: Expose some module.c symbols
Ksplice uses several functions from module.c in order to resolve symbols and implement dependency handling. Calling these functions requires holding module_mutex, so it is exported.
(This is just the module part of a bigger add-exports patch from Tim).
include/linux/module.h | 28 ++++++++++++++++++++++++++++ kernel/module.c | 43 +++++++++++++++++++------------------------ 2 files changed, 47 insertions(+), 24 deletions(-)
commit c6e665c8f0c18ab3686117905765b5139efd6ebd
Author: Rusty Russell <[email protected]> Date: Tue Mar 31 13:05:33 2009 -0600
module: clarify the force-loading taint message.
Impact: Message cleanup
Two of three callers of try_to_force_load() are not because of a missing version, so change the messages:
Old:
<modname>: no version for "magic" found: kernel tainted.
New:
<modname>: bad vermagic: kernel tainted.
Old:
<modname>: no version for "nocrc" found: kernel tainted.
New:
<modname>: no versions for exported symbols: kernel tainted.
Old:
<modname>: no version for "<symname>" found: kernel tainted.
New:
<modname>: <symname>: kernel tainted.
kernel/module.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
commit 9cb610d8e35fe3ec95a2fe2030b02f85aeea83c1
Author: Rusty Russell <[email protected]> Date: Tue Mar 31 13:05:33 2009 -0600
module: remove the SHF_ALLOC flag on the __versions section.
Impact: reduce kernel memory usage
This patch just takes off the SHF_ALLOC flag on __versions so we don't keep them around after module load.
This saves about 7% of module memory if CONFIG_MODVERSIONS=y.
kernel/module.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
commit 8c8ef42aee8fcfb4128bb94c50d55c9f80ade525
Author: Rusty Russell <[email protected]> Date: Tue Mar 31 13:05:34 2009 -0600
module: include other structures in module version check
With CONFIG_MODVERSIONS, we version 'struct module' using a dummy export, but other things matter too:
1) 'struct modversion_info' determines the layout of the __versions section,
2) 'struct kernel_param' determines the layout of the __params section,
3) 'struct kernel_symbol' determines __ksymtab*.
4) 'struct marker' determines __markers.
5) 'struct tracepoint' determines __tracepoints.
So we rename 'struct_module' to 'module_layout' and include these in the signature. Now it's general we can add others later on without confusion.
kernel/module.c | 18 +++++++++++++----- scripts/mod/modpost.c | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-)
commit acae05156551fd7528fbb616271e672789388e3c
Author: Arjan van de Ven <[email protected]> Date: Sun Feb 8 10:42:01 2009 -0800
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)
include/linux/kmod.h | 11 ++++++++--- kernel/kmod.c | 10 ++++++---- 2 files changed, 14 insertions(+), 7 deletions(-)
commit e91defa26c527ceeaff6266c55cdc7e17c9081a2
Author: Rusty Russell <[email protected]> Date: Tue Mar 31 13:05:35 2009 -0600
module: don't use stop_machine on module load
Kay Sievers <[email protected]> discovered that boot times are slowed by about half a second because all the stop_machine_create() calls, and he only probes about 40 modules (I have 125 loaded on this laptop).
We only do stop_machine_create() so we can unlink the module if something goes wrong, but it's overkill (and buggy anyway: if stop_machine_create() fails we still call stop_machine_destroy()).
Since we are only protecting against kallsyms (esp. oops) walking the list, synchronize_sched() is sufficient (synchronize_rcu() is probably sufficient, but we're not in a hurry).
Kay says of this patch:
... no module takes more than 40 millisecs to link now, most of them are between 3 and 8 millisecs.
That looks very different to the numbers without this patch and the otherwise same setup, where we get heavy noise in the traces and many delays of up to 200 millisecs until linking, most of them taking 30+ millisecs.
kernel/module.c | 12 +++--------- 1 files changed, 3 insertions(+), 9 deletions(-)
commit aa0d3bb77e780054babcd289484cf4c15180111b
Author: Rusty Russell <[email protected]> Date: Tue Mar 31 13:05:35 2009 -0600
arm: allow usage of string functions in linux/string.h
In introducing a trivial "strstarts()" function in linux/string.h, we hit:
arch/arm/boot/compressed/misc.o: In function `strstarts':
misc.c:(.text+0x368): undefined reference to strlen' misc.c:(.text+0x378): undefined reference to strncmp'
This is because of "CFLAGS_misc.o := -Dstatic=" in the Makefile. "static inline strstarts(...)" becomes non-inline, and refers to the other string ops.
The simplest workaround is to include asm/string.h. This makes sense anyway, since lib/string.c won't be linked against this so we can't use those functions anyway.
Compile tested here.
arch/arm/boot/compressed/misc.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
commit 66f92cf9d415e96a5bdd6c64de8dd8418595d2fc
Author: Rusty Russell <[email protected]> Date: Tue Mar 31 13:05:36 2009 -0600
strstarts: helper function for !strncmp(str, prefix, strlen(prefix))
Impact: minor new API
ksplice added a "starts_with" function, which seems like a common need. When people open-code it they seem to use fixed numbers rather than strlen, so it's quite a readability win (also, strncmp() almost always wants != 0 on it).
So here's strstarts().
include/linux/string.h | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
commit 49502677e11079c2e3e01867c922a894ce06a8be
Author: Rusty Russell <[email protected]> Date: Tue Mar 31 13:05:36 2009 -0600
module: use strstarts()
Impact: minor cleanup.
I'm not going to neaten anyone else's code, but I'm happy to clean up my own.
kernel/module.c | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-)