Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140886
b: refs/heads/master
c: dba58e3
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar committed Mar 8, 2009
1 parent 18292a0 commit 6021379
Show file tree
Hide file tree
Showing 27 changed files with 1,469 additions and 428 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 78ff7fae04554b49d29226ed12536268c2500d1f
refs/heads/master: dba58e39ced7af63f2748d12bbb2b4ac83c72391
9 changes: 9 additions & 0 deletions trunk/include/asm-generic/vmlinux.lds.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@
#define FTRACE_EVENTS()
#endif

#ifdef CONFIG_TRACING
#define TRACE_PRINTKS() VMLINUX_SYMBOL(__start___trace_bprintk_fmt) = .; \
*(__trace_printk_fmt) /* Trace_printk fmt' pointer */ \
VMLINUX_SYMBOL(__stop___trace_bprintk_fmt) = .;
#else
#define TRACE_PRINTKS()
#endif

/* .data section */
#define DATA_DATA \
*(.data) \
Expand Down Expand Up @@ -100,6 +108,7 @@
*(__vermagic) /* Kernel version magic */ \
*(__markers_strings) /* Markers: strings */ \
*(__tracepoints_strings)/* Tracepoints: strings */ \
TRACE_PRINTKS() \
} \
\
.rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \
Expand Down
1 change: 0 additions & 1 deletion trunk/include/linux/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ extern int ftrace_make_nop(struct module *mod,
*/
extern int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr);


/* May be defined in arch */
extern int ftrace_arch_read_dyn_info(char *buf, int size);

Expand Down
80 changes: 76 additions & 4 deletions trunk/include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,19 @@ extern struct ratelimit_state printk_ratelimit_state;
extern int printk_ratelimit(void);
extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
unsigned int interval_msec);

/*
* Print a one-time message (analogous to WARN_ONCE() et al):
*/
#define printk_once(x...) ({ \
static int __print_once = 1; \
\
if (__print_once) { \
__print_once = 0; \
printk(x); \
} \
})

#else
static inline int vprintk(const char *s, va_list args)
__attribute__ ((format (printf, 1, 0)));
Expand All @@ -253,6 +266,10 @@ static inline int printk_ratelimit(void) { return 0; }
static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
unsigned int interval_msec) \
{ return false; }

/* No effect, but we still get type checking even in the !PRINTK case: */
#define printk_once(x...) printk(x)

#endif

extern int printk_needs_cpu(int cpu);
Expand Down Expand Up @@ -369,8 +386,35 @@ static inline char *pack_hex_byte(char *buf, u8 byte)

/*
* General tracing related utility functions - trace_printk(),
* tracing_start()/tracing_stop:
* tracing_on/tracing_off and tracing_start()/tracing_stop
*
* Use tracing_on/tracing_off when you want to quickly turn on or off
* tracing. It simply enables or disables the recording of the trace events.
* This also corresponds to the user space debugfs/tracing/tracing_on
* file, which gives a means for the kernel and userspace to interact.
* Place a tracing_off() in the kernel where you want tracing to end.
* From user space, examine the trace, and then echo 1 > tracing_on
* to continue tracing.
*
* tracing_stop/tracing_start has slightly more overhead. It is used
* by things like suspend to ram where disabling the recording of the
* trace is not enough, but tracing must actually stop because things
* like calling smp_processor_id() may crash the system.
*
* Most likely, you want to use tracing_on/tracing_off.
*/
#ifdef CONFIG_RING_BUFFER
void tracing_on(void);
void tracing_off(void);
/* trace_off_permanent stops recording with no way to bring it back */
void tracing_off_permanent(void);
int tracing_is_on(void);
#else
static inline void tracing_on(void) { }
static inline void tracing_off(void) { }
static inline void tracing_off_permanent(void) { }
static inline int tracing_is_on(void) { return 0; }
#endif
#ifdef CONFIG_TRACING
extern void tracing_start(void);
extern void tracing_stop(void);
Expand All @@ -379,6 +423,16 @@ extern void ftrace_off_permanent(void);
extern void
ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);

static inline void __attribute__ ((format (printf, 1, 2)))
____trace_printk_check_format(const char *fmt, ...)
{
}
#define __trace_printk_check_format(fmt, args...) \
do { \
if (0) \
____trace_printk_check_format(fmt, ##args); \
} while (0)

/**
* trace_printk - printf formatting in the ftrace buffer
* @fmt: the printf format for printing
Expand All @@ -395,13 +449,31 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
* Please refrain from leaving trace_printks scattered around in
* your code.
*/
# define trace_printk(fmt...) __trace_printk(_THIS_IP_, fmt)

#define trace_printk(fmt, args...) \
do { \
static const char *trace_printk_fmt \
__attribute__((section("__trace_printk_fmt"))); \
trace_printk_fmt = fmt; \
__trace_printk_check_format(fmt, ##args); \
__trace_printk(_THIS_IP_, trace_printk_fmt, ##args); \
} while (0)

extern int
__trace_printk(unsigned long ip, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
# define ftrace_vprintk(fmt, ap) __trace_printk(_THIS_IP_, fmt, ap)

#define ftrace_vprintk(fmt, vargs) \
do { \
static const char *trace_printk_fmt \
__attribute__((section("__trace_printk_fmt"))); \
trace_printk_fmt = fmt; \
__ftrace_vprintk(_THIS_IP_, trace_printk_fmt, vargs); \
} while (0)

extern int
__ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap);

extern void ftrace_dump(void);
#else
static inline void
Expand All @@ -423,7 +495,7 @@ ftrace_vprintk(const char *fmt, va_list ap)
return 0;
}
static inline void ftrace_dump(void) { }
#endif
#endif /* CONFIG_TRACING */

/*
* Display an IP address in readable format.
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/linux/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ struct module
unsigned int num_tracepoints;
#endif

#ifdef CONFIG_TRACING
const char **trace_bprintk_fmt_start;
unsigned int num_trace_bprintk_fmt;
#endif

#ifdef CONFIG_MODULE_UNLOAD
/* What modules depend on me? */
struct list_head modules_which_use_me;
Expand Down
15 changes: 0 additions & 15 deletions trunk/include/linux/ring_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,6 @@ void ring_buffer_normalize_time_stamp(int cpu, u64 *ts);
size_t ring_buffer_page_len(void *page);


/*
* The below functions are fine to use outside the tracing facility.
*/
#ifdef CONFIG_RING_BUFFER
void tracing_on(void);
void tracing_off(void);
void tracing_off_permanent(void);
int tracing_is_on(void);
#else
static inline void tracing_on(void) { }
static inline void tracing_off(void) { }
static inline void tracing_off_permanent(void) { }
static inline int tracing_is_on(void) { return 0; }
#endif

void *ring_buffer_alloc_read_page(struct ring_buffer *buffer);
void ring_buffer_free_read_page(struct ring_buffer *buffer, void *data);
int ring_buffer_read_page(struct ring_buffer *buffer, void **data_page,
Expand Down
7 changes: 7 additions & 0 deletions trunk/include/linux/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/compiler.h> /* for inline */
#include <linux/types.h> /* for size_t */
#include <linux/stddef.h> /* for NULL */
#include <stdarg.h>

extern char *strndup_user(const char __user *, long);

Expand Down Expand Up @@ -111,6 +112,12 @@ extern void argv_free(char **argv);

extern bool sysfs_streq(const char *s1, const char *s2);

#ifdef CONFIG_BINARY_PRINTF
int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf);
int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...) __printf(3, 4);
#endif

extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
const void *from, size_t available);

Expand Down
2 changes: 0 additions & 2 deletions trunk/include/trace/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ enum {
};

struct power_trace {
#ifdef CONFIG_POWER_TRACER
ktime_t stamp;
ktime_t end;
int type;
int state;
#endif
};

DECLARE_TRACE(power_start,
Expand Down
2 changes: 2 additions & 0 deletions trunk/kernel/trace/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ config TRACING
select STACKTRACE if STACKTRACE_SUPPORT
select TRACEPOINTS
select NOP_TRACER
select BINARY_PRINTF

#
# Minimum requirements an architecture has to meet for us to
Expand All @@ -61,6 +62,7 @@ config TRACING_SUPPORT
bool
depends on TRACE_IRQFLAGS_SUPPORT
depends on STACKTRACE_SUPPORT
default y

if TRACING_SUPPORT

Expand Down
2 changes: 2 additions & 0 deletions trunk/kernel/trace/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ obj-$(CONFIG_TRACING) += trace.o
obj-$(CONFIG_TRACING) += trace_clock.o
obj-$(CONFIG_TRACING) += trace_output.o
obj-$(CONFIG_TRACING) += trace_stat.o
obj-$(CONFIG_TRACING) += trace_printk.o
obj-$(CONFIG_CONTEXT_SWITCH_TRACER) += trace_sched_switch.o
obj-$(CONFIG_SYSPROF_TRACER) += trace_sysprof.o
obj-$(CONFIG_FUNCTION_TRACER) += trace_functions.o
Expand All @@ -41,5 +42,6 @@ obj-$(CONFIG_WORKQUEUE_TRACER) += trace_workqueue.o
obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o
obj-$(CONFIG_EVENT_TRACER) += trace_events.o
obj-$(CONFIG_EVENT_TRACER) += events.o
obj-$(CONFIG_EVENT_TRACER) += trace_export.o

libftrace-y := ftrace.o
17 changes: 6 additions & 11 deletions trunk/kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,8 @@ static void ftrace_update_pid_func(void)
{
ftrace_func_t func;

mutex_lock(&ftrace_lock);

if (ftrace_trace_function == ftrace_stub)
goto out;
return;

func = ftrace_trace_function;

Expand All @@ -238,9 +236,6 @@ static void ftrace_update_pid_func(void)
#else
__ftrace_trace_function = func;
#endif

out:
mutex_unlock(&ftrace_lock);
}

/* set when tracing only a pid */
Expand Down Expand Up @@ -1869,29 +1864,29 @@ ftrace_notrace_release(struct inode *inode, struct file *file)
return ftrace_regex_release(inode, file, 0);
}

static struct file_operations ftrace_avail_fops = {
static const struct file_operations ftrace_avail_fops = {
.open = ftrace_avail_open,
.read = seq_read,
.llseek = seq_lseek,
.release = ftrace_avail_release,
};

static struct file_operations ftrace_failures_fops = {
static const struct file_operations ftrace_failures_fops = {
.open = ftrace_failures_open,
.read = seq_read,
.llseek = seq_lseek,
.release = ftrace_avail_release,
};

static struct file_operations ftrace_filter_fops = {
static const struct file_operations ftrace_filter_fops = {
.open = ftrace_filter_open,
.read = ftrace_regex_read,
.write = ftrace_filter_write,
.llseek = ftrace_regex_lseek,
.release = ftrace_filter_release,
};

static struct file_operations ftrace_notrace_fops = {
static const struct file_operations ftrace_notrace_fops = {
.open = ftrace_notrace_open,
.read = ftrace_regex_read,
.write = ftrace_notrace_write,
Expand Down Expand Up @@ -2423,7 +2418,7 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf,
return cnt;
}

static struct file_operations ftrace_pid_fops = {
static const struct file_operations ftrace_pid_fops = {
.read = ftrace_pid_read,
.write = ftrace_pid_write,
};
Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,7 @@ rb_simple_write(struct file *filp, const char __user *ubuf,
return cnt;
}

static struct file_operations rb_simple_fops = {
static const struct file_operations rb_simple_fops = {
.open = tracing_open_generic,
.read = rb_simple_read,
.write = rb_simple_write,
Expand Down
Loading

0 comments on commit 6021379

Please sign in to comment.