aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-04-01 15:54:19 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-01 18:49:02 -0400
commit8302294f43250dc337108c51882a6007f2b1e2e0 (patch)
tree85acd4440799c46a372df9cad170fa0c21e59096 /include/linux/kernel.h
parent4fe70410d9a219dabb47328effccae7e7f2a6e26 (diff)
parent2e572895bf3203e881356a4039ab0fa428ed2639 (diff)
Merge branch 'tracing/core-v2' into tracing-for-linus
Conflicts: include/linux/slub_def.h lib/Kconfig.debug mm/slob.c mm/slub.c
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h150
1 files changed, 150 insertions, 0 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index e720b0da7751..e81f2637fdef 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -242,6 +242,19 @@ extern struct ratelimit_state printk_ratelimit_state;
242extern int printk_ratelimit(void); 242extern int printk_ratelimit(void);
243extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, 243extern 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
246static inline int vprintk(const char *s, va_list args) 259static 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; }
253static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ 266static 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
258extern int printk_needs_cpu(int cpu); 275extern int printk_needs_cpu(int cpu);
@@ -371,6 +388,139 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
371#endif 388#endif
372 389
373/* 390/*
391 * General tracing related utility functions - trace_printk(),
392 * tracing_on/tracing_off and tracing_start()/tracing_stop
393 *
394 * Use tracing_on/tracing_off when you want to quickly turn on or off
395 * tracing. It simply enables or disables the recording of the trace events.
396 * This also corresponds to the user space debugfs/tracing/tracing_on
397 * file, which gives a means for the kernel and userspace to interact.
398 * Place a tracing_off() in the kernel where you want tracing to end.
399 * From user space, examine the trace, and then echo 1 > tracing_on
400 * to continue tracing.
401 *
402 * tracing_stop/tracing_start has slightly more overhead. It is used
403 * by things like suspend to ram where disabling the recording of the
404 * trace is not enough, but tracing must actually stop because things
405 * like calling smp_processor_id() may crash the system.
406 *
407 * Most likely, you want to use tracing_on/tracing_off.
408 */
409#ifdef CONFIG_RING_BUFFER
410void tracing_on(void);
411void tracing_off(void);
412/* trace_off_permanent stops recording with no way to bring it back */
413void tracing_off_permanent(void);
414int tracing_is_on(void);
415#else
416static inline void tracing_on(void) { }
417static inline void tracing_off(void) { }
418static inline void tracing_off_permanent(void) { }
419static inline int tracing_is_on(void) { return 0; }
420#endif
421#ifdef CONFIG_TRACING
422extern void tracing_start(void);
423extern void tracing_stop(void);
424extern void ftrace_off_permanent(void);
425
426extern void
427ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
428
429static inline void __attribute__ ((format (printf, 1, 2)))
430____trace_printk_check_format(const char *fmt, ...)
431{
432}
433#define __trace_printk_check_format(fmt, args...) \
434do { \
435 if (0) \
436 ____trace_printk_check_format(fmt, ##args); \
437} while (0)
438
439/**
440 * trace_printk - printf formatting in the ftrace buffer
441 * @fmt: the printf format for printing
442 *
443 * Note: __trace_printk is an internal function for trace_printk and
444 * the @ip is passed in via the trace_printk macro.
445 *
446 * This function allows a kernel developer to debug fast path sections
447 * that printk is not appropriate for. By scattering in various
448 * printk like tracing in the code, a developer can quickly see
449 * where problems are occurring.
450 *
451 * This is intended as a debugging tool for the developer only.
452 * Please refrain from leaving trace_printks scattered around in
453 * your code.
454 */
455
456#define trace_printk(fmt, args...) \
457do { \
458 __trace_printk_check_format(fmt, ##args); \
459 if (__builtin_constant_p(fmt)) { \
460 static const char *trace_printk_fmt \
461 __attribute__((section("__trace_printk_fmt"))) = \
462 __builtin_constant_p(fmt) ? fmt : NULL; \
463 \
464 __trace_bprintk(_THIS_IP_, trace_printk_fmt, ##args); \
465 } else \
466 __trace_printk(_THIS_IP_, fmt, ##args); \
467} while (0)
468
469extern int
470__trace_bprintk(unsigned long ip, const char *fmt, ...)
471 __attribute__ ((format (printf, 2, 3)));
472
473extern int
474__trace_printk(unsigned long ip, const char *fmt, ...)
475 __attribute__ ((format (printf, 2, 3)));
476
477/*
478 * The double __builtin_constant_p is because gcc will give us an error
479 * if we try to allocate the static variable to fmt if it is not a
480 * constant. Even with the outer if statement.
481 */
482#define ftrace_vprintk(fmt, vargs) \
483do { \
484 if (__builtin_constant_p(fmt)) { \
485 static const char *trace_printk_fmt \
486 __attribute__((section("__trace_printk_fmt"))) = \
487 __builtin_constant_p(fmt) ? fmt : NULL; \
488 \
489 __ftrace_vbprintk(_THIS_IP_, trace_printk_fmt, vargs); \
490 } else \
491 __ftrace_vprintk(_THIS_IP_, fmt, vargs); \
492} while (0)
493
494extern int
495__ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap);
496
497extern int
498__ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap);
499
500extern void ftrace_dump(void);
501#else
502static inline void
503ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
504static inline int
505trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
506
507static inline void tracing_start(void) { }
508static inline void tracing_stop(void) { }
509static inline void ftrace_off_permanent(void) { }
510static inline int
511trace_printk(const char *fmt, ...)
512{
513 return 0;
514}
515static inline int
516ftrace_vprintk(const char *fmt, va_list ap)
517{
518 return 0;
519}
520static inline void ftrace_dump(void) { }
521#endif /* CONFIG_TRACING */
522
523/*
374 * Display an IP address in readable format. 524 * Display an IP address in readable format.
375 */ 525 */
376 526