module: make module_refcount() a signed integer.
James Bottomley points out that it will be -1 during unload. It's only used for diagnostics, so let's not hide that as it could be a clue as to what's gone wrong. Cc: Jason Wessel <jason.wessel@windriver.com> Acked-and-documention-added-by: James Bottomley <James.Bottomley@HansenPartnership.com> Reviewed-by: Masami Hiramatsu <maasami.hiramatsu.pt@hitachi.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -772,9 +772,18 @@ static int try_stop_module(struct module *mod, int flags, int *forced)
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long module_refcount(struct module *mod)
|
||||
/**
|
||||
* module_refcount - return the refcount or -1 if unloading
|
||||
*
|
||||
* @mod: the module we're checking
|
||||
*
|
||||
* Returns:
|
||||
* -1 if the module is in the process of unloading
|
||||
* otherwise the number of references in the kernel to the module
|
||||
*/
|
||||
int module_refcount(struct module *mod)
|
||||
{
|
||||
return (unsigned long)atomic_read(&mod->refcnt) - MODULE_REF_BASE;
|
||||
return atomic_read(&mod->refcnt) - MODULE_REF_BASE;
|
||||
}
|
||||
EXPORT_SYMBOL(module_refcount);
|
||||
|
||||
@@ -856,7 +865,7 @@ static inline void print_unload_info(struct seq_file *m, struct module *mod)
|
||||
struct module_use *use;
|
||||
int printed_something = 0;
|
||||
|
||||
seq_printf(m, " %lu ", module_refcount(mod));
|
||||
seq_printf(m, " %i ", module_refcount(mod));
|
||||
|
||||
/*
|
||||
* Always include a trailing , so userspace can differentiate
|
||||
@@ -908,7 +917,7 @@ EXPORT_SYMBOL_GPL(symbol_put_addr);
|
||||
static ssize_t show_refcnt(struct module_attribute *mattr,
|
||||
struct module_kobject *mk, char *buffer)
|
||||
{
|
||||
return sprintf(buffer, "%lu\n", module_refcount(mk->mod));
|
||||
return sprintf(buffer, "%i\n", module_refcount(mk->mod));
|
||||
}
|
||||
|
||||
static struct module_attribute modinfo_refcnt =
|
||||
|
Reference in New Issue
Block a user