Skip to content

Commit

Permalink
Merge branch 'tip/tracing/ftrace' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/git/rostedt/linux-2.6-trace into tracing/ftrace
  • Loading branch information
Ingo Molnar committed Feb 25, 2009
2 parents 886b5b7 + 1473e44 commit 2b1b858
Showing 9 changed files with 572 additions and 49 deletions.
11 changes: 10 additions & 1 deletion include/asm-generic/vmlinux.lds.h
Original file line number Diff line number Diff line change
@@ -61,6 +61,14 @@
#define BRANCH_PROFILE()
#endif

#ifdef CONFIG_EVENT_TRACER
#define FTRACE_EVENTS() VMLINUX_SYMBOL(__start_ftrace_events) = .; \
*(_ftrace_events) \
VMLINUX_SYMBOL(__stop_ftrace_events) = .;
#else
#define FTRACE_EVENTS()
#endif

/* .data section */
#define DATA_DATA \
*(.data) \
@@ -81,7 +89,8 @@
*(__tracepoints) \
VMLINUX_SYMBOL(__stop___tracepoints) = .; \
LIKELY_PROFILE() \
BRANCH_PROFILE()
BRANCH_PROFILE() \
FTRACE_EVENTS()

#define RO_DATA(align) \
. = ALIGN((align)); \
3 changes: 3 additions & 0 deletions include/linux/tracepoint.h
Original file line number Diff line number Diff line change
@@ -153,4 +153,7 @@ static inline void tracepoint_synchronize_unregister(void)
synchronize_sched();
}

#define DEFINE_TRACE_FMT(name, proto, args, fmt) \
DECLARE_TRACE(name, TPPROTO(proto), TPARGS(args))

#endif
49 changes: 1 addition & 48 deletions include/trace/sched.h
Original file line number Diff line number Diff line change
@@ -4,53 +4,6 @@
#include <linux/sched.h>
#include <linux/tracepoint.h>

DECLARE_TRACE(sched_kthread_stop,
TPPROTO(struct task_struct *t),
TPARGS(t));

DECLARE_TRACE(sched_kthread_stop_ret,
TPPROTO(int ret),
TPARGS(ret));

DECLARE_TRACE(sched_wait_task,
TPPROTO(struct rq *rq, struct task_struct *p),
TPARGS(rq, p));

DECLARE_TRACE(sched_wakeup,
TPPROTO(struct rq *rq, struct task_struct *p, int success),
TPARGS(rq, p, success));

DECLARE_TRACE(sched_wakeup_new,
TPPROTO(struct rq *rq, struct task_struct *p, int success),
TPARGS(rq, p, success));

DECLARE_TRACE(sched_switch,
TPPROTO(struct rq *rq, struct task_struct *prev,
struct task_struct *next),
TPARGS(rq, prev, next));

DECLARE_TRACE(sched_migrate_task,
TPPROTO(struct task_struct *p, int orig_cpu, int dest_cpu),
TPARGS(p, orig_cpu, dest_cpu));

DECLARE_TRACE(sched_process_free,
TPPROTO(struct task_struct *p),
TPARGS(p));

DECLARE_TRACE(sched_process_exit,
TPPROTO(struct task_struct *p),
TPARGS(p));

DECLARE_TRACE(sched_process_wait,
TPPROTO(struct pid *pid),
TPARGS(pid));

DECLARE_TRACE(sched_process_fork,
TPPROTO(struct task_struct *parent, struct task_struct *child),
TPARGS(parent, child));

DECLARE_TRACE(sched_signal_send,
TPPROTO(int sig, struct task_struct *p),
TPARGS(sig, p));
#include <trace/sched_event_types.h>

#endif
72 changes: 72 additions & 0 deletions include/trace/sched_event_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

/* use <trace/sched.h> instead */
#ifndef DEFINE_TRACE_FMT
# error Do not include this file directly.
# error Unless you know what you are doing.
#endif

DEFINE_TRACE_FMT(sched_kthread_stop,
TPPROTO(struct task_struct *t),
TPARGS(t),
TPFMT("task %s:%d", t->comm, t->pid));

DEFINE_TRACE_FMT(sched_kthread_stop_ret,
TPPROTO(int ret),
TPARGS(ret),
TPFMT("ret=%d", ret));

DEFINE_TRACE_FMT(sched_wait_task,
TPPROTO(struct rq *rq, struct task_struct *p),
TPARGS(rq, p),
TPFMT("task %s:%d", p->comm, p->pid));

DEFINE_TRACE_FMT(sched_wakeup,
TPPROTO(struct rq *rq, struct task_struct *p, int success),
TPARGS(rq, p, success),
TPFMT("task %s:%d %s",
p->comm, p->pid, success?"succeeded":"failed"));

DEFINE_TRACE_FMT(sched_wakeup_new,
TPPROTO(struct rq *rq, struct task_struct *p, int success),
TPARGS(rq, p, success),
TPFMT("task %s:%d",
p->comm, p->pid, success?"succeeded":"failed"));

DEFINE_TRACE_FMT(sched_switch,
TPPROTO(struct rq *rq, struct task_struct *prev,
struct task_struct *next),
TPARGS(rq, prev, next),
TPFMT("task %s:%d ==> %s:%d",
prev->comm, prev->pid, next->comm, next->pid));

DEFINE_TRACE_FMT(sched_migrate_task,
TPPROTO(struct task_struct *p, int orig_cpu, int dest_cpu),
TPARGS(p, orig_cpu, dest_cpu),
TPFMT("task %s:%d from: %d to: %d",
p->comm, p->pid, orig_cpu, dest_cpu));

DEFINE_TRACE_FMT(sched_process_free,
TPPROTO(struct task_struct *p),
TPARGS(p),
TPFMT("task %s:%d", p->comm, p->pid));

DEFINE_TRACE_FMT(sched_process_exit,
TPPROTO(struct task_struct *p),
TPARGS(p),
TPFMT("task %s:%d", p->comm, p->pid));

DEFINE_TRACE_FMT(sched_process_wait,
TPPROTO(struct pid *pid),
TPARGS(pid),
TPFMT("pid %d", pid));

DEFINE_TRACE_FMT(sched_process_fork,
TPPROTO(struct task_struct *parent, struct task_struct *child),
TPARGS(parent, child),
TPFMT("parent %s:%d child %s:%d",
parent->comm, parent->pid, child->comm, child->pid));

DEFINE_TRACE_FMT(sched_signal_send,
TPPROTO(int sig, struct task_struct *p),
TPARGS(sig, p),
TPFMT("sig: %d task %s:%d", sig, p->comm, p->pid));
9 changes: 9 additions & 0 deletions kernel/trace/Kconfig
Original file line number Diff line number Diff line change
@@ -159,6 +159,15 @@ config CONTEXT_SWITCH_TRACER
This tracer gets called from the context switch and records
all switching of tasks.

config EVENT_TRACER
bool "Trace various events in the kernel"
depends on DEBUG_KERNEL
select TRACING
help
This tracer hooks to various trace points in the kernel
allowing the user to pick and choose which trace point they
want to trace.

config BOOT_TRACER
bool "Trace boot initcalls"
depends on DEBUG_KERNEL
2 changes: 2 additions & 0 deletions kernel/trace/Makefile
Original file line number Diff line number Diff line change
@@ -38,5 +38,7 @@ obj-$(CONFIG_POWER_TRACER) += trace_power.o
obj-$(CONFIG_KMEMTRACE) += kmemtrace.o
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

libftrace-y := ftrace.o
13 changes: 13 additions & 0 deletions kernel/trace/events.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* This is the place to register all trace points as events.
* Include the trace/<type>.h at the top.
* Include the trace/<type>_event_types.h at the bottom.
*/

/* trace/<type>.h here */
#include <trace/sched.h>

#include "trace_events.h"

/* trace/<type>_event_types.h here */
#include <trace/sched_event_types.h>
407 changes: 407 additions & 0 deletions kernel/trace/trace_events.c

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions kernel/trace/trace_events.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#ifndef _LINUX_KERNEL_TRACE_EVENTS_H
#define _LINUX_KERNEL_TRACE_EVENTS_H

#include <linux/debugfs.h>
#include <linux/ftrace.h>
#include "trace.h"

struct ftrace_event_call {
char *name;
struct dentry *dir;
int enabled;
int (*regfunc)(void);
void (*unregfunc)(void);
};


#undef TPFMT
#define TPFMT(fmt, args...) fmt "\n", ##args

#undef DEFINE_TRACE_FMT
#define DEFINE_TRACE_FMT(call, proto, args, fmt) \
static void ftrace_event_##call(proto) \
{ \
event_trace_printk(_RET_IP_, "(" #call ") " fmt); \
} \
\
static int ftrace_reg_event_##call(void) \
{ \
int ret; \
\
ret = register_trace_##call(ftrace_event_##call); \
if (!ret) \
pr_info("event trace: Could not activate trace point " \
"probe to " #call); \
return ret; \
} \
\
static void ftrace_unreg_event_##call(void) \
{ \
unregister_trace_##call(ftrace_event_##call); \
} \
\
static struct ftrace_event_call __used \
__attribute__((__aligned__(4))) \
__attribute__((section("_ftrace_events"))) event_##call = { \
.name = #call, \
.regfunc = ftrace_reg_event_##call, \
.unregfunc = ftrace_unreg_event_##call, \
}

void event_trace_printk(unsigned long ip, const char *fmt, ...);
extern struct ftrace_event_call __start_ftrace_events[];
extern struct ftrace_event_call __stop_ftrace_events[];

#endif /* _LINUX_KERNEL_TRACE_EVENTS_H */

0 comments on commit 2b1b858

Please sign in to comment.