diff options
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 88 |
1 files changed, 87 insertions, 1 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 3c183d9864ae..7aef15c4645e 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -385,6 +385,91 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
385 | #endif | 385 | #endif |
386 | 386 | ||
387 | /* | 387 | /* |
388 | * General tracing related utility functions - trace_printk(), | ||
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. | ||
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 | ||
418 | #ifdef CONFIG_TRACING | ||
419 | extern void tracing_start(void); | ||
420 | extern void tracing_stop(void); | ||
421 | extern void ftrace_off_permanent(void); | ||
422 | |||
423 | extern void | ||
424 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); | ||
425 | |||
426 | /** | ||
427 | * trace_printk - printf formatting in the ftrace buffer | ||
428 | * @fmt: the printf format for printing | ||
429 | * | ||
430 | * Note: __trace_printk is an internal function for trace_printk and | ||
431 | * the @ip is passed in via the trace_printk macro. | ||
432 | * | ||
433 | * This function allows a kernel developer to debug fast path sections | ||
434 | * that printk is not appropriate for. By scattering in various | ||
435 | * printk like tracing in the code, a developer can quickly see | ||
436 | * where problems are occurring. | ||
437 | * | ||
438 | * This is intended as a debugging tool for the developer only. | ||
439 | * Please refrain from leaving trace_printks scattered around in | ||
440 | * your code. | ||
441 | */ | ||
442 | # define trace_printk(fmt...) __trace_printk(_THIS_IP_, fmt) | ||
443 | extern int | ||
444 | __trace_printk(unsigned long ip, const char *fmt, ...) | ||
445 | __attribute__ ((format (printf, 2, 3))); | ||
446 | # define ftrace_vprintk(fmt, ap) __trace_printk(_THIS_IP_, fmt, ap) | ||
447 | extern int | ||
448 | __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); | ||
449 | extern void ftrace_dump(void); | ||
450 | #else | ||
451 | static inline void | ||
452 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { } | ||
453 | static inline int | ||
454 | trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); | ||
455 | |||
456 | static inline void tracing_start(void) { } | ||
457 | static inline void tracing_stop(void) { } | ||
458 | static inline void ftrace_off_permanent(void) { } | ||
459 | static inline int | ||
460 | trace_printk(const char *fmt, ...) | ||
461 | { | ||
462 | return 0; | ||
463 | } | ||
464 | static inline int | ||
465 | ftrace_vprintk(const char *fmt, va_list ap) | ||
466 | { | ||
467 | return 0; | ||
468 | } | ||
469 | static inline void ftrace_dump(void) { } | ||
470 | #endif | ||
471 | |||
472 | /* | ||
388 | * Display an IP address in readable format. | 473 | * Display an IP address in readable format. |
389 | */ | 474 | */ |
390 | 475 | ||
@@ -497,7 +582,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
497 | /* | 582 | /* |
498 | * swap - swap value of @a and @b | 583 | * swap - swap value of @a and @b |
499 | */ | 584 | */ |
500 | #define swap(a, b) ({ typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; }) | 585 | #define swap(a, b) \ |
586 | do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) | ||
501 | 587 | ||
502 | /** | 588 | /** |
503 | * container_of - cast a member of a structure out to the containing structure | 589 | * container_of - cast a member of a structure out to the containing structure |