Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 297042
b: refs/heads/master
c: d53799b
h: refs/heads/master
v: v3
  • Loading branch information
Steven Rostedt authored and Rusty Russell committed Mar 26, 2012
1 parent d4d4136 commit dab0338
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 026cee0086fe1df4cf74691cf273062cc769617d
refs/heads/master: d53799be6758841e1ffb1fd3780f73d0ffe44432
32 changes: 4 additions & 28 deletions trunk/include/linux/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include <linux/percpu.h>
#include <asm/module.h>

#include <trace/events/module.h>

/* Not Yet Implemented */
#define MODULE_SUPPORTED_DEVICE(name)

Expand Down Expand Up @@ -452,33 +450,11 @@ void symbol_put_addr(void *addr);

/* Sometimes we know we already have a refcount, and it's easier not
to handle the error case (which only happens with rmmod --wait). */
static inline 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)
{
int ret = 1;

if (module) {
preempt_disable();
extern void __module_get(struct module *module);

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;
}
/* This is the Right Way to get a module: if it fails, it's being removed,
* so pretend it's not there. */
extern bool try_module_get(struct module *module);

extern void module_put(struct module *module);

Expand Down
30 changes: 30 additions & 0 deletions trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,36 @@ static ssize_t show_refcnt(struct module_attribute *mattr,
static struct module_attribute modinfo_refcnt =
__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)
{
if (module) {
Expand Down

0 comments on commit dab0338

Please sign in to comment.