Commit c345f60a authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'core-debugobjects-for-linus' of...

Merge branch 'core-debugobjects-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'core-debugobjects-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  debugobjects: Add hint for better object identification
parents 422e6c4b 99777288
...@@ -34,7 +34,10 @@ struct debug_obj { ...@@ -34,7 +34,10 @@ struct debug_obj {
/** /**
* struct debug_obj_descr - object type specific debug description structure * struct debug_obj_descr - object type specific debug description structure
*
* @name: name of the object typee * @name: name of the object typee
* @debug_hint: function returning address, which have associated
* kernel symbol, to allow identify the object
* @fixup_init: fixup function, which is called when the init check * @fixup_init: fixup function, which is called when the init check
* fails * fails
* @fixup_activate: fixup function, which is called when the activate check * @fixup_activate: fixup function, which is called when the activate check
...@@ -46,7 +49,7 @@ struct debug_obj { ...@@ -46,7 +49,7 @@ struct debug_obj {
*/ */
struct debug_obj_descr { struct debug_obj_descr {
const char *name; const char *name;
void *(*debug_hint) (void *addr);
int (*fixup_init) (void *addr, enum debug_obj_state state); int (*fixup_init) (void *addr, enum debug_obj_state state);
int (*fixup_activate) (void *addr, enum debug_obj_state state); int (*fixup_activate) (void *addr, enum debug_obj_state state);
int (*fixup_destroy) (void *addr, enum debug_obj_state state); int (*fixup_destroy) (void *addr, enum debug_obj_state state);
......
...@@ -334,6 +334,11 @@ EXPORT_SYMBOL_GPL(ktime_add_safe); ...@@ -334,6 +334,11 @@ EXPORT_SYMBOL_GPL(ktime_add_safe);
static struct debug_obj_descr hrtimer_debug_descr; static struct debug_obj_descr hrtimer_debug_descr;
static void *hrtimer_debug_hint(void *addr)
{
return ((struct hrtimer *) addr)->function;
}
/* /*
* fixup_init is called when: * fixup_init is called when:
* - an active object is initialized * - an active object is initialized
...@@ -393,6 +398,7 @@ static int hrtimer_fixup_free(void *addr, enum debug_obj_state state) ...@@ -393,6 +398,7 @@ static int hrtimer_fixup_free(void *addr, enum debug_obj_state state)
static struct debug_obj_descr hrtimer_debug_descr = { static struct debug_obj_descr hrtimer_debug_descr = {
.name = "hrtimer", .name = "hrtimer",
.debug_hint = hrtimer_debug_hint,
.fixup_init = hrtimer_fixup_init, .fixup_init = hrtimer_fixup_init,
.fixup_activate = hrtimer_fixup_activate, .fixup_activate = hrtimer_fixup_activate,
.fixup_free = hrtimer_fixup_free, .fixup_free = hrtimer_fixup_free,
......
...@@ -404,6 +404,11 @@ static void timer_stats_account_timer(struct timer_list *timer) {} ...@@ -404,6 +404,11 @@ static void timer_stats_account_timer(struct timer_list *timer) {}
static struct debug_obj_descr timer_debug_descr; static struct debug_obj_descr timer_debug_descr;
static void *timer_debug_hint(void *addr)
{
return ((struct timer_list *) addr)->function;
}
/* /*
* fixup_init is called when: * fixup_init is called when:
* - an active object is initialized * - an active object is initialized
...@@ -477,6 +482,7 @@ static int timer_fixup_free(void *addr, enum debug_obj_state state) ...@@ -477,6 +482,7 @@ static int timer_fixup_free(void *addr, enum debug_obj_state state)
static struct debug_obj_descr timer_debug_descr = { static struct debug_obj_descr timer_debug_descr = {
.name = "timer_list", .name = "timer_list",
.debug_hint = timer_debug_hint,
.fixup_init = timer_fixup_init, .fixup_init = timer_fixup_init,
.fixup_activate = timer_fixup_activate, .fixup_activate = timer_fixup_activate,
.fixup_free = timer_fixup_free, .fixup_free = timer_fixup_free,
......
...@@ -316,6 +316,11 @@ static inline int __next_wq_cpu(int cpu, const struct cpumask *mask, ...@@ -316,6 +316,11 @@ static inline int __next_wq_cpu(int cpu, const struct cpumask *mask,
static struct debug_obj_descr work_debug_descr; static struct debug_obj_descr work_debug_descr;
static void *work_debug_hint(void *addr)
{
return ((struct work_struct *) addr)->func;
}
/* /*
* fixup_init is called when: * fixup_init is called when:
* - an active object is initialized * - an active object is initialized
...@@ -387,6 +392,7 @@ static int work_fixup_free(void *addr, enum debug_obj_state state) ...@@ -387,6 +392,7 @@ static int work_fixup_free(void *addr, enum debug_obj_state state)
static struct debug_obj_descr work_debug_descr = { static struct debug_obj_descr work_debug_descr = {
.name = "work_struct", .name = "work_struct",
.debug_hint = work_debug_hint,
.fixup_init = work_fixup_init, .fixup_init = work_fixup_init,
.fixup_activate = work_fixup_activate, .fixup_activate = work_fixup_activate,
.fixup_free = work_fixup_free, .fixup_free = work_fixup_free,
......
...@@ -249,14 +249,17 @@ static struct debug_bucket *get_bucket(unsigned long addr) ...@@ -249,14 +249,17 @@ static struct debug_bucket *get_bucket(unsigned long addr)
static void debug_print_object(struct debug_obj *obj, char *msg) static void debug_print_object(struct debug_obj *obj, char *msg)
{ {
struct debug_obj_descr *descr = obj->descr;
static int limit; static int limit;
if (limit < 5 && obj->descr != descr_test) { if (limit < 5 && descr != descr_test) {
void *hint = descr->debug_hint ?
descr->debug_hint(obj->object) : NULL;
limit++; limit++;
WARN(1, KERN_ERR "ODEBUG: %s %s (active state %u) " WARN(1, KERN_ERR "ODEBUG: %s %s (active state %u) "
"object type: %s\n", "object type: %s hint: %pS\n",
msg, obj_states[obj->state], obj->astate, msg, obj_states[obj->state], obj->astate,
obj->descr->name); descr->name, hint);
} }
debug_objects_warnings++; debug_objects_warnings++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment