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)
This commit is contained in:
parent
026cee0086
commit
d53799be67
2 changed files with 34 additions and 28 deletions
|
@ -21,8 +21,6 @@
|
||||||
#include <linux/percpu.h>
|
#include <linux/percpu.h>
|
||||||
#include <asm/module.h>
|
#include <asm/module.h>
|
||||||
|
|
||||||
#include <trace/events/module.h>
|
|
||||||
|
|
||||||
/* Not Yet Implemented */
|
/* Not Yet Implemented */
|
||||||
#define MODULE_SUPPORTED_DEVICE(name)
|
#define MODULE_SUPPORTED_DEVICE(name)
|
||||||
|
|
||||||
|
@ -452,33 +450,11 @@ void symbol_put_addr(void *addr);
|
||||||
|
|
||||||
/* Sometimes we know we already have a refcount, and it's easier not
|
/* Sometimes we know we already have a refcount, and it's easier not
|
||||||
to handle the error case (which only happens with rmmod --wait). */
|
to handle the error case (which only happens with rmmod --wait). */
|
||||||
static inline void __module_get(struct module *module)
|
extern void __module_get(struct module *module);
|
||||||
{
|
|
||||||
if (module) {
|
|
||||||
preempt_disable();
|
|
||||||
__this_cpu_inc(module->refptr->incs);
|
|
||||||
trace_module_get(module, _THIS_IP_);
|
|
||||||
preempt_enable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int try_module_get(struct module *module)
|
/* This is the Right Way to get a module: if it fails, it's being removed,
|
||||||
{
|
* so pretend it's not there. */
|
||||||
int ret = 1;
|
extern bool try_module_get(struct module *module);
|
||||||
|
|
||||||
if (module) {
|
|
||||||
preempt_disable();
|
|
||||||
|
|
||||||
if (likely(module_is_live(module))) {
|
|
||||||
__this_cpu_inc(module->refptr->incs);
|
|
||||||
trace_module_get(module, _THIS_IP_);
|
|
||||||
} else
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
preempt_enable();
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern void module_put(struct module *module);
|
extern void module_put(struct module *module);
|
||||||
|
|
||||||
|
|
|
@ -904,6 +904,36 @@ static ssize_t show_refcnt(struct module_attribute *mattr,
|
||||||
static struct module_attribute modinfo_refcnt =
|
static struct module_attribute modinfo_refcnt =
|
||||||
__ATTR(refcnt, 0444, show_refcnt, NULL);
|
__ATTR(refcnt, 0444, show_refcnt, NULL);
|
||||||
|
|
||||||
|
void __module_get(struct module *module)
|
||||||
|
{
|
||||||
|
if (module) {
|
||||||
|
preempt_disable();
|
||||||
|
__this_cpu_inc(module->refptr->incs);
|
||||||
|
trace_module_get(module, _RET_IP_);
|
||||||
|
preempt_enable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(__module_get);
|
||||||
|
|
||||||
|
bool try_module_get(struct module *module)
|
||||||
|
{
|
||||||
|
bool ret = true;
|
||||||
|
|
||||||
|
if (module) {
|
||||||
|
preempt_disable();
|
||||||
|
|
||||||
|
if (likely(module_is_live(module))) {
|
||||||
|
__this_cpu_inc(module->refptr->incs);
|
||||||
|
trace_module_get(module, _RET_IP_);
|
||||||
|
} else
|
||||||
|
ret = false;
|
||||||
|
|
||||||
|
preempt_enable();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(try_module_get);
|
||||||
|
|
||||||
void module_put(struct module *module)
|
void module_put(struct module *module)
|
||||||
{
|
{
|
||||||
if (module) {
|
if (module) {
|
||||||
|
|
Loading…
Reference in a new issue