diff options
Diffstat (limited to 'include/linux/kernel.h')
| -rw-r--r-- | include/linux/kernel.h | 81 |
1 files changed, 68 insertions, 13 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 80d36874689b..e9ef6d6b51d5 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
| @@ -390,7 +390,6 @@ extern struct pid *session_of_pgrp(struct pid *pgrp); | |||
| 390 | unsigned long int_sqrt(unsigned long); | 390 | unsigned long int_sqrt(unsigned long); |
| 391 | 391 | ||
| 392 | extern void bust_spinlocks(int yes); | 392 | extern void bust_spinlocks(int yes); |
| 393 | extern void wake_up_klogd(void); | ||
| 394 | extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ | 393 | extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ |
| 395 | extern int panic_timeout; | 394 | extern int panic_timeout; |
| 396 | extern int panic_on_oops; | 395 | extern int panic_on_oops; |
| @@ -487,6 +486,8 @@ enum ftrace_dump_mode { | |||
| 487 | void tracing_on(void); | 486 | void tracing_on(void); |
| 488 | void tracing_off(void); | 487 | void tracing_off(void); |
| 489 | int tracing_is_on(void); | 488 | int tracing_is_on(void); |
| 489 | void tracing_snapshot(void); | ||
| 490 | void tracing_snapshot_alloc(void); | ||
| 490 | 491 | ||
| 491 | extern void tracing_start(void); | 492 | extern void tracing_start(void); |
| 492 | extern void tracing_stop(void); | 493 | extern void tracing_stop(void); |
| @@ -516,10 +517,32 @@ do { \ | |||
| 516 | * | 517 | * |
| 517 | * This is intended as a debugging tool for the developer only. | 518 | * This is intended as a debugging tool for the developer only. |
| 518 | * Please refrain from leaving trace_printks scattered around in | 519 | * Please refrain from leaving trace_printks scattered around in |
| 519 | * your code. | 520 | * your code. (Extra memory is used for special buffers that are |
| 521 | * allocated when trace_printk() is used) | ||
| 522 | * | ||
| 523 | * A little optization trick is done here. If there's only one | ||
| 524 | * argument, there's no need to scan the string for printf formats. | ||
| 525 | * The trace_puts() will suffice. But how can we take advantage of | ||
| 526 | * using trace_puts() when trace_printk() has only one argument? | ||
| 527 | * By stringifying the args and checking the size we can tell | ||
| 528 | * whether or not there are args. __stringify((__VA_ARGS__)) will | ||
| 529 | * turn into "()\0" with a size of 3 when there are no args, anything | ||
| 530 | * else will be bigger. All we need to do is define a string to this, | ||
| 531 | * and then take its size and compare to 3. If it's bigger, use | ||
| 532 | * do_trace_printk() otherwise, optimize it to trace_puts(). Then just | ||
| 533 | * let gcc optimize the rest. | ||
| 520 | */ | 534 | */ |
| 521 | 535 | ||
| 522 | #define trace_printk(fmt, args...) \ | 536 | #define trace_printk(fmt, ...) \ |
| 537 | do { \ | ||
| 538 | char _______STR[] = __stringify((__VA_ARGS__)); \ | ||
| 539 | if (sizeof(_______STR) > 3) \ | ||
| 540 | do_trace_printk(fmt, ##__VA_ARGS__); \ | ||
| 541 | else \ | ||
| 542 | trace_puts(fmt); \ | ||
| 543 | } while (0) | ||
| 544 | |||
| 545 | #define do_trace_printk(fmt, args...) \ | ||
| 523 | do { \ | 546 | do { \ |
| 524 | static const char *trace_printk_fmt \ | 547 | static const char *trace_printk_fmt \ |
| 525 | __attribute__((section("__trace_printk_fmt"))) = \ | 548 | __attribute__((section("__trace_printk_fmt"))) = \ |
| @@ -539,7 +562,46 @@ int __trace_bprintk(unsigned long ip, const char *fmt, ...); | |||
| 539 | extern __printf(2, 3) | 562 | extern __printf(2, 3) |
| 540 | int __trace_printk(unsigned long ip, const char *fmt, ...); | 563 | int __trace_printk(unsigned long ip, const char *fmt, ...); |
| 541 | 564 | ||
| 542 | extern void trace_dump_stack(void); | 565 | extern int __trace_bputs(unsigned long ip, const char *str); |
| 566 | extern int __trace_puts(unsigned long ip, const char *str, int size); | ||
| 567 | |||
| 568 | /** | ||
| 569 | * trace_puts - write a string into the ftrace buffer | ||
| 570 | * @str: the string to record | ||
| 571 | * | ||
| 572 | * Note: __trace_bputs is an internal function for trace_puts and | ||
| 573 | * the @ip is passed in via the trace_puts macro. | ||
| 574 | * | ||
| 575 | * This is similar to trace_printk() but is made for those really fast | ||
| 576 | * paths that a developer wants the least amount of "Heisenbug" affects, | ||
| 577 | * where the processing of the print format is still too much. | ||
| 578 | * | ||
| 579 | * This function allows a kernel developer to debug fast path sections | ||
| 580 | * that printk is not appropriate for. By scattering in various | ||
| 581 | * printk like tracing in the code, a developer can quickly see | ||
| 582 | * where problems are occurring. | ||
| 583 | * | ||
| 584 | * This is intended as a debugging tool for the developer only. | ||
| 585 | * Please refrain from leaving trace_puts scattered around in | ||
| 586 | * your code. (Extra memory is used for special buffers that are | ||
| 587 | * allocated when trace_puts() is used) | ||
| 588 | * | ||
| 589 | * Returns: 0 if nothing was written, positive # if string was. | ||
| 590 | * (1 when __trace_bputs is used, strlen(str) when __trace_puts is used) | ||
| 591 | */ | ||
| 592 | |||
| 593 | #define trace_puts(str) ({ \ | ||
| 594 | static const char *trace_printk_fmt \ | ||
| 595 | __attribute__((section("__trace_printk_fmt"))) = \ | ||
| 596 | __builtin_constant_p(str) ? str : NULL; \ | ||
| 597 | \ | ||
| 598 | if (__builtin_constant_p(str)) \ | ||
| 599 | __trace_bputs(_THIS_IP_, trace_printk_fmt); \ | ||
| 600 | else \ | ||
| 601 | __trace_puts(_THIS_IP_, str, strlen(str)); \ | ||
| 602 | }) | ||
| 603 | |||
| 604 | extern void trace_dump_stack(int skip); | ||
| 543 | 605 | ||
| 544 | /* | 606 | /* |
| 545 | * The double __builtin_constant_p is because gcc will give us an error | 607 | * The double __builtin_constant_p is because gcc will give us an error |
| @@ -574,6 +636,8 @@ static inline void trace_dump_stack(void) { } | |||
| 574 | static inline void tracing_on(void) { } | 636 | static inline void tracing_on(void) { } |
| 575 | static inline void tracing_off(void) { } | 637 | static inline void tracing_off(void) { } |
| 576 | static inline int tracing_is_on(void) { return 0; } | 638 | static inline int tracing_is_on(void) { return 0; } |
| 639 | static inline void tracing_snapshot(void) { } | ||
| 640 | static inline void tracing_snapshot_alloc(void) { } | ||
| 577 | 641 | ||
| 578 | static inline __printf(1, 2) | 642 | static inline __printf(1, 2) |
| 579 | int trace_printk(const char *fmt, ...) | 643 | int trace_printk(const char *fmt, ...) |
| @@ -723,18 +787,9 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
| 723 | /* Trap pasters of __FUNCTION__ at compile-time */ | 787 | /* Trap pasters of __FUNCTION__ at compile-time */ |
| 724 | #define __FUNCTION__ (__func__) | 788 | #define __FUNCTION__ (__func__) |
| 725 | 789 | ||
| 726 | /* This helps us to avoid #ifdef CONFIG_SYMBOL_PREFIX */ | ||
| 727 | #ifdef CONFIG_SYMBOL_PREFIX | ||
| 728 | #define SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX | ||
| 729 | #else | ||
| 730 | #define SYMBOL_PREFIX "" | ||
| 731 | #endif | ||
| 732 | |||
| 733 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ | 790 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ |
| 734 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD | 791 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD |
| 735 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD | 792 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD |
| 736 | #endif | 793 | #endif |
| 737 | 794 | ||
| 738 | extern int do_sysinfo(struct sysinfo *info); | ||
| 739 | |||
| 740 | #endif | 795 | #endif |
