4 * Copyright (C) 2007 Steven Rostedt <srostedt@redhat.com>
7 #include <linux/module.h>
9 #include <linux/debugfs.h>
10 #include <linux/kallsyms.h>
11 #include <linux/uaccess.h>
12 #include <linux/ftrace.h>
13 #include <trace/events/sched.h>
18 static DEFINE_MUTEX(sched_register_mutex
);
21 probe_sched_switch(void *ignore
, struct task_struct
*prev
, struct task_struct
*next
)
23 if (unlikely(!sched_ref
))
26 tracing_record_cmdline(prev
);
27 tracing_record_cmdline(next
);
31 probe_sched_wakeup(void *ignore
, struct task_struct
*wakee
, int success
)
33 if (unlikely(!sched_ref
))
36 tracing_record_cmdline(current
);
39 static int tracing_sched_register(void)
43 ret
= register_trace_sched_wakeup(probe_sched_wakeup
, NULL
);
45 pr_info("wakeup trace: Couldn't activate tracepoint"
46 " probe to kernel_sched_wakeup\n");
50 ret
= register_trace_sched_wakeup_new(probe_sched_wakeup
, NULL
);
52 pr_info("wakeup trace: Couldn't activate tracepoint"
53 " probe to kernel_sched_wakeup_new\n");
57 ret
= register_trace_sched_switch(probe_sched_switch
, NULL
);
59 pr_info("sched trace: Couldn't activate tracepoint"
60 " probe to kernel_sched_switch\n");
61 goto fail_deprobe_wake_new
;
65 fail_deprobe_wake_new
:
66 unregister_trace_sched_wakeup_new(probe_sched_wakeup
, NULL
);
68 unregister_trace_sched_wakeup(probe_sched_wakeup
, NULL
);
72 static void tracing_sched_unregister(void)
74 unregister_trace_sched_switch(probe_sched_switch
, NULL
);
75 unregister_trace_sched_wakeup_new(probe_sched_wakeup
, NULL
);
76 unregister_trace_sched_wakeup(probe_sched_wakeup
, NULL
);
79 static void tracing_start_sched_switch(void)
81 mutex_lock(&sched_register_mutex
);
83 tracing_sched_register();
84 mutex_unlock(&sched_register_mutex
);
87 static void tracing_stop_sched_switch(void)
89 mutex_lock(&sched_register_mutex
);
91 tracing_sched_unregister();
92 mutex_unlock(&sched_register_mutex
);
95 void tracing_start_cmdline_record(void)
97 tracing_start_sched_switch();
100 void tracing_stop_cmdline_record(void)
102 tracing_stop_sched_switch();
This page took 0.062496 seconds and 5 git commands to generate.