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()

+85 -16
+1 -1
arch/x86/kernel/dumpstack.c
··· 27 27 28 28 void 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 31 reliable ? "" : "? ", (void *) address); 32 32 } 33 33
+27 -1
include/asm-generic/bug.h
··· 165 165 #define WARN_ON_RATELIMIT(condition, state) \ 166 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 194 #ifdef CONFIG_SMP 169 195 # define WARN_ON_SMP(x) WARN_ON(x) 170 196 #else 171 - # define WARN_ON_SMP(x) do { } while (0) 197 + # define WARN_ON_SMP(x) ({0;}) 172 198 #endif 173 199 174 200 #endif
+7
include/linux/kallsyms.h
··· 36 36 37 37 /* Look up a kernel symbol and return it in a text buffer. */ 38 38 extern int sprint_symbol(char *buffer, unsigned long address); 39 + extern int sprint_backtrace(char *buffer, unsigned long address); 39 40 40 41 /* Look up a kernel symbol and print it to the kernel messages. */ 41 42 extern void __print_symbol(const char *fmt, unsigned long address); ··· 75 74 } 76 75 77 76 static inline int sprint_symbol(char *buffer, unsigned long addr) 77 + { 78 + *buffer = '\0'; 79 + return 0; 80 + } 81 + 82 + static inline int sprint_backtrace(char *buffer, unsigned long addr) 78 83 { 79 84 *buffer = '\0'; 80 85 return 0;
+2 -2
kernel/futex.c
··· 782 782 { 783 783 struct futex_hash_bucket *hb; 784 784 785 - if (WARN_ON(!q->lock_ptr || !spin_is_locked(q->lock_ptr) 786 - || plist_node_empty(&q->list))) 785 + if (WARN_ON_SMP(!q->lock_ptr || !spin_is_locked(q->lock_ptr)) 786 + || WARN_ON(plist_node_empty(&q->list))) 787 787 return; 788 788 789 789 hb = container_of(q->lock_ptr, struct futex_hash_bucket, lock);
+41 -3
kernel/kallsyms.c
··· 342 342 } 343 343 344 344 /* Look up a kernel symbol and return it in a text buffer. */ 345 - int sprint_symbol(char *buffer, unsigned long address) 345 + static int __sprint_symbol(char *buffer, unsigned long address, 346 + int symbol_offset) 346 347 { 347 348 char *modname; 348 349 const char *name; 349 350 unsigned long offset, size; 350 351 int len; 351 352 353 + address += symbol_offset; 352 354 name = kallsyms_lookup(address, &size, &offset, &modname, buffer); 353 355 if (!name) 354 356 return sprintf(buffer, "0x%lx", address); ··· 359 357 strcpy(buffer, name); 360 358 len = strlen(buffer); 361 359 buffer += len; 360 + offset -= symbol_offset; 362 361 363 362 if (modname) 364 - len += sprintf(buffer, "+%#lx/%#lx [%s]", 365 - offset, size, modname); 363 + len += sprintf(buffer, "+%#lx/%#lx [%s]", offset, size, modname); 366 364 else 367 365 len += sprintf(buffer, "+%#lx/%#lx", offset, size); 368 366 369 367 return len; 370 368 } 369 + 370 + /** 371 + * sprint_symbol - Look up a kernel symbol and return it in a text buffer 372 + * @buffer: buffer to be stored 373 + * @address: address to lookup 374 + * 375 + * This function looks up a kernel symbol with @address and stores its name, 376 + * offset, size and module name to @buffer if possible. If no symbol was found, 377 + * just saves its @address as is. 378 + * 379 + * This function returns the number of bytes stored in @buffer. 380 + */ 381 + int sprint_symbol(char *buffer, unsigned long address) 382 + { 383 + return __sprint_symbol(buffer, address, 0); 384 + } 385 + 371 386 EXPORT_SYMBOL_GPL(sprint_symbol); 387 + 388 + /** 389 + * sprint_backtrace - Look up a backtrace symbol and return it in a text buffer 390 + * @buffer: buffer to be stored 391 + * @address: address to lookup 392 + * 393 + * This function is for stack backtrace and does the same thing as 394 + * sprint_symbol() but with modified/decreased @address. If there is a 395 + * tail-call to the function marked "noreturn", gcc optimized out code after 396 + * the call so that the stack-saved return address could point outside of the 397 + * caller. This function ensures that kallsyms will find the original caller 398 + * by decreasing @address. 399 + * 400 + * This function returns the number of bytes stored in @buffer. 401 + */ 402 + int sprint_backtrace(char *buffer, unsigned long address) 403 + { 404 + return __sprint_symbol(buffer, address, -1); 405 + } 372 406 373 407 /* Look up a kernel symbol and print it to the kernel messages. */ 374 408 void __print_symbol(const char *fmt, unsigned long address)
+1 -8
kernel/lockdep_proc.c
··· 225 225 nr_irq_read_safe = 0, nr_irq_read_unsafe = 0, 226 226 nr_softirq_read_safe = 0, nr_softirq_read_unsafe = 0, 227 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 230 list_for_each_entry(class, &all_lock_classes, lock_entry) { 231 231 ··· 282 282 nr_irq_unsafe * nr_irq_safe + 283 283 nr_hardirq_unsafe * nr_hardirq_safe + 284 284 nr_list_entries); 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 285 293 286 #ifdef CONFIG_PROVE_LOCKING 294 287 seq_printf(m, " dependency chains: %11lu [max: %lu]\n",
+6 -1
lib/vsprintf.c
··· 433 433 unsigned long value = (unsigned long) ptr; 434 434 #ifdef CONFIG_KALLSYMS 435 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 439 sprint_symbol(sym, value); 438 440 else 439 441 kallsyms_lookup(value, NULL, NULL, NULL, sym); ··· 810 808 * - 'f' For simple symbolic function names without offset 811 809 * - 'S' For symbolic direct pointers with offset 812 810 * - 's' For symbolic direct pointers without offset 811 + * - 'B' For backtraced symbolic direct pointers with offset 813 812 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref] 814 813 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201] 815 814 * - 'M' For a 6-byte MAC address, it prints the address in the ··· 870 867 /* Fallthrough */ 871 868 case 'S': 872 869 case 's': 870 + case 'B': 873 871 return symbol_string(buf, end, ptr, spec, *fmt); 874 872 case 'R': 875 873 case 'r': ··· 1138 1134 * %ps output the name of a text symbol without offset 1139 1135 * %pF output the name of a function pointer with its offset 1140 1136 * %pf output the name of a function pointer without its offset 1137 + * %pB output the name of a backtrace symbol with its offset 1141 1138 * %pR output the address range in a struct resource with decoded flags 1142 1139 * %pr output the address range in a struct resource with raw flags 1143 1140 * %pM output a 6-byte MAC address with colons