aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/ftrace.h1
-rw-r--r--include/linux/kernel.h80
-rw-r--r--include/linux/module.h5
-rw-r--r--include/linux/ring_buffer.h15
-rw-r--r--include/linux/string.h7
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 */
224extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr); 224extern 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 */
228extern int ftrace_arch_read_dyn_info(char *buf, int size); 227extern 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;
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);
@@ -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
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
374#ifdef CONFIG_TRACING 418#ifdef CONFIG_TRACING
375extern void tracing_start(void); 419extern void tracing_start(void);
376extern void tracing_stop(void); 420extern void tracing_stop(void);
@@ -379,6 +423,16 @@ extern void ftrace_off_permanent(void);
379extern void 423extern void
380ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); 424ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
381 425
426static 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...) \
431do { \
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...) \
454do { \
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
399extern int 462extern 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) \
467do { \
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
403extern int 474extern 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
405extern void ftrace_dump(void); 477extern void ftrace_dump(void);
406#else 478#else
407static inline void 479static inline void
@@ -423,7 +495,7 @@ ftrace_vprintk(const char *fmt, va_list ap)
423 return 0; 495 return 0;
424} 496}
425static inline void ftrace_dump(void) { } 497static 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);
124size_t ring_buffer_page_len(void *page); 124size_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
131void tracing_on(void);
132void tracing_off(void);
133void tracing_off_permanent(void);
134int tracing_is_on(void);
135#else
136static inline void tracing_on(void) { }
137static inline void tracing_off(void) { }
138static inline void tracing_off_permanent(void) { }
139static inline int tracing_is_on(void) { return 0; }
140#endif
141
142void *ring_buffer_alloc_read_page(struct ring_buffer *buffer); 127void *ring_buffer_alloc_read_page(struct ring_buffer *buffer);
143void ring_buffer_free_read_page(struct ring_buffer *buffer, void *data); 128void ring_buffer_free_read_page(struct ring_buffer *buffer, void *data);
144int ring_buffer_read_page(struct ring_buffer *buffer, void **data_page, 129int 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
14extern char *strndup_user(const char __user *, long); 15extern char *strndup_user(const char __user *, long);
15 16
@@ -111,6 +112,12 @@ extern void argv_free(char **argv);
111 112
112extern bool sysfs_streq(const char *s1, const char *s2); 113extern bool sysfs_streq(const char *s1, const char *s2);
113 114
115#ifdef CONFIG_BINARY_PRINTF
116int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
117int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf);
118int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...) __printf(3, 4);
119#endif
120
114extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos, 121extern 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