[patch 1/4] lock validator: provide common print_ip_sym()
From: Heiko Carstens
Date: Fri Jun 23 2006 - 09:23:01 EST
From: Heiko Carstens <heiko.carstens@xxxxxxxxxx>
Provide a common print_ip_sym() function that prints the passed instruction
pointer as well as the symbol belonging to it. Avoids adding a bunch of
#ifdef CONFIG_64BIT in order to get the printk format right on 32/64 bit
platforms.
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Arjan van de Ven <arjan@xxxxxxxxxxxxx>
Signed-off-by: Heiko Carstens <heiko.carstens@xxxxxxxxxx>
---
include/linux/kallsyms.h | 14 ++++++++++++++
kernel/lockdep.c | 38 ++++++++++++++------------------------
kernel/stacktrace.c | 4 +---
3 files changed, 29 insertions(+), 27 deletions(-)
Index: linux-2.6.17-mm1/include/linux/kallsyms.h
===================================================================
--- linux-2.6.17-mm1.orig/include/linux/kallsyms.h
+++ linux-2.6.17-mm1/include/linux/kallsyms.h
@@ -63,4 +63,18 @@ do { \
__print_symbol(fmt, addr); \
} while(0)
+#ifndef CONFIG_64BIT
+#define print_ip_sym(ip) \
+do { \
+ printk("[<%08lx>]", ip); \
+ print_symbol(" %s\n", ip); \
+} while(0)
+#else
+#define print_ip_sym(ip) \
+do { \
+ printk("[<%016lx>]", ip); \
+ print_symbol(" %s\n", ip); \
+} while(0)
+#endif
+
#endif /*_LINUX_KALLSYMS_H*/
Index: linux-2.6.17-mm1/kernel/lockdep.c
===================================================================
--- linux-2.6.17-mm1.orig/kernel/lockdep.c
+++ linux-2.6.17-mm1/kernel/lockdep.c
@@ -311,12 +311,6 @@ static const char *usage_str[] =
[LOCK_ENABLED_HARDIRQS_READ] = "hardirq-on-R",
};
-static void printk_sym(unsigned long ip)
-{
- printk(" [<%08lx>]", ip);
- print_symbol(" %s\n", ip);
-}
-
const char * __get_key_name(struct lockdep_subtype_key *key, char *str)
{
unsigned long offs, size;
@@ -413,8 +407,8 @@ static void print_lockdep_cache(struct l
static void print_lock(struct held_lock *hlock)
{
print_lock_name(hlock->type);
- printk(", at:");
- printk_sym(hlock->acquire_ip);
+ printk(", at: ");
+ print_ip_sym(hlock->acquire_ip);
}
void lockdep_print_held_locks(struct task_struct *curr)
@@ -468,8 +462,8 @@ void print_lock_type_header(struct lock_
printk(" }\n");
print_spaces(depth);
- printk(" ... key at:");
- printk_sym((unsigned long)type->key);
+ printk(" ... key at: ");
+ print_ip_sym((unsigned long)type->key);
}
/*
@@ -1508,18 +1502,14 @@ check_usage_backwards(struct task_struct
static inline void print_irqtrace_events(struct task_struct *curr)
{
printk("irq event stamp: %u\n", curr->irq_events);
- printk("hardirqs last enabled at (%u): [<%08lx>]",
- curr->hardirq_enable_event, curr->hardirq_enable_ip);
- print_symbol(" %s\n", curr->hardirq_enable_ip);
- printk("hardirqs last disabled at (%u): [<%08lx>]",
- curr->hardirq_disable_event, curr->hardirq_disable_ip);
- print_symbol(" %s\n", curr->hardirq_disable_ip);
- printk("softirqs last enabled at (%u): [<%08lx>]",
- curr->softirq_enable_event, curr->softirq_enable_ip);
- print_symbol(" %s\n", curr->softirq_enable_ip);
- printk("softirqs last disabled at (%u): [<%08lx>]",
- curr->softirq_disable_event, curr->softirq_disable_ip);
- print_symbol(" %s\n", curr->softirq_disable_ip);
+ printk("hardirqs last enabled at (%u): ", curr->hardirq_enable_event);
+ print_ip_sym(curr->hardirq_enable_ip);
+ printk("hardirqs last disabled at (%u): ", curr->hardirq_disable_event);
+ print_ip_sym(curr->hardirq_disable_ip);
+ printk("softirqs last enabled at (%u): ", curr->softirq_enable_event);
+ print_ip_sym(curr->softirq_enable_ip);
+ printk("softirqs last disabled at (%u): ", curr->softirq_disable_event);
+ print_ip_sym(curr->softirq_disable_ip);
}
#else
@@ -2262,7 +2252,7 @@ print_unlock_order_bug(struct task_struc
curr->comm, curr->pid);
print_lockdep_cache(lock);
printk(") at:\n");
- printk_sym(ip);
+ print_ip_sym(ip);
printk("but the next lock to release is:\n");
print_lock(hlock);
printk("\nother info that might help us debug this:\n");
@@ -2292,7 +2282,7 @@ print_unlock_inbalance_bug(struct task_s
curr->comm, curr->pid);
print_lockdep_cache(lock);
printk(") at:\n");
- printk_sym(ip);
+ print_ip_sym(ip);
printk("but there are no more locks to release!\n");
printk("\nother info that might help us debug this:\n");
lockdep_print_held_locks(curr);
Index: linux-2.6.17-mm1/kernel/stacktrace.c
===================================================================
--- linux-2.6.17-mm1.orig/kernel/stacktrace.c
+++ linux-2.6.17-mm1/kernel/stacktrace.c
@@ -18,9 +18,7 @@ void print_stack_trace(struct stack_trac
for (j = 0; j < spaces + 1; j++)
printk(" ");
-
- printk("[<%08lx>]", ip);
- print_symbol(" %s\n", ip);
+ print_ip_sym(ip);
}
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/