aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h88
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
407void tracing_on(void);
408void tracing_off(void);
409/* trace_off_permanent stops recording with no way to bring it back */
410void tracing_off_permanent(void);
411int tracing_is_on(void);
412#else
413static inline void tracing_on(void) { }
414static inline void tracing_off(void) { }
415static inline void tracing_off_permanent(void) { }
416static inline int tracing_is_on(void) { return 0; }
417#endif
418#ifdef CONFIG_TRACING
419extern void tracing_start(void);
420extern void tracing_stop(void);
421extern void ftrace_off_permanent(void);
422
423extern void
424ftrace_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)
443extern 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)
447extern int
448__ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap);
449extern void ftrace_dump(void);
450#else
451static inline void
452ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
453static inline int
454trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
455
456static inline void tracing_start(void) { }
457static inline void tracing_stop(void) { }
458static inline void ftrace_off_permanent(void) { }
459static inline int
460trace_printk(const char *fmt, ...)
461{
462 return 0;
463}
464static inline int
465ftrace_vprintk(const char *fmt, va_list ap)
466{
467 return 0;
468}
469static 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