Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

module: move __module_get and try_module_get() out of line.

With the preempt, tracepoint and everything, it's getting a bit
chubby. For an Ubuntu-based config:

Before:
$ size -t `find * -name '*.ko'` | grep TOTAL
56199906 3870760 1606616 61677282 3ad1ee2 (TOTALS)
$ size vmlinux
text data bss dec hex filename
8509342 850368 3358720 12718430 c2115e vmlinux

After:
$ size -t `find * -name '*.ko'` | grep TOTAL
56183760 3867892 1606616 61658268 3acd49c (TOTALS)
$ size vmlinux
text data bss dec hex filename
8501842 849088 3358720 12709650 c1ef12 vmlinux

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (made all out-of-line)

authored by

Steven Rostedt and committed by
Rusty Russell
d53799be 026cee00

+34 -28
+4 -28
include/linux/module.h
··· 21 21 #include <linux/percpu.h> 22 22 #include <asm/module.h> 23 23 24 - #include <trace/events/module.h> 25 - 26 24 /* Not Yet Implemented */ 27 25 #define MODULE_SUPPORTED_DEVICE(name) 28 26 ··· 450 452 451 453 /* Sometimes we know we already have a refcount, and it's easier not 452 454 to handle the error case (which only happens with rmmod --wait). */ 453 - static inline void __module_get(struct module *module) 454 - { 455 - if (module) { 456 - preempt_disable(); 457 - __this_cpu_inc(module->refptr->incs); 458 - trace_module_get(module, _THIS_IP_); 459 - preempt_enable(); 460 - } 461 - } 455 + extern void __module_get(struct module *module); 462 456 463 - static inline int try_module_get(struct module *module) 464 - { 465 - int ret = 1; 466 - 467 - if (module) { 468 - preempt_disable(); 469 - 470 - if (likely(module_is_live(module))) { 471 - __this_cpu_inc(module->refptr->incs); 472 - trace_module_get(module, _THIS_IP_); 473 - } else 474 - ret = 0; 475 - 476 - preempt_enable(); 477 - } 478 - return ret; 479 - } 457 + /* This is the Right Way to get a module: if it fails, it's being removed, 458 + * so pretend it's not there. */ 459 + extern bool try_module_get(struct module *module); 480 460 481 461 extern void module_put(struct module *module); 482 462
+30
kernel/module.c
··· 904 904 static struct module_attribute modinfo_refcnt = 905 905 __ATTR(refcnt, 0444, show_refcnt, NULL); 906 906 907 + void __module_get(struct module *module) 908 + { 909 + if (module) { 910 + preempt_disable(); 911 + __this_cpu_inc(module->refptr->incs); 912 + trace_module_get(module, _RET_IP_); 913 + preempt_enable(); 914 + } 915 + } 916 + EXPORT_SYMBOL(__module_get); 917 + 918 + bool try_module_get(struct module *module) 919 + { 920 + bool ret = true; 921 + 922 + if (module) { 923 + preempt_disable(); 924 + 925 + if (likely(module_is_live(module))) { 926 + __this_cpu_inc(module->refptr->incs); 927 + trace_module_get(module, _RET_IP_); 928 + } else 929 + ret = false; 930 + 931 + preempt_enable(); 932 + } 933 + return ret; 934 + } 935 + EXPORT_SYMBOL(try_module_get); 936 + 907 937 void module_put(struct module *module) 908 938 { 909 939 if (module) {