diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/ftrace.h | 1 | ||||
| -rw-r--r-- | include/linux/kernel.h | 80 | ||||
| -rw-r--r-- | include/linux/module.h | 5 | ||||
| -rw-r--r-- | include/linux/ring_buffer.h | 15 | ||||
| -rw-r--r-- | include/linux/string.h | 7 |
5 files changed, 88 insertions, 20 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 498769425eb2..e1583f2639b0 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h | |||
| @@ -223,7 +223,6 @@ extern int ftrace_make_nop(struct module *mod, | |||
| 223 | */ | 223 | */ |
| 224 | extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr); | 224 | extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr); |
| 225 | 225 | ||
| 226 | |||
| 227 | /* May be defined in arch */ | 226 | /* May be defined in arch */ |
| 228 | extern int ftrace_arch_read_dyn_info(char *buf, int size); | 227 | extern int ftrace_arch_read_dyn_info(char *buf, int size); |
| 229 | 228 | ||
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 08bf5da86676..4e726b9a71ec 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
| @@ -242,6 +242,19 @@ extern struct ratelimit_state printk_ratelimit_state; | |||
| 242 | extern int printk_ratelimit(void); | 242 | extern int printk_ratelimit(void); |
| 243 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, | 243 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, |
| 244 | unsigned int interval_msec); | 244 | unsigned int interval_msec); |
| 245 | |||
| 246 | /* | ||
| 247 | * Print a one-time message (analogous to WARN_ONCE() et al): | ||
| 248 | */ | ||
| 249 | #define printk_once(x...) ({ \ | ||
| 250 | static int __print_once = 1; \ | ||
| 251 | \ | ||
| 252 | if (__print_once) { \ | ||
| 253 | __print_once = 0; \ | ||
| 254 | printk(x); \ | ||
| 255 | } \ | ||
| 256 | }) | ||
| 257 | |||
| 245 | #else | 258 | #else |
| 246 | static inline int vprintk(const char *s, va_list args) | 259 | static inline int vprintk(const char *s, va_list args) |
| 247 | __attribute__ ((format (printf, 1, 0))); | 260 | __attribute__ ((format (printf, 1, 0))); |
| @@ -253,6 +266,10 @@ static inline int printk_ratelimit(void) { return 0; } | |||
| 253 | static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ | 266 | static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ |
| 254 | unsigned int interval_msec) \ | 267 | unsigned int interval_msec) \ |
| 255 | { return false; } | 268 | { return false; } |
| 269 | |||
| 270 | /* No effect, but we still get type checking even in the !PRINTK case: */ | ||
| 271 | #define printk_once(x...) printk(x) | ||
| 272 | |||
| 256 | #endif | 273 | #endif |
| 257 | 274 | ||
| 258 | extern int printk_needs_cpu(int cpu); | 275 | extern int printk_needs_cpu(int cpu); |
| @@ -369,8 +386,35 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
| 369 | 386 | ||
| 370 | /* | 387 | /* |
| 371 | * General tracing related utility functions - trace_printk(), | 388 | * General tracing related utility functions - trace_printk(), |
| 372 | * tracing_start()/tracing_stop: | 389 | * tracing_on/tracing_off and tracing_start()/tracing_stop |
| 390 | * | ||
| 391 | * Use tracing_on/tracing_off when you want to quickly turn on or off | ||
| 392 | * tracing. It simply enables or disables the recording of the trace events. | ||
| 393 | * This also corresponds to the user space debugfs/tracing/tracing_on | ||
| 394 | * file, which gives a means for the kernel and userspace to interact. | ||
| 395 | * Place a tracing_off() in the kernel where you want tracing to end. | ||
| 396 | * From user space, examine the trace, and then echo 1 > tracing_on | ||
| 397 | * to continue tracing. | ||
| 398 | * | ||
| 399 | * tracing_stop/tracing_start has slightly more overhead. It is used | ||
| 400 | * by things like suspend to ram where disabling the recording of the | ||
| 401 | * trace is not enough, but tracing must actually stop because things | ||
| 402 | * like calling smp_processor_id() may crash the system. | ||
| 403 | * | ||
| 404 | * Most likely, you want to use tracing_on/tracing_off. | ||
| 373 | */ | 405 | */ |
| 406 | #ifdef CONFIG_RING_BUFFER | ||
| 407 | void tracing_on(void); | ||
| 408 | void tracing_off(void); | ||
| 409 | /* trace_off_permanent stops recording with no way to bring it back */ | ||
| 410 | void tracing_off_permanent(void); | ||
| 411 | int tracing_is_on(void); | ||
| 412 | #else | ||
| 413 | static inline void tracing_on(void) { } | ||
| 414 | static inline void tracing_off(void) { } | ||
| 415 | static inline void tracing_off_permanent(void) { } | ||
| 416 | static inline int tracing_is_on(void) { return 0; } | ||
| 417 | #endif | ||
| 374 | #ifdef CONFIG_TRACING | 418 | #ifdef CONFIG_TRACING |
| 375 | extern void tracing_start(void); | 419 | extern void tracing_start(void); |
| 376 | extern void tracing_stop(void); | 420 | extern void tracing_stop(void); |
| @@ -379,6 +423,16 @@ extern void ftrace_off_permanent(void); | |||
| 379 | extern void | 423 | extern void |
| 380 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); | 424 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); |
| 381 | 425 | ||
| 426 | static inline void __attribute__ ((format (printf, 1, 2))) | ||
| 427 | ____trace_printk_check_format(const char *fmt, ...) | ||
| 428 | { | ||
| 429 | } | ||
| 430 | #define __trace_printk_check_format(fmt, args...) \ | ||
| 431 | do { \ | ||
| 432 | if (0) \ | ||
| 433 | ____trace_printk_check_format(fmt, ##args); \ | ||
| 434 | } while (0) | ||
| 435 | |||
| 382 | /** | 436 | /** |
| 383 | * trace_printk - printf formatting in the ftrace buffer | 437 | * trace_printk - printf formatting in the ftrace buffer |
| 384 | * @fmt: the printf format for printing | 438 | * @fmt: the printf format for printing |
| @@ -395,13 +449,31 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); | |||
| 395 | * Please refrain from leaving trace_printks scattered around in | 449 | * Please refrain from leaving trace_printks scattered around in |
| 396 | * your code. | 450 | * your code. |
| 397 | */ | 451 | */ |
| 398 | # define trace_printk(fmt...) __trace_printk(_THIS_IP_, fmt) | 452 | |
| 453 | #define trace_printk(fmt, args...) \ | ||
| 454 | do { \ | ||
| 455 | static const char *trace_printk_fmt \ | ||
| 456 | __attribute__((section("__trace_printk_fmt"))); \ | ||
| 457 | trace_printk_fmt = fmt; \ | ||
| 458 | __trace_printk_check_format(fmt, ##args); \ | ||
| 459 | __trace_printk(_THIS_IP_, trace_printk_fmt, ##args); \ | ||
| 460 | } while (0) | ||
| 461 | |||
| 399 | extern int | 462 | extern int |
| 400 | __trace_printk(unsigned long ip, const char *fmt, ...) | 463 | __trace_printk(unsigned long ip, const char *fmt, ...) |
| 401 | __attribute__ ((format (printf, 2, 3))); | 464 | __attribute__ ((format (printf, 2, 3))); |
| 402 | # define ftrace_vprintk(fmt, ap) __trace_printk(_THIS_IP_, fmt, ap) | 465 | |
| 466 | #define ftrace_vprintk(fmt, vargs) \ | ||
| 467 | do { \ | ||
| 468 | static const char *trace_printk_fmt \ | ||
| 469 | __attribute__((section("__trace_printk_fmt"))); \ | ||
| 470 | trace_printk_fmt = fmt; \ | ||
| 471 | __ftrace_vprintk(_THIS_IP_, trace_printk_fmt, vargs); \ | ||
| 472 | } while (0) | ||
| 473 | |||
| 403 | extern int | 474 | extern int |
| 404 | __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); | 475 | __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); |
| 476 | |||
| 405 | extern void ftrace_dump(void); | 477 | extern void ftrace_dump(void); |
| 406 | #else | 478 | #else |
| 407 | static inline void | 479 | static inline void |
| @@ -423,7 +495,7 @@ ftrace_vprintk(const char *fmt, va_list ap) | |||
| 423 | return 0; | 495 | return 0; |
| 424 | } | 496 | } |
| 425 | static inline void ftrace_dump(void) { } | 497 | static inline void ftrace_dump(void) { } |
| 426 | #endif | 498 | #endif /* CONFIG_TRACING */ |
| 427 | 499 | ||
| 428 | /* | 500 | /* |
| 429 | * Display an IP address in readable format. | 501 | * Display an IP address in readable format. |
diff --git a/include/linux/module.h b/include/linux/module.h index 145a75528cc1..22d9878e868c 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
| @@ -329,6 +329,11 @@ struct module | |||
| 329 | unsigned int num_tracepoints; | 329 | unsigned int num_tracepoints; |
| 330 | #endif | 330 | #endif |
| 331 | 331 | ||
| 332 | #ifdef CONFIG_TRACING | ||
| 333 | const char **trace_bprintk_fmt_start; | ||
| 334 | unsigned int num_trace_bprintk_fmt; | ||
| 335 | #endif | ||
| 336 | |||
| 332 | #ifdef CONFIG_MODULE_UNLOAD | 337 | #ifdef CONFIG_MODULE_UNLOAD |
| 333 | /* What modules depend on me? */ | 338 | /* What modules depend on me? */ |
| 334 | struct list_head modules_which_use_me; | 339 | struct list_head modules_which_use_me; |
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h index 79fcbc4b09d6..b1a0068a5557 100644 --- a/include/linux/ring_buffer.h +++ b/include/linux/ring_buffer.h | |||
| @@ -124,21 +124,6 @@ void ring_buffer_normalize_time_stamp(int cpu, u64 *ts); | |||
| 124 | size_t ring_buffer_page_len(void *page); | 124 | size_t ring_buffer_page_len(void *page); |
| 125 | 125 | ||
| 126 | 126 | ||
| 127 | /* | ||
| 128 | * The below functions are fine to use outside the tracing facility. | ||
| 129 | */ | ||
| 130 | #ifdef CONFIG_RING_BUFFER | ||
| 131 | void tracing_on(void); | ||
| 132 | void tracing_off(void); | ||
| 133 | void tracing_off_permanent(void); | ||
| 134 | int tracing_is_on(void); | ||
| 135 | #else | ||
| 136 | static inline void tracing_on(void) { } | ||
| 137 | static inline void tracing_off(void) { } | ||
| 138 | static inline void tracing_off_permanent(void) { } | ||
| 139 | static inline int tracing_is_on(void) { return 0; } | ||
| 140 | #endif | ||
| 141 | |||
| 142 | void *ring_buffer_alloc_read_page(struct ring_buffer *buffer); | 127 | void *ring_buffer_alloc_read_page(struct ring_buffer *buffer); |
| 143 | void ring_buffer_free_read_page(struct ring_buffer *buffer, void *data); | 128 | void ring_buffer_free_read_page(struct ring_buffer *buffer, void *data); |
| 144 | int ring_buffer_read_page(struct ring_buffer *buffer, void **data_page, | 129 | int ring_buffer_read_page(struct ring_buffer *buffer, void **data_page, |
diff --git a/include/linux/string.h b/include/linux/string.h index d18fc198aa2f..27ac31784ad2 100644 --- a/include/linux/string.h +++ b/include/linux/string.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <linux/compiler.h> /* for inline */ | 10 | #include <linux/compiler.h> /* for inline */ |
| 11 | #include <linux/types.h> /* for size_t */ | 11 | #include <linux/types.h> /* for size_t */ |
| 12 | #include <linux/stddef.h> /* for NULL */ | 12 | #include <linux/stddef.h> /* for NULL */ |
| 13 | #include <stdarg.h> | ||
| 13 | 14 | ||
| 14 | extern char *strndup_user(const char __user *, long); | 15 | extern char *strndup_user(const char __user *, long); |
| 15 | 16 | ||
| @@ -111,6 +112,12 @@ extern void argv_free(char **argv); | |||
| 111 | 112 | ||
| 112 | extern bool sysfs_streq(const char *s1, const char *s2); | 113 | extern bool sysfs_streq(const char *s1, const char *s2); |
| 113 | 114 | ||
| 115 | #ifdef CONFIG_BINARY_PRINTF | ||
| 116 | int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args); | ||
| 117 | int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf); | ||
| 118 | int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...) __printf(3, 4); | ||
| 119 | #endif | ||
| 120 | |||
| 114 | extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos, | 121 | extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos, |
| 115 | const void *from, size_t available); | 122 | const void *from, size_t available); |
| 116 | 123 | ||
