]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
debugobjects: be smarter about static objects
authorStephen Boyd <sboyd@codeaurora.org>
Wed, 16 Nov 2011 23:41:11 +0000 (10:41 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 17 Nov 2011 02:53:22 +0000 (13:53 +1100)
Remove the WARN_ON() in timer_fixup_activate() and actually use the return
code from fixup to tell the debugobjects code to print a warning.  This
provides better diagnostic information via a nice debugobjects warning
instead of a simple WARN_ON(1) in the timer code with no information as to
what is wrong.  We also assign a dummy timer callback so that if the timer
is actually set to fire we don't oops.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Cc: Christine Chan <cschan@codeaurora.org>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/timer.c
lib/debugobjects.c

index dbaa62422b13c057754252d986f97440ec7dd3af..317087d5d5fc318776ea4654f955ec5a6722e89b 100644 (file)
@@ -427,6 +427,12 @@ static int timer_fixup_init(void *addr, enum debug_obj_state state)
        }
 }
 
+/* Stub timer callback for improperly used timers. */
+static void stub_timer(unsigned long data)
+{
+       WARN_ON(1);
+}
+
 /*
  * fixup_activate is called when:
  * - an active object is activated
@@ -450,7 +456,8 @@ static int timer_fixup_activate(void *addr, enum debug_obj_state state)
                        debug_object_activate(timer, &timer_debug_descr);
                        return 0;
                } else {
-                       WARN_ON_ONCE(1);
+                       setup_timer(timer, stub_timer, 0);
+                       return 1;
                }
                return 0;
 
index a78b7c6e042c9f64fb76bcb252236c456bf8a6a0..0b07cc5ba23715f5eb2ccc9b15aac56597a8db22 100644 (file)
@@ -268,12 +268,15 @@ static void debug_print_object(struct debug_obj *obj, char *msg)
  * Try to repair the damage, so we have a better chance to get useful
  * debug output.
  */
-static void
+static int
 debug_object_fixup(int (*fixup)(void *addr, enum debug_obj_state state),
                   void * addr, enum debug_obj_state state)
 {
+       int fixed = 0;
        if (fixup)
-               debug_objects_fixups += fixup(addr, state);
+               fixed = fixup(addr, state);
+       debug_objects_fixups += fixed;
+       return fixed;
 }
 
 static void debug_object_is_on_stack(void *addr, int onstack)
@@ -386,6 +389,9 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr)
        struct debug_bucket *db;
        struct debug_obj *obj;
        unsigned long flags;
+       struct debug_obj o = { .object = addr,
+                              .state = ODEBUG_STATE_NOTAVAILABLE,
+                              .descr = descr };
 
        if (!debug_objects_enabled)
                return;
@@ -425,8 +431,9 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr)
         * let the type specific code decide whether this is
         * true or not.
         */
-       debug_object_fixup(descr->fixup_activate, addr,
-                          ODEBUG_STATE_NOTAVAILABLE);
+       if (debug_object_fixup(descr->fixup_activate, addr,
+                          ODEBUG_STATE_NOTAVAILABLE))
+               debug_print_object(&o, "activate");
 }
 
 /**