4 * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
6 * - Added format output of fields of the trace point.
7 * This was based off of work by Tom Zanussi <tzanussi@gmail.com>.
11 #include <linux/workqueue.h>
12 #include <linux/spinlock.h>
13 #include <linux/kthread.h>
14 #include <linux/debugfs.h>
15 #include <linux/uaccess.h>
16 #include <linux/module.h>
17 #include <linux/ctype.h>
18 #include <linux/delay.h>
20 #include "trace_output.h"
22 #define TRACE_SYSTEM "TRACE_SYSTEM"
24 DEFINE_MUTEX(event_mutex);
26 LIST_HEAD(ftrace_events);
28 int trace_define_field(struct ftrace_event_call *call, char *type,
29 char *name, int offset, int size, int is_signed)
31 struct ftrace_event_field *field;
33 field = kzalloc(sizeof(*field), GFP_KERNEL);
37 field->name = kstrdup(name, GFP_KERNEL);
41 field->type = kstrdup(type, GFP_KERNEL);
45 field->offset = offset;
47 field->is_signed = is_signed;
48 list_add(&field->link, &call->fields);
61 EXPORT_SYMBOL_GPL(trace_define_field);
65 static void trace_destroy_fields(struct ftrace_event_call *call)
67 struct ftrace_event_field *field, *next;
69 list_for_each_entry_safe(field, next, &call->fields, link) {
70 list_del(&field->link);
77 #endif /* CONFIG_MODULES */
79 static void ftrace_clear_events(void)
81 struct ftrace_event_call *call;
83 mutex_lock(&event_mutex);
84 list_for_each_entry(call, &ftrace_events, list) {
91 mutex_unlock(&event_mutex);
94 static void ftrace_event_enable_disable(struct ftrace_event_call *call,
106 if (!call->enabled) {
115 * __ftrace_set_clr_event(NULL, NULL, NULL, set) will set/unset all events.
117 static int __ftrace_set_clr_event(const char *match, const char *sub,
118 const char *event, int set)
120 struct ftrace_event_call *call;
123 mutex_lock(&event_mutex);
124 list_for_each_entry(call, &ftrace_events, list) {
126 if (!call->name || !call->regfunc)
130 strcmp(match, call->name) != 0 &&
131 strcmp(match, call->system) != 0)
134 if (sub && strcmp(sub, call->system) != 0)
137 if (event && strcmp(event, call->name) != 0)
140 ftrace_event_enable_disable(call, set);
144 mutex_unlock(&event_mutex);
149 static int ftrace_set_clr_event(char *buf, int set)
151 char *event = NULL, *sub = NULL, *match;
154 * The buf format can be <subsystem>:<event-name>
155 * *:<event-name> means any event by that name.
156 * :<event-name> is the same.
158 * <subsystem>:* means all events in that subsystem
159 * <subsystem>: means the same.
161 * <name> (no ':') means all events in a subsystem with
162 * the name <name> or any event that matches <name>
165 match = strsep(&buf, ":");
171 if (!strlen(sub) || strcmp(sub, "*") == 0)
173 if (!strlen(event) || strcmp(event, "*") == 0)
177 return __ftrace_set_clr_event(match, sub, event, set);
180 /* 128 should be much more than enough */
181 #define EVENT_BUF_SIZE 127
184 ftrace_event_write(struct file *file, const char __user *ubuf,
185 size_t cnt, loff_t *ppos)
196 ret = tracing_update_buffers();
200 ret = get_user(ch, ubuf++);
206 /* skip white space */
207 while (cnt && isspace(ch)) {
208 ret = get_user(ch, ubuf++);
215 /* Only white space found? */
222 buf = kmalloc(EVENT_BUF_SIZE+1, GFP_KERNEL);
226 if (cnt > EVENT_BUF_SIZE)
227 cnt = EVENT_BUF_SIZE;
230 while (cnt && !isspace(ch)) {
236 ret = get_user(ch, ubuf++);
246 ret = ftrace_set_clr_event(buf, set);
259 t_next(struct seq_file *m, void *v, loff_t *pos)
261 struct list_head *list = m->private;
262 struct ftrace_event_call *call;
267 if (list == &ftrace_events)
270 call = list_entry(list, struct ftrace_event_call, list);
273 * The ftrace subsystem is for showing formats only.
274 * They can not be enabled or disabled via the event files.
282 m->private = list->next;
287 static void *t_start(struct seq_file *m, loff_t *pos)
289 mutex_lock(&event_mutex);
291 m->private = ftrace_events.next;
292 return t_next(m, NULL, pos);
296 s_next(struct seq_file *m, void *v, loff_t *pos)
298 struct list_head *list = m->private;
299 struct ftrace_event_call *call;
304 if (list == &ftrace_events)
307 call = list_entry(list, struct ftrace_event_call, list);
309 if (!call->enabled) {
314 m->private = list->next;
319 static void *s_start(struct seq_file *m, loff_t *pos)
321 mutex_lock(&event_mutex);
323 m->private = ftrace_events.next;
324 return s_next(m, NULL, pos);
327 static int t_show(struct seq_file *m, void *v)
329 struct ftrace_event_call *call = v;
331 if (strcmp(call->system, TRACE_SYSTEM) != 0)
332 seq_printf(m, "%s:", call->system);
333 seq_printf(m, "%s\n", call->name);
338 static void t_stop(struct seq_file *m, void *p)
340 mutex_unlock(&event_mutex);
344 ftrace_event_seq_open(struct inode *inode, struct file *file)
346 const struct seq_operations *seq_ops;
348 if ((file->f_mode & FMODE_WRITE) &&
349 !(file->f_flags & O_APPEND))
350 ftrace_clear_events();
352 seq_ops = inode->i_private;
353 return seq_open(file, seq_ops);
357 event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
360 struct ftrace_event_call *call = filp->private_data;
368 return simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);
372 event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
375 struct ftrace_event_call *call = filp->private_data;
380 if (cnt >= sizeof(buf))
383 if (copy_from_user(&buf, ubuf, cnt))
388 ret = strict_strtoul(buf, 10, &val);
392 ret = tracing_update_buffers();
399 mutex_lock(&event_mutex);
400 ftrace_event_enable_disable(call, val);
401 mutex_unlock(&event_mutex);
414 system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
417 const char set_to_char[4] = { '?', '0', '1', 'X' };
418 const char *system = filp->private_data;
419 struct ftrace_event_call *call;
424 mutex_lock(&event_mutex);
425 list_for_each_entry(call, &ftrace_events, list) {
426 if (!call->name || !call->regfunc)
429 if (system && strcmp(call->system, system) != 0)
433 * We need to find out if all the events are set
434 * or if all events or cleared, or if we have
437 set |= (1 << !!call->enabled);
440 * If we have a mixture, no need to look further.
445 mutex_unlock(&event_mutex);
447 buf[0] = set_to_char[set];
450 ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);
456 system_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
459 const char *system = filp->private_data;
464 if (cnt >= sizeof(buf))
467 if (copy_from_user(&buf, ubuf, cnt))
472 ret = strict_strtoul(buf, 10, &val);
476 ret = tracing_update_buffers();
480 if (val != 0 && val != 1)
483 ret = __ftrace_set_clr_event(NULL, system, NULL, val);
495 extern char *__bad_type_size(void);
498 #define FIELD(type, name) \
499 sizeof(type) != sizeof(field.name) ? __bad_type_size() : \
500 #type, "common_" #name, offsetof(typeof(field), name), \
503 static int trace_write_header(struct trace_seq *s)
505 struct trace_entry field;
507 /* struct trace_entry */
508 return trace_seq_printf(s,
509 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
510 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
511 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
512 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
513 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
515 FIELD(unsigned short, type),
516 FIELD(unsigned char, flags),
517 FIELD(unsigned char, preempt_count),
523 event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
526 struct ftrace_event_call *call = filp->private_data;
534 s = kmalloc(sizeof(*s), GFP_KERNEL);
540 /* If any of the first writes fail, so will the show_format. */
542 trace_seq_printf(s, "name: %s\n", call->name);
543 trace_seq_printf(s, "ID: %d\n", call->id);
544 trace_seq_printf(s, "format:\n");
545 trace_write_header(s);
547 r = call->show_format(s);
550 * ug! The format output is bigger than a PAGE!!
552 buf = "FORMAT TOO BIG\n";
553 r = simple_read_from_buffer(ubuf, cnt, ppos,
558 r = simple_read_from_buffer(ubuf, cnt, ppos,
566 event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
568 struct ftrace_event_call *call = filp->private_data;
575 s = kmalloc(sizeof(*s), GFP_KERNEL);
580 trace_seq_printf(s, "%d\n", call->id);
582 r = simple_read_from_buffer(ubuf, cnt, ppos,
589 event_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
592 struct ftrace_event_call *call = filp->private_data;
599 s = kmalloc(sizeof(*s), GFP_KERNEL);
605 print_event_filter(call, s);
606 r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
614 event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
617 struct ftrace_event_call *call = filp->private_data;
621 if (cnt >= PAGE_SIZE)
624 buf = (char *)__get_free_page(GFP_TEMPORARY);
628 if (copy_from_user(buf, ubuf, cnt)) {
629 free_page((unsigned long) buf);
634 err = apply_event_filter(call, buf);
635 free_page((unsigned long) buf);
645 subsystem_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
648 struct event_subsystem *system = filp->private_data;
655 s = kmalloc(sizeof(*s), GFP_KERNEL);
661 print_subsystem_event_filter(system, s);
662 r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
670 subsystem_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
673 struct event_subsystem *system = filp->private_data;
677 if (cnt >= PAGE_SIZE)
680 buf = (char *)__get_free_page(GFP_TEMPORARY);
684 if (copy_from_user(buf, ubuf, cnt)) {
685 free_page((unsigned long) buf);
690 err = apply_subsystem_event_filter(system, buf);
691 free_page((unsigned long) buf);
701 show_header(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
703 int (*func)(struct trace_seq *s) = filp->private_data;
710 s = kmalloc(sizeof(*s), GFP_KERNEL);
717 r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
724 static const struct seq_operations show_event_seq_ops = {
731 static const struct seq_operations show_set_event_seq_ops = {
738 static const struct file_operations ftrace_avail_fops = {
739 .open = ftrace_event_seq_open,
742 .release = seq_release,
745 static const struct file_operations ftrace_set_event_fops = {
746 .open = ftrace_event_seq_open,
748 .write = ftrace_event_write,
750 .release = seq_release,
753 static const struct file_operations ftrace_enable_fops = {
754 .open = tracing_open_generic,
755 .read = event_enable_read,
756 .write = event_enable_write,
759 static const struct file_operations ftrace_event_format_fops = {
760 .open = tracing_open_generic,
761 .read = event_format_read,
764 static const struct file_operations ftrace_event_id_fops = {
765 .open = tracing_open_generic,
766 .read = event_id_read,
769 static const struct file_operations ftrace_event_filter_fops = {
770 .open = tracing_open_generic,
771 .read = event_filter_read,
772 .write = event_filter_write,
775 static const struct file_operations ftrace_subsystem_filter_fops = {
776 .open = tracing_open_generic,
777 .read = subsystem_filter_read,
778 .write = subsystem_filter_write,
781 static const struct file_operations ftrace_system_enable_fops = {
782 .open = tracing_open_generic,
783 .read = system_enable_read,
784 .write = system_enable_write,
787 static const struct file_operations ftrace_show_header_fops = {
788 .open = tracing_open_generic,
792 static struct dentry *event_trace_events_dir(void)
794 static struct dentry *d_tracer;
795 static struct dentry *d_events;
800 d_tracer = tracing_init_dentry();
804 d_events = debugfs_create_dir("events", d_tracer);
806 pr_warning("Could not create debugfs "
807 "'events' directory\n");
812 static LIST_HEAD(event_subsystems);
814 static struct dentry *
815 event_subsystem_dir(const char *name, struct dentry *d_events)
817 struct event_subsystem *system;
818 struct dentry *entry;
820 /* First see if we did not already create this dir */
821 list_for_each_entry(system, &event_subsystems, list) {
822 if (strcmp(system->name, name) == 0)
823 return system->entry;
826 /* need to create new entry */
827 system = kmalloc(sizeof(*system), GFP_KERNEL);
829 pr_warning("No memory to create event subsystem %s\n",
834 system->entry = debugfs_create_dir(name, d_events);
835 if (!system->entry) {
836 pr_warning("Could not create event subsystem %s\n",
842 system->name = kstrdup(name, GFP_KERNEL);
844 debugfs_remove(system->entry);
849 list_add(&system->list, &event_subsystems);
851 system->filter = NULL;
853 system->filter = kzalloc(sizeof(struct event_filter), GFP_KERNEL);
854 if (!system->filter) {
855 pr_warning("Could not allocate filter for subsystem "
857 return system->entry;
860 entry = debugfs_create_file("filter", 0644, system->entry, system,
861 &ftrace_subsystem_filter_fops);
863 kfree(system->filter);
864 system->filter = NULL;
865 pr_warning("Could not create debugfs "
866 "'%s/filter' entry\n", name);
869 entry = trace_create_file("enable", 0644, system->entry,
870 (void *)system->name,
871 &ftrace_system_enable_fops);
873 return system->entry;
877 event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
878 const struct file_operations *id,
879 const struct file_operations *enable,
880 const struct file_operations *filter,
881 const struct file_operations *format)
883 struct dentry *entry;
887 * If the trace point header did not define TRACE_SYSTEM
888 * then the system would be called "TRACE_SYSTEM".
890 if (strcmp(call->system, TRACE_SYSTEM) != 0)
891 d_events = event_subsystem_dir(call->system, d_events);
893 if (call->raw_init) {
894 ret = call->raw_init();
896 pr_warning("Could not initialize trace point"
897 " events/%s\n", call->name);
902 call->dir = debugfs_create_dir(call->name, d_events);
904 pr_warning("Could not create debugfs "
905 "'%s' directory\n", call->name);
910 entry = trace_create_file("enable", 0644, call->dir, call,
914 entry = trace_create_file("id", 0444, call->dir, call,
917 if (call->define_fields) {
918 ret = call->define_fields();
920 pr_warning("Could not initialize trace point"
921 " events/%s\n", call->name);
924 entry = trace_create_file("filter", 0644, call->dir, call,
928 /* A trace may not want to export its format */
929 if (!call->show_format)
932 entry = trace_create_file("format", 0444, call->dir, call,
938 #define for_each_event(event, start, end) \
939 for (event = start; \
940 (unsigned long)event < (unsigned long)end; \
943 #ifdef CONFIG_MODULES
945 static LIST_HEAD(ftrace_module_file_list);
948 * Modules must own their file_operations to keep up with
949 * reference counting.
951 struct ftrace_module_file_ops {
952 struct list_head list;
954 struct file_operations id;
955 struct file_operations enable;
956 struct file_operations format;
957 struct file_operations filter;
960 static struct ftrace_module_file_ops *
961 trace_create_file_ops(struct module *mod)
963 struct ftrace_module_file_ops *file_ops;
966 * This is a bit of a PITA. To allow for correct reference
967 * counting, modules must "own" their file_operations.
968 * To do this, we allocate the file operations that will be
969 * used in the event directory.
972 file_ops = kmalloc(sizeof(*file_ops), GFP_KERNEL);
978 file_ops->id = ftrace_event_id_fops;
979 file_ops->id.owner = mod;
981 file_ops->enable = ftrace_enable_fops;
982 file_ops->enable.owner = mod;
984 file_ops->filter = ftrace_event_filter_fops;
985 file_ops->filter.owner = mod;
987 file_ops->format = ftrace_event_format_fops;
988 file_ops->format.owner = mod;
990 list_add(&file_ops->list, &ftrace_module_file_list);
995 static void trace_module_add_events(struct module *mod)
997 struct ftrace_module_file_ops *file_ops = NULL;
998 struct ftrace_event_call *call, *start, *end;
999 struct dentry *d_events;
1001 start = mod->trace_events;
1002 end = mod->trace_events + mod->num_trace_events;
1007 d_events = event_trace_events_dir();
1011 for_each_event(call, start, end) {
1012 /* The linker may leave blanks */
1017 * This module has events, create file ops for this module
1018 * if not already done.
1021 file_ops = trace_create_file_ops(mod);
1026 list_add(&call->list, &ftrace_events);
1027 event_create_dir(call, d_events,
1028 &file_ops->id, &file_ops->enable,
1029 &file_ops->filter, &file_ops->format);
1033 static void trace_module_remove_events(struct module *mod)
1035 struct ftrace_module_file_ops *file_ops;
1036 struct ftrace_event_call *call, *p;
1039 list_for_each_entry_safe(call, p, &ftrace_events, list) {
1040 if (call->mod == mod) {
1042 if (call->enabled) {
1047 unregister_ftrace_event(call->event);
1048 debugfs_remove_recursive(call->dir);
1049 list_del(&call->list);
1050 trace_destroy_fields(call);
1051 destroy_preds(call);
1055 /* Now free the file_operations */
1056 list_for_each_entry(file_ops, &ftrace_module_file_list, list) {
1057 if (file_ops->mod == mod)
1060 if (&file_ops->list != &ftrace_module_file_list) {
1061 list_del(&file_ops->list);
1066 * It is safest to reset the ring buffer if the module being unloaded
1067 * registered any events.
1070 tracing_reset_current_online_cpus();
1073 static int trace_module_notify(struct notifier_block *self,
1074 unsigned long val, void *data)
1076 struct module *mod = data;
1078 mutex_lock(&event_mutex);
1080 case MODULE_STATE_COMING:
1081 trace_module_add_events(mod);
1083 case MODULE_STATE_GOING:
1084 trace_module_remove_events(mod);
1087 mutex_unlock(&event_mutex);
1092 static int trace_module_notify(struct notifier_block *self,
1093 unsigned long val, void *data)
1097 #endif /* CONFIG_MODULES */
1099 struct notifier_block trace_module_nb = {
1100 .notifier_call = trace_module_notify,
1104 extern struct ftrace_event_call __start_ftrace_events[];
1105 extern struct ftrace_event_call __stop_ftrace_events[];
1107 static __init int event_trace_init(void)
1109 struct ftrace_event_call *call;
1110 struct dentry *d_tracer;
1111 struct dentry *entry;
1112 struct dentry *d_events;
1115 d_tracer = tracing_init_dentry();
1119 entry = debugfs_create_file("available_events", 0444, d_tracer,
1120 (void *)&show_event_seq_ops,
1121 &ftrace_avail_fops);
1123 pr_warning("Could not create debugfs "
1124 "'available_events' entry\n");
1126 entry = debugfs_create_file("set_event", 0644, d_tracer,
1127 (void *)&show_set_event_seq_ops,
1128 &ftrace_set_event_fops);
1130 pr_warning("Could not create debugfs "
1131 "'set_event' entry\n");
1133 d_events = event_trace_events_dir();
1137 /* ring buffer internal formats */
1138 trace_create_file("header_page", 0444, d_events,
1139 ring_buffer_print_page_header,
1140 &ftrace_show_header_fops);
1142 trace_create_file("header_event", 0444, d_events,
1143 ring_buffer_print_entry_header,
1144 &ftrace_show_header_fops);
1146 trace_create_file("enable", 0644, d_events,
1147 NULL, &ftrace_system_enable_fops);
1149 for_each_event(call, __start_ftrace_events, __stop_ftrace_events) {
1150 /* The linker may leave blanks */
1153 list_add(&call->list, &ftrace_events);
1154 event_create_dir(call, d_events, &ftrace_event_id_fops,
1155 &ftrace_enable_fops, &ftrace_event_filter_fops,
1156 &ftrace_event_format_fops);
1159 ret = register_module_notifier(&trace_module_nb);
1161 pr_warning("Failed to register trace events module notifier\n");
1165 fs_initcall(event_trace_init);
1167 #ifdef CONFIG_FTRACE_STARTUP_TEST
1169 static DEFINE_SPINLOCK(test_spinlock);
1170 static DEFINE_SPINLOCK(test_spinlock_irq);
1171 static DEFINE_MUTEX(test_mutex);
1173 static __init void test_work(struct work_struct *dummy)
1175 spin_lock(&test_spinlock);
1176 spin_lock_irq(&test_spinlock_irq);
1178 spin_unlock_irq(&test_spinlock_irq);
1179 spin_unlock(&test_spinlock);
1181 mutex_lock(&test_mutex);
1183 mutex_unlock(&test_mutex);
1186 static __init int event_test_thread(void *unused)
1190 test_malloc = kmalloc(1234, GFP_KERNEL);
1192 pr_info("failed to kmalloc\n");
1194 schedule_on_each_cpu(test_work);
1198 set_current_state(TASK_INTERRUPTIBLE);
1199 while (!kthread_should_stop())
1206 * Do various things that may trigger events.
1208 static __init void event_test_stuff(void)
1210 struct task_struct *test_thread;
1212 test_thread = kthread_run(event_test_thread, NULL, "test-events");
1214 kthread_stop(test_thread);
1218 * For every trace event defined, we will test each trace point separately,
1219 * and then by groups, and finally all trace points.
1221 static __init void event_trace_self_tests(void)
1223 struct ftrace_event_call *call;
1224 struct event_subsystem *system;
1227 pr_info("Running tests on trace events:\n");
1229 list_for_each_entry(call, &ftrace_events, list) {
1231 /* Only test those that have a regfunc */
1235 pr_info("Testing event %s: ", call->name);
1238 * If an event is already enabled, someone is using
1239 * it and the self test should not be on.
1241 if (call->enabled) {
1242 pr_warning("Enabled event during self test!\n");
1258 /* Now test at the sub system level */
1260 pr_info("Running tests on trace event systems:\n");
1262 list_for_each_entry(system, &event_subsystems, list) {
1264 /* the ftrace system is special, skip it */
1265 if (strcmp(system->name, "ftrace") == 0)
1268 pr_info("Testing event system %s: ", system->name);
1270 ret = __ftrace_set_clr_event(NULL, system->name, NULL, 1);
1271 if (WARN_ON_ONCE(ret)) {
1272 pr_warning("error enabling system %s\n",
1279 ret = __ftrace_set_clr_event(NULL, system->name, NULL, 0);
1280 if (WARN_ON_ONCE(ret))
1281 pr_warning("error disabling system %s\n",
1287 /* Test with all events enabled */
1289 pr_info("Running tests on all trace events:\n");
1290 pr_info("Testing all events: ");
1292 ret = __ftrace_set_clr_event(NULL, NULL, NULL, 1);
1293 if (WARN_ON_ONCE(ret)) {
1294 pr_warning("error enabling all events\n");
1301 ret = __ftrace_set_clr_event(NULL, NULL, NULL, 0);
1302 if (WARN_ON_ONCE(ret)) {
1303 pr_warning("error disabling all events\n");
1310 #ifdef CONFIG_FUNCTION_TRACER
1312 static DEFINE_PER_CPU(atomic_t, test_event_disable);
1315 function_test_events_call(unsigned long ip, unsigned long parent_ip)
1317 struct ring_buffer_event *event;
1318 struct ftrace_entry *entry;
1319 unsigned long flags;
1325 pc = preempt_count();
1326 resched = ftrace_preempt_disable();
1327 cpu = raw_smp_processor_id();
1328 disabled = atomic_inc_return(&per_cpu(test_event_disable, cpu));
1333 local_save_flags(flags);
1335 event = trace_current_buffer_lock_reserve(TRACE_FN, sizeof(*entry),
1339 entry = ring_buffer_event_data(event);
1341 entry->parent_ip = parent_ip;
1343 trace_nowake_buffer_unlock_commit(event, flags, pc);
1346 atomic_dec(&per_cpu(test_event_disable, cpu));
1347 ftrace_preempt_enable(resched);
1350 static struct ftrace_ops trace_ops __initdata =
1352 .func = function_test_events_call,
1355 static __init void event_trace_self_test_with_function(void)
1357 register_ftrace_function(&trace_ops);
1358 pr_info("Running tests again, along with the function tracer\n");
1359 event_trace_self_tests();
1360 unregister_ftrace_function(&trace_ops);
1363 static __init void event_trace_self_test_with_function(void)
1368 static __init int event_trace_self_tests_init(void)
1371 event_trace_self_tests();
1373 event_trace_self_test_with_function();
1378 late_initcall(event_trace_self_tests_init);