lkml.org 
[lkml]   [2012]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [RFC][PATCH] tracing/module: Move tracepoint out of module.h
Date
On Mon, 30 Jan 2012 06:52:13 -0500, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Fri, 2012-01-27 at 13:32 +1030, Rusty Russell wrote:
> > On Thu, 26 Jan 2012 19:39:46 +0100, Ingo Molnar <mingo@elte.hu> wrote:
> > > Ok, i like this one best. Rusty, does it look good to you too?
> >
> > No, the if (module) test belongs in the inline wrapper (since gcc knows
> > that at compile time).
>
> For some reason though it still adds 5K when we keep the code as a
> static inline. Note, my test config does have all the necessary modules
> to boot the box as compiled in (not as modules). If necessary, I could
> compile with a distro config and see what the differences are with that.
>
> Rusty, the final decision is yours. If you believe that the added code
> size is worth having the static inlines, then I'll go back to the
> previous version that had that.

Wow, we're really bikeshedding this!

I was completely wrong with the "it's usually a constant" of course;
it's usually ->owner.

So let's just out-of-line the entire thing. I changed the type to bool
and s/_THIS_IP_/_RET_IP_/ -- is that sufficient?

Doesn't save me much here, though. What are your stats?


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

With the preempt, tracepoint and everything, it's getting a bit
chubby.

Saves only 400 bytes of text here, but I don't do preempt or
tracepoints.

Before:
text data bss dec hex filename
5373459 399532 2514944 8287935 7e76bf vmlinux

After:
text data bss dec hex filename
5373071 399532 2514944 8287547 7e753b vmlinux

diff --git a/include/linux/module.h b/include/linux/module.h
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -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)

@@ -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();
- }
-}
+extern void __module_get(struct module *module);

-static inline int try_module_get(struct module *module)
-{
- int ret = 1;
-
- 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;
-}
+/* 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);

diff --git a/kernel/module.c b/kernel/module.c
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -903,6 +903,36 @@ static ssize_t show_refcnt(struct module
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) {

\
 
 \ /
  Last update: 2012-01-31 11:01    [W:0.098 / U:0.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site