Commit 94df491c authored by Linus Torvalds's avatar Linus Torvalds

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

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

* 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  futex: Fix WARN_ON() test for UP
  WARN_ON_SMP(): Allow use in if() statements on UP
  x86, dumpstack: Use %pB format specifier for stack trace
  vsprintf: Introduce %pB format specifier
  lockdep: Remove unused 'factor' variable from lockdep_stats_show()
parents 26ff6801 29096202
...@@ -27,7 +27,7 @@ static int die_counter; ...@@ -27,7 +27,7 @@ static int die_counter;
void printk_address(unsigned long address, int reliable) void printk_address(unsigned long address, int reliable)
{ {
printk(" [<%p>] %s%pS\n", (void *) address, printk(" [<%p>] %s%pB\n", (void *) address,
reliable ? "" : "? ", (void *) address); reliable ? "" : "? ", (void *) address);
} }
......
...@@ -165,10 +165,36 @@ extern void warn_slowpath_null(const char *file, const int line); ...@@ -165,10 +165,36 @@ extern void warn_slowpath_null(const char *file, const int line);
#define WARN_ON_RATELIMIT(condition, state) \ #define WARN_ON_RATELIMIT(condition, state) \
WARN_ON((condition) && __ratelimit(state)) WARN_ON((condition) && __ratelimit(state))
/*
* WARN_ON_SMP() is for cases that the warning is either
* meaningless for !SMP or may even cause failures.
* This is usually used for cases that we have
* WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked()
* returns 0 for uniprocessor settings.
* It can also be used with values that are only defined
* on SMP:
*
* struct foo {
* [...]
* #ifdef CONFIG_SMP
* int bar;
* #endif
* };
*
* void func(struct foo *zoot)
* {
* WARN_ON_SMP(!zoot->bar);
*
* For CONFIG_SMP, WARN_ON_SMP() should act the same as WARN_ON(),
* and should be a nop and return false for uniprocessor.
*
* if (WARN_ON_SMP(x)) returns true only when CONFIG_SMP is set
* and x is true.
*/
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
# define WARN_ON_SMP(x) WARN_ON(x) # define WARN_ON_SMP(x) WARN_ON(x)
#else #else
# define WARN_ON_SMP(x) do { } while (0) # define WARN_ON_SMP(x) ({0;})
#endif #endif
#endif #endif
...@@ -36,6 +36,7 @@ const char *kallsyms_lookup(unsigned long addr, ...@@ -36,6 +36,7 @@ const char *kallsyms_lookup(unsigned long addr,
/* Look up a kernel symbol and return it in a text buffer. */ /* Look up a kernel symbol and return it in a text buffer. */
extern int sprint_symbol(char *buffer, unsigned long address); extern int sprint_symbol(char *buffer, unsigned long address);
extern int sprint_backtrace(char *buffer, unsigned long address);
/* Look up a kernel symbol and print it to the kernel messages. */ /* Look up a kernel symbol and print it to the kernel messages. */
extern void __print_symbol(const char *fmt, unsigned long address); extern void __print_symbol(const char *fmt, unsigned long address);
...@@ -79,6 +80,12 @@ static inline int sprint_symbol(char *buffer, unsigned long addr) ...@@ -79,6 +80,12 @@ static inline int sprint_symbol(char *buffer, unsigned long addr)
return 0; return 0;
} }
static inline int sprint_backtrace(char *buffer, unsigned long addr)
{
*buffer = '\0';
return 0;
}
static inline int lookup_symbol_name(unsigned long addr, char *symname) static inline int lookup_symbol_name(unsigned long addr, char *symname)
{ {
return -ERANGE; return -ERANGE;
......
...@@ -782,8 +782,8 @@ static void __unqueue_futex(struct futex_q *q) ...@@ -782,8 +782,8 @@ static void __unqueue_futex(struct futex_q *q)
{ {
struct futex_hash_bucket *hb; struct futex_hash_bucket *hb;
if (WARN_ON(!q->lock_ptr || !spin_is_locked(q->lock_ptr) if (WARN_ON_SMP(!q->lock_ptr || !spin_is_locked(q->lock_ptr))
|| plist_node_empty(&q->list))) || WARN_ON(plist_node_empty(&q->list)))
return; return;
hb = container_of(q->lock_ptr, struct futex_hash_bucket, lock); hb = container_of(q->lock_ptr, struct futex_hash_bucket, lock);
......
...@@ -342,13 +342,15 @@ int lookup_symbol_attrs(unsigned long addr, unsigned long *size, ...@@ -342,13 +342,15 @@ int lookup_symbol_attrs(unsigned long addr, unsigned long *size,
} }
/* Look up a kernel symbol and return it in a text buffer. */ /* Look up a kernel symbol and return it in a text buffer. */
int sprint_symbol(char *buffer, unsigned long address) static int __sprint_symbol(char *buffer, unsigned long address,
int symbol_offset)
{ {
char *modname; char *modname;
const char *name; const char *name;
unsigned long offset, size; unsigned long offset, size;
int len; int len;
address += symbol_offset;
name = kallsyms_lookup(address, &size, &offset, &modname, buffer); name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
if (!name) if (!name)
return sprintf(buffer, "0x%lx", address); return sprintf(buffer, "0x%lx", address);
...@@ -357,17 +359,53 @@ int sprint_symbol(char *buffer, unsigned long address) ...@@ -357,17 +359,53 @@ int sprint_symbol(char *buffer, unsigned long address)
strcpy(buffer, name); strcpy(buffer, name);
len = strlen(buffer); len = strlen(buffer);
buffer += len; buffer += len;
offset -= symbol_offset;
if (modname) if (modname)
len += sprintf(buffer, "+%#lx/%#lx [%s]", len += sprintf(buffer, "+%#lx/%#lx [%s]", offset, size, modname);
offset, size, modname);
else else
len += sprintf(buffer, "+%#lx/%#lx", offset, size); len += sprintf(buffer, "+%#lx/%#lx", offset, size);
return len; return len;
} }
/**
* sprint_symbol - Look up a kernel symbol and return it in a text buffer
* @buffer: buffer to be stored
* @address: address to lookup
*
* This function looks up a kernel symbol with @address and stores its name,
* offset, size and module name to @buffer if possible. If no symbol was found,
* just saves its @address as is.
*
* This function returns the number of bytes stored in @buffer.
*/
int sprint_symbol(char *buffer, unsigned long address)
{
return __sprint_symbol(buffer, address, 0);
}
EXPORT_SYMBOL_GPL(sprint_symbol); EXPORT_SYMBOL_GPL(sprint_symbol);
/**
* sprint_backtrace - Look up a backtrace symbol and return it in a text buffer
* @buffer: buffer to be stored
* @address: address to lookup
*
* This function is for stack backtrace and does the same thing as
* sprint_symbol() but with modified/decreased @address. If there is a
* tail-call to the function marked "noreturn", gcc optimized out code after
* the call so that the stack-saved return address could point outside of the
* caller. This function ensures that kallsyms will find the original caller
* by decreasing @address.
*
* This function returns the number of bytes stored in @buffer.
*/
int sprint_backtrace(char *buffer, unsigned long address)
{
return __sprint_symbol(buffer, address, -1);
}
/* Look up a kernel symbol and print it to the kernel messages. */ /* Look up a kernel symbol and print it to the kernel messages. */
void __print_symbol(const char *fmt, unsigned long address) void __print_symbol(const char *fmt, unsigned long address)
{ {
......
...@@ -225,7 +225,7 @@ static int lockdep_stats_show(struct seq_file *m, void *v) ...@@ -225,7 +225,7 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
nr_irq_read_safe = 0, nr_irq_read_unsafe = 0, nr_irq_read_safe = 0, nr_irq_read_unsafe = 0,
nr_softirq_read_safe = 0, nr_softirq_read_unsafe = 0, nr_softirq_read_safe = 0, nr_softirq_read_unsafe = 0,
nr_hardirq_read_safe = 0, nr_hardirq_read_unsafe = 0, nr_hardirq_read_safe = 0, nr_hardirq_read_unsafe = 0,
sum_forward_deps = 0, factor = 0; sum_forward_deps = 0;
list_for_each_entry(class, &all_lock_classes, lock_entry) { list_for_each_entry(class, &all_lock_classes, lock_entry) {
...@@ -283,13 +283,6 @@ static int lockdep_stats_show(struct seq_file *m, void *v) ...@@ -283,13 +283,6 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
nr_hardirq_unsafe * nr_hardirq_safe + nr_hardirq_unsafe * nr_hardirq_safe +
nr_list_entries); nr_list_entries);
/*
* Estimated factor between direct and indirect
* dependencies:
*/
if (nr_list_entries)
factor = sum_forward_deps / nr_list_entries;
#ifdef CONFIG_PROVE_LOCKING #ifdef CONFIG_PROVE_LOCKING
seq_printf(m, " dependency chains: %11lu [max: %lu]\n", seq_printf(m, " dependency chains: %11lu [max: %lu]\n",
nr_lock_chains, MAX_LOCKDEP_CHAINS); nr_lock_chains, MAX_LOCKDEP_CHAINS);
......
...@@ -433,7 +433,9 @@ char *symbol_string(char *buf, char *end, void *ptr, ...@@ -433,7 +433,9 @@ char *symbol_string(char *buf, char *end, void *ptr,
unsigned long value = (unsigned long) ptr; unsigned long value = (unsigned long) ptr;
#ifdef CONFIG_KALLSYMS #ifdef CONFIG_KALLSYMS
char sym[KSYM_SYMBOL_LEN]; char sym[KSYM_SYMBOL_LEN];
if (ext != 'f' && ext != 's') if (ext == 'B')
sprint_backtrace(sym, value);
else if (ext != 'f' && ext != 's')
sprint_symbol(sym, value); sprint_symbol(sym, value);
else else
kallsyms_lookup(value, NULL, NULL, NULL, sym); kallsyms_lookup(value, NULL, NULL, NULL, sym);
...@@ -808,6 +810,7 @@ int kptr_restrict = 1; ...@@ -808,6 +810,7 @@ int kptr_restrict = 1;
* - 'f' For simple symbolic function names without offset * - 'f' For simple symbolic function names without offset
* - 'S' For symbolic direct pointers with offset * - 'S' For symbolic direct pointers with offset
* - 's' For symbolic direct pointers without offset * - 's' For symbolic direct pointers without offset
* - 'B' For backtraced symbolic direct pointers with offset
* - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref] * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
* - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201] * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
* - 'M' For a 6-byte MAC address, it prints the address in the * - 'M' For a 6-byte MAC address, it prints the address in the
...@@ -867,6 +870,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, ...@@ -867,6 +870,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
/* Fallthrough */ /* Fallthrough */
case 'S': case 'S':
case 's': case 's':
case 'B':
return symbol_string(buf, end, ptr, spec, *fmt); return symbol_string(buf, end, ptr, spec, *fmt);
case 'R': case 'R':
case 'r': case 'r':
...@@ -1134,6 +1138,7 @@ int format_decode(const char *fmt, struct printf_spec *spec) ...@@ -1134,6 +1138,7 @@ int format_decode(const char *fmt, struct printf_spec *spec)
* %ps output the name of a text symbol without offset * %ps output the name of a text symbol without offset
* %pF output the name of a function pointer with its offset * %pF output the name of a function pointer with its offset
* %pf output the name of a function pointer without its offset * %pf output the name of a function pointer without its offset
* %pB output the name of a backtrace symbol with its offset
* %pR output the address range in a struct resource with decoded flags * %pR output the address range in a struct resource with decoded flags
* %pr output the address range in a struct resource with raw flags * %pr output the address range in a struct resource with raw flags
* %pM output a 6-byte MAC address with colons * %pM output a 6-byte MAC address with colons
......
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