aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-03-25 20:52:22 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-25 20:52:22 -0400
commit94df491c4a01b39d81279a68386158eb02656712 (patch)
treeba431d9d74f11a7117883df54908ea39e4ef7c5c
parent26ff6801f751cd47e44c2e9507ec08b447f2d2b9 (diff)
parent29096202176ceaa5016a17ea2dd1aea19a4e90e2 (diff)
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()
-rw-r--r--arch/x86/kernel/dumpstack.c2
-rw-r--r--include/asm-generic/bug.h28
-rw-r--r--include/linux/kallsyms.h7
-rw-r--r--kernel/futex.c4
-rw-r--r--kernel/kallsyms.c44
-rw-r--r--kernel/lockdep_proc.c9
-rw-r--r--lib/vsprintf.c7
7 files changed, 85 insertions, 16 deletions
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 81ac6c78c01..e2a3f0606da 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -27,7 +27,7 @@ static int die_counter;
27 27
28void printk_address(unsigned long address, int reliable) 28void printk_address(unsigned long address, int reliable)
29{ 29{
30 printk(" [<%p>] %s%pS\n", (void *) address, 30 printk(" [<%p>] %s%pB\n", (void *) address,
31 reliable ? "" : "? ", (void *) address); 31 reliable ? "" : "? ", (void *) address);
32} 32}
33 33
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index c2c9ba032d4..f2d2faf4d9a 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -165,10 +165,36 @@ extern void warn_slowpath_null(const char *file, const int line);
165#define WARN_ON_RATELIMIT(condition, state) \ 165#define WARN_ON_RATELIMIT(condition, state) \
166 WARN_ON((condition) && __ratelimit(state)) 166 WARN_ON((condition) && __ratelimit(state))
167 167
168/*
169 * WARN_ON_SMP() is for cases that the warning is either
170 * meaningless for !SMP or may even cause failures.
171 * This is usually used for cases that we have
172 * WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked()
173 * returns 0 for uniprocessor settings.
174 * It can also be used with values that are only defined
175 * on SMP:
176 *
177 * struct foo {
178 * [...]
179 * #ifdef CONFIG_SMP
180 * int bar;
181 * #endif
182 * };
183 *
184 * void func(struct foo *zoot)
185 * {
186 * WARN_ON_SMP(!zoot->bar);
187 *
188 * For CONFIG_SMP, WARN_ON_SMP() should act the same as WARN_ON(),
189 * and should be a nop and return false for uniprocessor.
190 *
191 * if (WARN_ON_SMP(x)) returns true only when CONFIG_SMP is set
192 * and x is true.
193 */
168#ifdef CONFIG_SMP 194#ifdef CONFIG_SMP
169# define WARN_ON_SMP(x) WARN_ON(x) 195# define WARN_ON_SMP(x) WARN_ON(x)
170#else 196#else
171# define WARN_ON_SMP(x) do { } while (0) 197# define WARN_ON_SMP(x) ({0;})
172#endif 198#endif
173 199
174#endif 200#endif
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index d8e9b3d1c23..0df513b7a9f 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -36,6 +36,7 @@ const char *kallsyms_lookup(unsigned long addr,
36 36
37/* Look up a kernel symbol and return it in a text buffer. */ 37/* Look up a kernel symbol and return it in a text buffer. */
38extern int sprint_symbol(char *buffer, unsigned long address); 38extern int sprint_symbol(char *buffer, unsigned long address);
39extern int sprint_backtrace(char *buffer, unsigned long address);
39 40
40/* Look up a kernel symbol and print it to the kernel messages. */ 41/* Look up a kernel symbol and print it to the kernel messages. */
41extern void __print_symbol(const char *fmt, unsigned long address); 42extern void __print_symbol(const char *fmt, unsigned long address);
@@ -79,6 +80,12 @@ static inline int sprint_symbol(char *buffer, unsigned long addr)
79 return 0; 80 return 0;
80} 81}
81 82
83static inline int sprint_backtrace(char *buffer, unsigned long addr)
84{
85 *buffer = '\0';
86 return 0;
87}
88
82static inline int lookup_symbol_name(unsigned long addr, char *symname) 89static inline int lookup_symbol_name(unsigned long addr, char *symname)
83{ 90{
84 return -ERANGE; 91 return -ERANGE;
diff --git a/kernel/futex.c b/kernel/futex.c
index 6570c459f31..dfb924ffe65 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -782,8 +782,8 @@ static void __unqueue_futex(struct futex_q *q)
782{ 782{
783 struct futex_hash_bucket *hb; 783 struct futex_hash_bucket *hb;
784 784
785 if (WARN_ON(!q->lock_ptr || !spin_is_locked(q->lock_ptr) 785 if (WARN_ON_SMP(!q->lock_ptr || !spin_is_locked(q->lock_ptr))
786 || plist_node_empty(&q->list))) 786 || WARN_ON(plist_node_empty(&q->list)))
787 return; 787 return;
788 788
789 hb = container_of(q->lock_ptr, struct futex_hash_bucket, lock); 789 hb = container_of(q->lock_ptr, struct futex_hash_bucket, lock);
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index a56aa58b9cb..079f1d39a8b 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -342,13 +342,15 @@ int lookup_symbol_attrs(unsigned long addr, unsigned long *size,
342} 342}
343 343
344/* Look up a kernel symbol and return it in a text buffer. */ 344/* Look up a kernel symbol and return it in a text buffer. */
345int sprint_symbol(char *buffer, unsigned long address) 345static int __sprint_symbol(char *buffer, unsigned long address,
346 int symbol_offset)
346{ 347{
347 char *modname; 348 char *modname;
348 const char *name; 349 const char *name;
349 unsigned long offset, size; 350 unsigned long offset, size;
350 int len; 351 int len;
351 352
353 address += symbol_offset;
352 name = kallsyms_lookup(address, &size, &offset, &modname, buffer); 354 name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
353 if (!name) 355 if (!name)
354 return sprintf(buffer, "0x%lx", address); 356 return sprintf(buffer, "0x%lx", address);
@@ -357,17 +359,53 @@ int sprint_symbol(char *buffer, unsigned long address)
357 strcpy(buffer, name); 359 strcpy(buffer, name);
358 len = strlen(buffer); 360 len = strlen(buffer);
359 buffer += len; 361 buffer += len;
362 offset -= symbol_offset;
360 363
361 if (modname) 364 if (modname)
362 len += sprintf(buffer, "+%#lx/%#lx [%s]", 365 len += sprintf(buffer, "+%#lx/%#lx [%s]", offset, size, modname);
363 offset, size, modname);
364 else 366 else
365 len += sprintf(buffer, "+%#lx/%#lx", offset, size); 367 len += sprintf(buffer, "+%#lx/%#lx", offset, size);
366 368
367 return len; 369 return len;
368} 370}
371
372/**
373 * sprint_symbol - Look up a kernel symbol and return it in a text buffer
374 * @buffer: buffer to be stored
375 * @address: address to lookup
376 *
377 * This function looks up a kernel symbol with @address and stores its name,
378 * offset, size and module name to @buffer if possible. If no symbol was found,
379 * just saves its @address as is.
380 *
381 * This function returns the number of bytes stored in @buffer.
382 */
383int sprint_symbol(char *buffer, unsigned long address)
384{
385 return __sprint_symbol(buffer, address, 0);
386}
387
369EXPORT_SYMBOL_GPL(sprint_symbol); 388EXPORT_SYMBOL_GPL(sprint_symbol);
370 389
390/**
391 * sprint_backtrace - Look up a backtrace symbol and return it in a text buffer
392 * @buffer: buffer to be stored
393 * @address: address to lookup
394 *
395 * This function is for stack backtrace and does the same thing as
396 * sprint_symbol() but with modified/decreased @address. If there is a
397 * tail-call to the function marked "noreturn", gcc optimized out code after
398 * the call so that the stack-saved return address could point outside of the
399 * caller. This function ensures that kallsyms will find the original caller
400 * by decreasing @address.
401 *
402 * This function returns the number of bytes stored in @buffer.
403 */
404int sprint_backtrace(char *buffer, unsigned long address)
405{
406 return __sprint_symbol(buffer, address, -1);
407}
408
371/* Look up a kernel symbol and print it to the kernel messages. */ 409/* Look up a kernel symbol and print it to the kernel messages. */
372void __print_symbol(const char *fmt, unsigned long address) 410void __print_symbol(const char *fmt, unsigned long address)
373{ 411{
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
index 1969d2fc4b3..71edd2f60c0 100644
--- a/kernel/lockdep_proc.c
+++ b/kernel/lockdep_proc.c
@@ -225,7 +225,7 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
225 nr_irq_read_safe = 0, nr_irq_read_unsafe = 0, 225 nr_irq_read_safe = 0, nr_irq_read_unsafe = 0,
226 nr_softirq_read_safe = 0, nr_softirq_read_unsafe = 0, 226 nr_softirq_read_safe = 0, nr_softirq_read_unsafe = 0,
227 nr_hardirq_read_safe = 0, nr_hardirq_read_unsafe = 0, 227 nr_hardirq_read_safe = 0, nr_hardirq_read_unsafe = 0,
228 sum_forward_deps = 0, factor = 0; 228 sum_forward_deps = 0;
229 229
230 list_for_each_entry(class, &all_lock_classes, lock_entry) { 230 list_for_each_entry(class, &all_lock_classes, lock_entry) {
231 231
@@ -283,13 +283,6 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
283 nr_hardirq_unsafe * nr_hardirq_safe + 283 nr_hardirq_unsafe * nr_hardirq_safe +
284 nr_list_entries); 284 nr_list_entries);
285 285
286 /*
287 * Estimated factor between direct and indirect
288 * dependencies:
289 */
290 if (nr_list_entries)
291 factor = sum_forward_deps / nr_list_entries;
292
293#ifdef CONFIG_PROVE_LOCKING 286#ifdef CONFIG_PROVE_LOCKING
294 seq_printf(m, " dependency chains: %11lu [max: %lu]\n", 287 seq_printf(m, " dependency chains: %11lu [max: %lu]\n",
295 nr_lock_chains, MAX_LOCKDEP_CHAINS); 288 nr_lock_chains, MAX_LOCKDEP_CHAINS);
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 02bcdd5feac..bc0ac6b333d 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -433,7 +433,9 @@ char *symbol_string(char *buf, char *end, void *ptr,
433 unsigned long value = (unsigned long) ptr; 433 unsigned long value = (unsigned long) ptr;
434#ifdef CONFIG_KALLSYMS 434#ifdef CONFIG_KALLSYMS
435 char sym[KSYM_SYMBOL_LEN]; 435 char sym[KSYM_SYMBOL_LEN];
436 if (ext != 'f' && ext != 's') 436 if (ext == 'B')
437 sprint_backtrace(sym, value);
438 else if (ext != 'f' && ext != 's')
437 sprint_symbol(sym, value); 439 sprint_symbol(sym, value);
438 else 440 else
439 kallsyms_lookup(value, NULL, NULL, NULL, sym); 441 kallsyms_lookup(value, NULL, NULL, NULL, sym);
@@ -808,6 +810,7 @@ int kptr_restrict = 1;
808 * - 'f' For simple symbolic function names without offset 810 * - 'f' For simple symbolic function names without offset
809 * - 'S' For symbolic direct pointers with offset 811 * - 'S' For symbolic direct pointers with offset
810 * - 's' For symbolic direct pointers without offset 812 * - 's' For symbolic direct pointers without offset
813 * - 'B' For backtraced symbolic direct pointers with offset
811 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref] 814 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
812 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201] 815 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
813 * - 'M' For a 6-byte MAC address, it prints the address in the 816 * - '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 /* Fallthrough */ 870 /* Fallthrough */
868 case 'S': 871 case 'S':
869 case 's': 872 case 's':
873 case 'B':
870 return symbol_string(buf, end, ptr, spec, *fmt); 874 return symbol_string(buf, end, ptr, spec, *fmt);
871 case 'R': 875 case 'R':
872 case 'r': 876 case 'r':
@@ -1134,6 +1138,7 @@ qualifier:
1134 * %ps output the name of a text symbol without offset 1138 * %ps output the name of a text symbol without offset
1135 * %pF output the name of a function pointer with its offset 1139 * %pF output the name of a function pointer with its offset
1136 * %pf output the name of a function pointer without its offset 1140 * %pf output the name of a function pointer without its offset
1141 * %pB output the name of a backtrace symbol with its offset
1137 * %pR output the address range in a struct resource with decoded flags 1142 * %pR output the address range in a struct resource with decoded flags
1138 * %pr output the address range in a struct resource with raw flags 1143 * %pr output the address range in a struct resource with raw flags
1139 * %pM output a 6-byte MAC address with colons 1144 * %pM output a 6-byte MAC address with colons