Lines Matching refs:tr
99 dummy_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set) in dummy_set_flag() argument
178 int tracing_set_tracer(struct trace_array *tr, const char *buf);
179 static void ftrace_trace_userstack(struct trace_array *tr,
457 struct trace_array *tr; in trace_array_get() local
461 list_for_each_entry(tr, &ftrace_trace_arrays, list) { in trace_array_get()
462 if (tr == this_tr) { in trace_array_get()
463 tr->ref++; in trace_array_get()
499 int tracing_check_open_get_tr(struct trace_array *tr) in tracing_check_open_get_tr() argument
510 if (tr && trace_array_get(tr) < 0) in tracing_check_open_get_tr()
914 static inline void ftrace_trace_stack(struct trace_array *tr,
925 static inline void ftrace_trace_stack(struct trace_array *tr, in ftrace_trace_stack() argument
958 void tracer_tracing_on(struct trace_array *tr) in tracer_tracing_on() argument
960 if (tr->array_buffer.buffer) in tracer_tracing_on()
961 ring_buffer_record_on(tr->array_buffer.buffer); in tracer_tracing_on()
970 tr->buffer_disabled = 0; in tracer_tracing_on()
1101 static void tracing_snapshot_instance_cond(struct trace_array *tr, in tracing_snapshot_instance_cond() argument
1104 struct tracer *tracer = tr->current_trace; in tracing_snapshot_instance_cond()
1113 if (!tr->allocated_snapshot) { in tracing_snapshot_instance_cond()
1128 update_max_tr(tr, current, smp_processor_id(), cond_data); in tracing_snapshot_instance_cond()
1132 void tracing_snapshot_instance(struct trace_array *tr) in tracing_snapshot_instance() argument
1134 tracing_snapshot_instance_cond(tr, NULL); in tracing_snapshot_instance()
1153 struct trace_array *tr = &global_trace; in tracing_snapshot() local
1155 tracing_snapshot_instance(tr); in tracing_snapshot()
1172 void tracing_snapshot_cond(struct trace_array *tr, void *cond_data) in tracing_snapshot_cond() argument
1174 tracing_snapshot_instance_cond(tr, cond_data); in tracing_snapshot_cond()
1192 void *tracing_cond_snapshot_data(struct trace_array *tr) in tracing_cond_snapshot_data() argument
1197 arch_spin_lock(&tr->max_lock); in tracing_cond_snapshot_data()
1199 if (tr->cond_snapshot) in tracing_cond_snapshot_data()
1200 cond_data = tr->cond_snapshot->cond_data; in tracing_cond_snapshot_data()
1202 arch_spin_unlock(&tr->max_lock); in tracing_cond_snapshot_data()
1213 int tracing_alloc_snapshot_instance(struct trace_array *tr) in tracing_alloc_snapshot_instance() argument
1217 if (!tr->allocated_snapshot) { in tracing_alloc_snapshot_instance()
1220 ret = resize_buffer_duplicate_size(&tr->max_buffer, in tracing_alloc_snapshot_instance()
1221 &tr->array_buffer, RING_BUFFER_ALL_CPUS); in tracing_alloc_snapshot_instance()
1225 tr->allocated_snapshot = true; in tracing_alloc_snapshot_instance()
1231 static void free_snapshot(struct trace_array *tr) in free_snapshot() argument
1238 ring_buffer_resize(tr->max_buffer.buffer, 1, RING_BUFFER_ALL_CPUS); in free_snapshot()
1239 set_buffer_entries(&tr->max_buffer, 1); in free_snapshot()
1240 tracing_reset_online_cpus(&tr->max_buffer); in free_snapshot()
1241 tr->allocated_snapshot = false; in free_snapshot()
1256 struct trace_array *tr = &global_trace; in tracing_alloc_snapshot() local
1259 ret = tracing_alloc_snapshot_instance(tr); in tracing_alloc_snapshot()
1302 int tracing_snapshot_cond_enable(struct trace_array *tr, void *cond_data, in tracing_snapshot_cond_enable() argument
1317 ret = tracing_alloc_snapshot_instance(tr); in tracing_snapshot_cond_enable()
1321 if (tr->current_trace->use_max_tr) { in tracing_snapshot_cond_enable()
1334 if (tr->cond_snapshot) { in tracing_snapshot_cond_enable()
1340 arch_spin_lock(&tr->max_lock); in tracing_snapshot_cond_enable()
1341 tr->cond_snapshot = cond_snapshot; in tracing_snapshot_cond_enable()
1342 arch_spin_unlock(&tr->max_lock); in tracing_snapshot_cond_enable()
1366 int tracing_snapshot_cond_disable(struct trace_array *tr) in tracing_snapshot_cond_disable() argument
1371 arch_spin_lock(&tr->max_lock); in tracing_snapshot_cond_disable()
1373 if (!tr->cond_snapshot) in tracing_snapshot_cond_disable()
1376 kfree(tr->cond_snapshot); in tracing_snapshot_cond_disable()
1377 tr->cond_snapshot = NULL; in tracing_snapshot_cond_disable()
1380 arch_spin_unlock(&tr->max_lock); in tracing_snapshot_cond_disable()
1392 void tracing_snapshot_cond(struct trace_array *tr, void *cond_data) in tracing_snapshot_cond() argument
1409 void *tracing_cond_snapshot_data(struct trace_array *tr) in tracing_cond_snapshot_data() argument
1414 int tracing_snapshot_cond_enable(struct trace_array *tr, void *cond_data, cond_update_fn_t update) in tracing_snapshot_cond_enable() argument
1419 int tracing_snapshot_cond_disable(struct trace_array *tr) in tracing_snapshot_cond_disable() argument
1424 #define free_snapshot(tr) do { } while (0) argument
1427 void tracer_tracing_off(struct trace_array *tr) in tracer_tracing_off() argument
1429 if (tr->array_buffer.buffer) in tracer_tracing_off()
1430 ring_buffer_record_off(tr->array_buffer.buffer); in tracer_tracing_off()
1439 tr->buffer_disabled = 1; in tracer_tracing_off()
1473 bool tracer_tracing_is_on(struct trace_array *tr) in tracer_tracing_is_on() argument
1475 if (tr->array_buffer.buffer) in tracer_tracing_is_on()
1476 return ring_buffer_record_is_on(tr->array_buffer.buffer); in tracer_tracing_is_on()
1477 return !tr->buffer_disabled; in tracer_tracing_is_on()
1558 bool trace_clock_in_ns(struct trace_array *tr) in trace_clock_in_ns() argument
1560 if (trace_clocks[tr->clock_id].in_ns) in trace_clock_in_ns()
1706 struct trace_array *tr = container_of(work, struct trace_array, in latency_fsnotify_workfn() local
1708 fsnotify_inode(tr->d_max_latency->d_inode, FS_MODIFY); in latency_fsnotify_workfn()
1713 struct trace_array *tr = container_of(iwork, struct trace_array, in latency_fsnotify_workfn_irq() local
1715 queue_work(fsnotify_wq, &tr->fsnotify_work); in latency_fsnotify_workfn_irq()
1718 static void trace_create_maxlat_file(struct trace_array *tr, in trace_create_maxlat_file() argument
1721 INIT_WORK(&tr->fsnotify_work, latency_fsnotify_workfn); in trace_create_maxlat_file()
1722 init_irq_work(&tr->fsnotify_irqwork, latency_fsnotify_workfn_irq); in trace_create_maxlat_file()
1723 tr->d_max_latency = trace_create_file("tracing_max_latency", in trace_create_maxlat_file()
1725 d_tracer, &tr->max_latency, in trace_create_maxlat_file()
1742 void latency_fsnotify(struct trace_array *tr) in latency_fsnotify() argument
1751 irq_work_queue(&tr->fsnotify_irqwork); in latency_fsnotify()
1756 #define trace_create_maxlat_file(tr, d_tracer) \ argument
1758 d_tracer, &tr->max_latency, &tracing_max_lat_fops)
1768 __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu) in __update_max_tr() argument
1770 struct array_buffer *trace_buf = &tr->array_buffer; in __update_max_tr()
1771 struct array_buffer *max_buf = &tr->max_buffer; in __update_max_tr()
1778 max_data->saved_latency = tr->max_latency; in __update_max_tr()
1799 latency_fsnotify(tr); in __update_max_tr()
1813 update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu, in update_max_tr() argument
1816 if (tr->stop_count) in update_max_tr()
1821 if (!tr->allocated_snapshot) { in update_max_tr()
1823 WARN_ON_ONCE(tr->current_trace != &nop_trace); in update_max_tr()
1827 arch_spin_lock(&tr->max_lock); in update_max_tr()
1830 if (ring_buffer_record_is_set_on(tr->array_buffer.buffer)) in update_max_tr()
1831 ring_buffer_record_on(tr->max_buffer.buffer); in update_max_tr()
1833 ring_buffer_record_off(tr->max_buffer.buffer); in update_max_tr()
1836 if (tr->cond_snapshot && !tr->cond_snapshot->update(tr, cond_data)) { in update_max_tr()
1837 arch_spin_unlock(&tr->max_lock); in update_max_tr()
1841 swap(tr->array_buffer.buffer, tr->max_buffer.buffer); in update_max_tr()
1843 __update_max_tr(tr, tsk, cpu); in update_max_tr()
1845 arch_spin_unlock(&tr->max_lock); in update_max_tr()
1857 update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu) in update_max_tr_single() argument
1861 if (tr->stop_count) in update_max_tr_single()
1865 if (!tr->allocated_snapshot) { in update_max_tr_single()
1867 WARN_ON_ONCE(tr->current_trace != &nop_trace); in update_max_tr_single()
1871 arch_spin_lock(&tr->max_lock); in update_max_tr_single()
1873 ret = ring_buffer_swap_cpu(tr->max_buffer.buffer, tr->array_buffer.buffer, cpu); in update_max_tr_single()
1882 trace_array_printk_buf(tr->max_buffer.buffer, _THIS_IP_, in update_max_tr_single()
1888 __update_max_tr(tr, tsk, cpu); in update_max_tr_single()
1889 arch_spin_unlock(&tr->max_lock); in update_max_tr_single()
1929 struct trace_array *tr = &global_trace; in run_tracer_selftest() local
1930 struct tracer *saved_tracer = tr->current_trace; in run_tracer_selftest()
1957 tracing_reset_online_cpus(&tr->array_buffer); in run_tracer_selftest()
1959 tr->current_trace = type; in run_tracer_selftest()
1965 ring_buffer_resize(tr->max_buffer.buffer, trace_buf_size, in run_tracer_selftest()
1967 tr->allocated_snapshot = true; in run_tracer_selftest()
1973 ret = type->selftest(type, tr); in run_tracer_selftest()
1975 tr->current_trace = saved_tracer; in run_tracer_selftest()
1983 tracing_reset_online_cpus(&tr->array_buffer); in run_tracer_selftest()
1987 tr->allocated_snapshot = false; in run_tracer_selftest()
1991 ring_buffer_resize(tr->max_buffer.buffer, 1, in run_tracer_selftest()
2053 static void add_tracer_options(struct trace_array *tr, struct tracer *t);
2186 struct trace_array *tr; in tracing_reset_all_online_cpus_unlocked() local
2190 list_for_each_entry(tr, &ftrace_trace_arrays, list) { in tracing_reset_all_online_cpus_unlocked()
2191 if (!tr->clear_trace) in tracing_reset_all_online_cpus_unlocked()
2193 tr->clear_trace = false; in tracing_reset_all_online_cpus_unlocked()
2194 tracing_reset_online_cpus(&tr->array_buffer); in tracing_reset_all_online_cpus_unlocked()
2196 tracing_reset_online_cpus(&tr->max_buffer); in tracing_reset_all_online_cpus_unlocked()
2335 static void tracing_start_tr(struct trace_array *tr) in tracing_start_tr() argument
2344 if (tr->flags & TRACE_ARRAY_FL_GLOBAL) in tracing_start_tr()
2347 raw_spin_lock_irqsave(&tr->start_lock, flags); in tracing_start_tr()
2349 if (--tr->stop_count) { in tracing_start_tr()
2350 if (tr->stop_count < 0) { in tracing_start_tr()
2353 tr->stop_count = 0; in tracing_start_tr()
2358 buffer = tr->array_buffer.buffer; in tracing_start_tr()
2363 raw_spin_unlock_irqrestore(&tr->start_lock, flags); in tracing_start_tr()
2400 static void tracing_stop_tr(struct trace_array *tr) in tracing_stop_tr() argument
2406 if (tr->flags & TRACE_ARRAY_FL_GLOBAL) in tracing_stop_tr()
2409 raw_spin_lock_irqsave(&tr->start_lock, flags); in tracing_stop_tr()
2410 if (tr->stop_count++) in tracing_stop_tr()
2413 buffer = tr->array_buffer.buffer; in tracing_stop_tr()
2418 raw_spin_unlock_irqrestore(&tr->start_lock, flags); in tracing_stop_tr()
2790 struct trace_array *tr = trace_file->tr; in trace_event_buffer_lock_reserve() local
2793 *current_rb = tr->array_buffer.buffer; in trace_event_buffer_lock_reserve()
2795 if (!tr->no_filter_buffering_ref && in trace_event_buffer_lock_reserve()
2952 trace_buffer_unlock_commit_regs(file->tr, fbuffer->buffer, in trace_event_buffer_commit()
2971 void trace_buffer_unlock_commit_regs(struct trace_array *tr, in trace_buffer_unlock_commit_regs() argument
2985 ftrace_trace_stack(tr, buffer, trace_ctx, regs ? 0 : STACK_SKIP, regs); in trace_buffer_unlock_commit_regs()
2986 ftrace_trace_userstack(tr, buffer, trace_ctx); in trace_buffer_unlock_commit_regs()
3000 trace_function(struct trace_array *tr, unsigned long ip, unsigned long in trace_function() argument
3004 struct trace_buffer *buffer = tr->array_buffer.buffer; in trace_function()
3111 static inline void ftrace_trace_stack(struct trace_array *tr, in ftrace_trace_stack() argument
3116 if (!(tr->trace_flags & TRACE_ITER_STACKTRACE)) in ftrace_trace_stack()
3122 void __trace_stack(struct trace_array *tr, unsigned int trace_ctx, in __trace_stack() argument
3125 struct trace_buffer *buffer = tr->array_buffer.buffer; in __trace_stack()
3168 ftrace_trace_userstack(struct trace_array *tr, in ftrace_trace_userstack() argument
3175 if (!(tr->trace_flags & TRACE_ITER_USERSTACKTRACE)) in ftrace_trace_userstack()
3214 static void ftrace_trace_userstack(struct trace_array *tr, in ftrace_trace_userstack() argument
3231 void trace_last_func_repeats(struct trace_array *tr, in trace_last_func_repeats() argument
3235 struct trace_buffer *buffer = tr->array_buffer.buffer; in trace_last_func_repeats()
3378 struct trace_array *tr = &global_trace; in trace_vbprintk() local
3405 buffer = tr->array_buffer.buffer; in trace_vbprintk()
3418 ftrace_trace_stack(tr, buffer, trace_ctx, 6, NULL); in trace_vbprintk()
3491 int trace_array_vprintk(struct trace_array *tr, in trace_array_vprintk() argument
3494 return __trace_array_vprintk(tr->array_buffer.buffer, ip, fmt, args); in trace_array_vprintk()
3518 int trace_array_printk(struct trace_array *tr, in trace_array_printk() argument
3524 if (!tr) in trace_array_printk()
3528 if (tr == &global_trace) in trace_array_printk()
3531 if (!(tr->trace_flags & TRACE_ITER_PRINTK)) in trace_array_printk()
3535 ret = trace_array_vprintk(tr, ip, fmt, ap); in trace_array_printk()
3549 int trace_array_init_printk(struct trace_array *tr) in trace_array_init_printk() argument
3551 if (!tr) in trace_array_init_printk()
3555 if (tr == &global_trace) in trace_array_init_printk()
3690 if (!iter->tr || iter->fmt == static_fmt_buf) in trace_iter_expand_format()
3949 if (!iter->tr || iter->tr->trace_flags & TRACE_ITER_HASH_PTR) in trace_event_format()
4110 struct trace_array *tr = iter->tr; in s_start() local
4123 if (unlikely(tr->current_trace && iter->trace->name != tr->current_trace->name)) in s_start()
4124 *iter->trace = *tr->current_trace; in s_start()
4217 unsigned long trace_total_entries_cpu(struct trace_array *tr, int cpu) in trace_total_entries_cpu() argument
4221 if (!tr) in trace_total_entries_cpu()
4222 tr = &global_trace; in trace_total_entries_cpu()
4224 get_total_entries_cpu(&tr->array_buffer, &total, &entries, cpu); in trace_total_entries_cpu()
4229 unsigned long trace_total_entries(struct trace_array *tr) in trace_total_entries() argument
4233 if (!tr) in trace_total_entries()
4234 tr = &global_trace; in trace_total_entries()
4236 get_total_entries(&tr->array_buffer, &total, &entries); in trace_total_entries()
4354 struct trace_array *tr = iter->tr; in test_cpu_buff_start() local
4356 if (!(tr->trace_flags & TRACE_ITER_ANNOTATE)) in test_cpu_buff_start()
4380 struct trace_array *tr = iter->tr; in print_trace_fmt() local
4382 unsigned long sym_flags = (tr->trace_flags & TRACE_ITER_SYM_MASK); in print_trace_fmt()
4392 if (tr->trace_flags & TRACE_ITER_CONTEXT_INFO) { in print_trace_fmt()
4412 struct trace_array *tr = iter->tr; in print_raw_fmt() local
4419 if (tr->trace_flags & TRACE_ITER_CONTEXT_INFO) in print_raw_fmt()
4437 struct trace_array *tr = iter->tr; in print_hex_fmt() local
4445 if (tr->trace_flags & TRACE_ITER_CONTEXT_INFO) { in print_hex_fmt()
4467 struct trace_array *tr = iter->tr; in print_bin_fmt() local
4474 if (tr->trace_flags & TRACE_ITER_CONTEXT_INFO) { in print_bin_fmt()
4523 struct trace_array *tr = iter->tr; in print_trace_line() local
4524 unsigned long trace_flags = tr->trace_flags; in print_trace_line()
4574 struct trace_array *tr = iter->tr; in trace_latency_header() local
4583 if (!(tr->trace_flags & TRACE_ITER_VERBOSE)) in trace_latency_header()
4590 struct trace_array *tr = iter->tr; in trace_default_header() local
4591 unsigned long trace_flags = tr->trace_flags; in trace_default_header()
4651 if (iter->tr->allocated_snapshot) in print_snapshot_help()
4673 if (iter->tr) { in s_show()
4732 struct trace_array *tr = inode->i_private; in __tracing_open() local
4779 *iter->trace = *tr->current_trace; in __tracing_open()
4784 iter->tr = tr; in __tracing_open()
4788 if (tr->current_trace->print_max || snapshot) in __tracing_open()
4789 iter->array_buffer = &tr->max_buffer; in __tracing_open()
4792 iter->array_buffer = &tr->array_buffer; in __tracing_open()
4807 if (trace_clocks[tr->clock_id].in_ns) in __tracing_open()
4814 if (!iter->snapshot && (tr->trace_flags & TRACE_ITER_PAUSE_ON_TRACE)) in __tracing_open()
4815 tracing_stop_tr(tr); in __tracing_open()
4875 struct trace_array *tr = inode->i_private; in tracing_open_generic_tr() local
4878 ret = tracing_check_open_get_tr(tr); in tracing_open_generic_tr()
4895 struct trace_array *tr = inode->i_private; in tracing_release() local
4901 trace_array_put(tr); in tracing_release()
4917 if (!iter->snapshot && tr->stop_count) in tracing_release()
4919 tracing_start_tr(tr); in tracing_release()
4921 __trace_array_put(tr); in tracing_release()
4938 struct trace_array *tr = inode->i_private; in tracing_release_generic_tr() local
4940 trace_array_put(tr); in tracing_release_generic_tr()
4946 struct trace_array *tr = inode->i_private; in tracing_single_release_tr() local
4948 trace_array_put(tr); in tracing_single_release_tr()
4955 struct trace_array *tr = inode->i_private; in tracing_open() local
4959 ret = tracing_check_open_get_tr(tr); in tracing_open()
4966 struct array_buffer *trace_buf = &tr->array_buffer; in tracing_open()
4969 if (tr->current_trace->print_max) in tracing_open()
4970 trace_buf = &tr->max_buffer; in tracing_open()
4983 else if (tr->trace_flags & TRACE_ITER_LATENCY_FMT) in tracing_open()
4988 trace_array_put(tr); in tracing_open()
4999 trace_ok_for_array(struct tracer *t, struct trace_array *tr) in trace_ok_for_array() argument
5001 return (tr->flags & TRACE_ARRAY_FL_GLOBAL) || t->allow_instances; in trace_ok_for_array()
5006 get_tracer_for_array(struct trace_array *tr, struct tracer *t) in get_tracer_for_array() argument
5008 while (t && !trace_ok_for_array(t, tr)) in get_tracer_for_array()
5017 struct trace_array *tr = m->private; in t_next() local
5023 t = get_tracer_for_array(tr, t->next); in t_next()
5030 struct trace_array *tr = m->private; in t_start() local
5036 t = get_tracer_for_array(tr, trace_types); in t_start()
5073 struct trace_array *tr = inode->i_private; in show_traces_open() local
5077 ret = tracing_check_open_get_tr(tr); in show_traces_open()
5083 trace_array_put(tr); in show_traces_open()
5088 m->private = tr; in show_traces_open()
5095 struct trace_array *tr = inode->i_private; in show_traces_release() local
5097 trace_array_put(tr); in show_traces_release()
5139 struct trace_array *tr = file_inode(filp)->i_private; in tracing_cpumask_read() local
5144 cpumask_pr_args(tr->tracing_cpumask)) + 1; in tracing_cpumask_read()
5150 cpumask_pr_args(tr->tracing_cpumask)); in tracing_cpumask_read()
5163 int tracing_set_cpumask(struct trace_array *tr, in tracing_set_cpumask() argument
5168 if (!tr) in tracing_set_cpumask()
5172 arch_spin_lock(&tr->max_lock); in tracing_set_cpumask()
5178 if (cpumask_test_cpu(cpu, tr->tracing_cpumask) && in tracing_set_cpumask()
5180 atomic_inc(&per_cpu_ptr(tr->array_buffer.data, cpu)->disabled); in tracing_set_cpumask()
5181 ring_buffer_record_disable_cpu(tr->array_buffer.buffer, cpu); in tracing_set_cpumask()
5183 if (!cpumask_test_cpu(cpu, tr->tracing_cpumask) && in tracing_set_cpumask()
5185 atomic_dec(&per_cpu_ptr(tr->array_buffer.data, cpu)->disabled); in tracing_set_cpumask()
5186 ring_buffer_record_enable_cpu(tr->array_buffer.buffer, cpu); in tracing_set_cpumask()
5189 arch_spin_unlock(&tr->max_lock); in tracing_set_cpumask()
5192 cpumask_copy(tr->tracing_cpumask, tracing_cpumask_new); in tracing_set_cpumask()
5201 struct trace_array *tr = file_inode(filp)->i_private; in tracing_cpumask_write() local
5212 err = tracing_set_cpumask(tr, tracing_cpumask_new); in tracing_cpumask_write()
5237 struct trace_array *tr = m->private; in tracing_trace_options_show() local
5242 tracer_flags = tr->current_trace->flags->val; in tracing_trace_options_show()
5243 trace_opts = tr->current_trace->flags->opts; in tracing_trace_options_show()
5246 if (tr->trace_flags & (1 << i)) in tracing_trace_options_show()
5263 static int __set_tracer_option(struct trace_array *tr, in __set_tracer_option() argument
5270 ret = trace->set_flag(tr, tracer_flags->val, opts->bit, !neg); in __set_tracer_option()
5282 static int set_tracer_option(struct trace_array *tr, char *cmp, int neg) in set_tracer_option() argument
5284 struct tracer *trace = tr->current_trace; in set_tracer_option()
5293 return __set_tracer_option(tr, trace->flags, opts, neg); in set_tracer_option()
5308 int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled) in set_tracer_flag() argument
5317 if (!!(tr->trace_flags & mask) == !!enabled) in set_tracer_flag()
5321 if (tr->current_trace->flag_changed) in set_tracer_flag()
5322 if (tr->current_trace->flag_changed(tr, mask, !!enabled)) in set_tracer_flag()
5326 tr->trace_flags |= mask; in set_tracer_flag()
5328 tr->trace_flags &= ~mask; in set_tracer_flag()
5348 tr->trace_flags &= ~TRACE_ITER_RECORD_TGID; in set_tracer_flag()
5356 trace_event_follow_fork(tr, enabled); in set_tracer_flag()
5359 ftrace_pid_follow_fork(tr, enabled); in set_tracer_flag()
5362 ring_buffer_change_overwrite(tr->array_buffer.buffer, enabled); in set_tracer_flag()
5364 ring_buffer_change_overwrite(tr->max_buffer.buffer, enabled); in set_tracer_flag()
5376 int trace_set_options(struct trace_array *tr, char *option) in trace_set_options() argument
5398 ret = set_tracer_option(tr, cmp, neg); in trace_set_options()
5400 ret = set_tracer_flag(tr, 1 << ret, !neg); in trace_set_options()
5440 struct trace_array *tr = m->private; in tracing_trace_options_write() local
5452 ret = trace_set_options(tr, buf); in tracing_trace_options_write()
5463 struct trace_array *tr = inode->i_private; in tracing_trace_options_open() local
5466 ret = tracing_check_open_get_tr(tr); in tracing_trace_options_open()
5472 trace_array_put(tr); in tracing_trace_options_open()
6169 struct trace_array *tr = filp->private_data; in tracing_set_trace_read() local
6174 r = sprintf(buf, "%s\n", tr->current_trace->name); in tracing_set_trace_read()
6180 int tracer_init(struct tracer *t, struct trace_array *tr) in tracer_init() argument
6182 tracing_reset_online_cpus(&tr->array_buffer); in tracer_init()
6183 return t->init(tr); in tracer_init()
6222 static int __tracing_resize_ring_buffer(struct trace_array *tr, in __tracing_resize_ring_buffer() argument
6235 if (!tr->array_buffer.buffer) in __tracing_resize_ring_buffer()
6238 ret = ring_buffer_resize(tr->array_buffer.buffer, size, cpu); in __tracing_resize_ring_buffer()
6243 if (!(tr->flags & TRACE_ARRAY_FL_GLOBAL) || in __tracing_resize_ring_buffer()
6244 !tr->current_trace->use_max_tr) in __tracing_resize_ring_buffer()
6247 ret = ring_buffer_resize(tr->max_buffer.buffer, size, cpu); in __tracing_resize_ring_buffer()
6249 int r = resize_buffer_duplicate_size(&tr->array_buffer, in __tracing_resize_ring_buffer()
6250 &tr->array_buffer, cpu); in __tracing_resize_ring_buffer()
6273 set_buffer_entries(&tr->max_buffer, size); in __tracing_resize_ring_buffer()
6275 per_cpu_ptr(tr->max_buffer.data, cpu)->entries = size; in __tracing_resize_ring_buffer()
6281 set_buffer_entries(&tr->array_buffer, size); in __tracing_resize_ring_buffer()
6283 per_cpu_ptr(tr->array_buffer.data, cpu)->entries = size; in __tracing_resize_ring_buffer()
6288 ssize_t tracing_resize_ring_buffer(struct trace_array *tr, in tracing_resize_ring_buffer() argument
6303 ret = __tracing_resize_ring_buffer(tr, size, cpu_id); in tracing_resize_ring_buffer()
6340 create_trace_option_files(struct trace_array *tr, struct tracer *tracer);
6346 static void tracing_set_nop(struct trace_array *tr) in tracing_set_nop() argument
6348 if (tr->current_trace == &nop_trace) in tracing_set_nop()
6351 tr->current_trace->enabled--; in tracing_set_nop()
6353 if (tr->current_trace->reset) in tracing_set_nop()
6354 tr->current_trace->reset(tr); in tracing_set_nop()
6356 tr->current_trace = &nop_trace; in tracing_set_nop()
6361 static void add_tracer_options(struct trace_array *tr, struct tracer *t) in add_tracer_options() argument
6364 if (!tr->dir) in add_tracer_options()
6371 create_trace_option_files(tr, t); in add_tracer_options()
6374 int tracing_set_tracer(struct trace_array *tr, const char *buf) in tracing_set_tracer() argument
6385 ret = __tracing_resize_ring_buffer(tr, trace_buf_size, in tracing_set_tracer()
6400 if (t == tr->current_trace) in tracing_set_tracer()
6406 arch_spin_lock(&tr->max_lock); in tracing_set_tracer()
6407 if (tr->cond_snapshot) in tracing_set_tracer()
6409 arch_spin_unlock(&tr->max_lock); in tracing_set_tracer()
6423 if (!trace_ok_for_array(t, tr)) { in tracing_set_tracer()
6429 if (tr->trace_ref) { in tracing_set_tracer()
6436 tr->current_trace->enabled--; in tracing_set_tracer()
6438 if (tr->current_trace->reset) in tracing_set_tracer()
6439 tr->current_trace->reset(tr); in tracing_set_tracer()
6442 had_max_tr = tr->current_trace->use_max_tr; in tracing_set_tracer()
6445 tr->current_trace = &nop_trace; in tracing_set_tracer()
6456 free_snapshot(tr); in tracing_set_tracer()
6459 if (t->use_max_tr && !tr->allocated_snapshot) { in tracing_set_tracer()
6460 ret = tracing_alloc_snapshot_instance(tr); in tracing_set_tracer()
6465 tr->current_trace = &nop_trace; in tracing_set_tracer()
6469 ret = tracer_init(t, tr); in tracing_set_tracer()
6474 tr->current_trace = t; in tracing_set_tracer()
6475 tr->current_trace->enabled++; in tracing_set_tracer()
6476 trace_branch_enable(tr); in tracing_set_tracer()
6487 struct trace_array *tr = filp->private_data; in tracing_set_trace_write() local
6505 err = tracing_set_tracer(tr, name); in tracing_set_trace_write()
6555 struct trace_array *tr = filp->private_data; in tracing_thresh_write() local
6563 if (tr->current_trace->update_thresh) { in tracing_thresh_write()
6564 ret = tr->current_trace->update_thresh(tr); in tracing_thresh_write()
6596 struct trace_array *tr = inode->i_private; in tracing_open_pipe() local
6600 ret = tracing_check_open_get_tr(tr); in tracing_open_pipe()
6610 __trace_array_put(tr); in tracing_open_pipe()
6615 iter->trace = tr->current_trace; in tracing_open_pipe()
6625 if (tr->trace_flags & TRACE_ITER_LATENCY_FMT) in tracing_open_pipe()
6629 if (trace_clocks[tr->clock_id].in_ns) in tracing_open_pipe()
6632 iter->tr = tr; in tracing_open_pipe()
6633 iter->array_buffer = &tr->array_buffer; in tracing_open_pipe()
6643 tr->trace_ref++; in tracing_open_pipe()
6650 __trace_array_put(tr); in tracing_open_pipe()
6658 struct trace_array *tr = inode->i_private; in tracing_release_pipe() local
6662 tr->trace_ref--; in tracing_release_pipe()
6674 trace_array_put(tr); in tracing_release_pipe()
6682 struct trace_array *tr = iter->tr; in trace_poll() local
6688 if (tr->trace_flags & TRACE_ITER_BLOCK) in trace_poll()
6695 filp, poll_table, iter->tr->buffer_percent); in trace_poll()
6727 if (!tracer_tracing_is_on(iter->tr) && iter->pos) in tracing_wait_pipe()
6996 struct trace_array *tr = inode->i_private; in tracing_entries_read() local
7014 size = per_cpu_ptr(tr->array_buffer.data, cpu)->entries; in tracing_entries_read()
7015 if (size != per_cpu_ptr(tr->array_buffer.data, cpu)->entries) { in tracing_entries_read()
7031 r = sprintf(buf, "%lu\n", per_cpu_ptr(tr->array_buffer.data, cpu)->entries >> 10); in tracing_entries_read()
7044 struct trace_array *tr = inode->i_private; in tracing_entries_write() local
7058 ret = tracing_resize_ring_buffer(tr, val, tracing_get_cpu(inode)); in tracing_entries_write()
7071 struct trace_array *tr = filp->private_data; in tracing_total_entries_read() local
7078 size += per_cpu_ptr(tr->array_buffer.data, cpu)->entries >> 10; in tracing_total_entries_read()
7108 struct trace_array *tr = inode->i_private; in tracing_free_buffer_release() local
7111 if (tr->trace_flags & TRACE_ITER_STOP_ON_FREE) in tracing_free_buffer_release()
7112 tracer_tracing_off(tr); in tracing_free_buffer_release()
7114 tracing_resize_ring_buffer(tr, 0, RING_BUFFER_ALL_CPUS); in tracing_free_buffer_release()
7116 trace_array_put(tr); in tracing_free_buffer_release()
7125 struct trace_array *tr = filp->private_data; in tracing_mark_write() local
7141 if (!(tr->trace_flags & TRACE_ITER_MARKERS)) in tracing_mark_write()
7155 buffer = tr->array_buffer.buffer; in tracing_mark_write()
7173 if (tr->trace_marker_file && !list_empty(&tr->trace_marker_file->triggers)) { in tracing_mark_write()
7176 tt = event_triggers_call(tr->trace_marker_file, buffer, entry, event); in tracing_mark_write()
7190 event_triggers_post_call(tr->trace_marker_file, tt); in tracing_mark_write()
7202 struct trace_array *tr = filp->private_data; in tracing_mark_raw_write() local
7215 if (!(tr->trace_flags & TRACE_ITER_MARKERS)) in tracing_mark_raw_write()
7231 buffer = tr->array_buffer.buffer; in tracing_mark_raw_write()
7255 struct trace_array *tr = m->private; in tracing_clock_show() local
7261 i == tr->clock_id ? "[" : "", trace_clocks[i].name, in tracing_clock_show()
7262 i == tr->clock_id ? "]" : ""); in tracing_clock_show()
7268 int tracing_set_clock(struct trace_array *tr, const char *clockstr) in tracing_set_clock() argument
7281 tr->clock_id = i; in tracing_set_clock()
7283 ring_buffer_set_clock(tr->array_buffer.buffer, trace_clocks[i].func); in tracing_set_clock()
7289 tracing_reset_online_cpus(&tr->array_buffer); in tracing_set_clock()
7292 if (tr->max_buffer.buffer) in tracing_set_clock()
7293 ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func); in tracing_set_clock()
7294 tracing_reset_online_cpus(&tr->max_buffer); in tracing_set_clock()
7306 struct trace_array *tr = m->private; in tracing_clock_write() local
7321 ret = tracing_set_clock(tr, clockstr); in tracing_clock_write()
7332 struct trace_array *tr = inode->i_private; in tracing_clock_open() local
7335 ret = tracing_check_open_get_tr(tr); in tracing_clock_open()
7341 trace_array_put(tr); in tracing_clock_open()
7348 struct trace_array *tr = m->private; in tracing_time_stamp_mode_show() local
7352 if (ring_buffer_time_stamp_abs(tr->array_buffer.buffer)) in tracing_time_stamp_mode_show()
7364 struct trace_array *tr = inode->i_private; in tracing_time_stamp_mode_open() local
7367 ret = tracing_check_open_get_tr(tr); in tracing_time_stamp_mode_open()
7373 trace_array_put(tr); in tracing_time_stamp_mode_open()
7389 int tracing_set_filter_buffering(struct trace_array *tr, bool set) in tracing_set_filter_buffering() argument
7395 if (set && tr->no_filter_buffering_ref++) in tracing_set_filter_buffering()
7399 if (WARN_ON_ONCE(!tr->no_filter_buffering_ref)) { in tracing_set_filter_buffering()
7404 --tr->no_filter_buffering_ref; in tracing_set_filter_buffering()
7422 struct trace_array *tr = inode->i_private; in tracing_snapshot_open() local
7427 ret = tracing_check_open_get_tr(tr); in tracing_snapshot_open()
7448 iter->tr = tr; in tracing_snapshot_open()
7449 iter->array_buffer = &tr->max_buffer; in tracing_snapshot_open()
7456 trace_array_put(tr); in tracing_snapshot_open()
7467 struct trace_array *tr = iter->tr; in tracing_snapshot_write() local
7481 if (tr->current_trace->use_max_tr) { in tracing_snapshot_write()
7487 arch_spin_lock(&tr->max_lock); in tracing_snapshot_write()
7488 if (tr->cond_snapshot) in tracing_snapshot_write()
7490 arch_spin_unlock(&tr->max_lock); in tracing_snapshot_write()
7501 if (tr->allocated_snapshot) in tracing_snapshot_write()
7502 free_snapshot(tr); in tracing_snapshot_write()
7512 if (tr->allocated_snapshot) in tracing_snapshot_write()
7513 ret = resize_buffer_duplicate_size(&tr->max_buffer, in tracing_snapshot_write()
7514 &tr->array_buffer, iter->cpu_file); in tracing_snapshot_write()
7516 ret = tracing_alloc_snapshot_instance(tr); in tracing_snapshot_write()
7522 update_max_tr(tr, current, smp_processor_id(), NULL); in tracing_snapshot_write()
7524 update_max_tr_single(tr, current, iter->cpu_file); in tracing_snapshot_write()
7528 if (tr->allocated_snapshot) { in tracing_snapshot_write()
7530 tracing_reset_online_cpus(&tr->max_buffer); in tracing_snapshot_write()
7532 tracing_reset_cpu(&tr->max_buffer, iter->cpu_file); in tracing_snapshot_write()
7589 info->iter.array_buffer = &info->iter.tr->max_buffer; in snapshot_raw_open()
7825 static struct tracing_log_err *get_tracing_log_err(struct trace_array *tr, in get_tracing_log_err() argument
7831 if (tr->n_err_log_entries < TRACING_LOG_ERRS_MAX) { in get_tracing_log_err()
7834 tr->n_err_log_entries++; in get_tracing_log_err()
7841 err = list_first_entry(&tr->err_log, struct tracing_log_err, list); in get_tracing_log_err()
7902 void tracing_log_err(struct trace_array *tr, in tracing_log_err() argument
7909 if (!tr) in tracing_log_err()
7910 tr = &global_trace; in tracing_log_err()
7915 err = get_tracing_log_err(tr, len); in tracing_log_err()
7929 list_add_tail(&err->list, &tr->err_log); in tracing_log_err()
7933 static void clear_tracing_err_log(struct trace_array *tr) in clear_tracing_err_log() argument
7938 list_for_each_entry_safe(err, next, &tr->err_log, list) { in clear_tracing_err_log()
7943 tr->n_err_log_entries = 0; in clear_tracing_err_log()
7949 struct trace_array *tr = m->private; in tracing_err_log_seq_start() local
7953 return seq_list_start(&tr->err_log, *pos); in tracing_err_log_seq_start()
7958 struct trace_array *tr = m->private; in tracing_err_log_seq_next() local
7960 return seq_list_next(v, &tr->err_log, pos); in tracing_err_log_seq_next()
8007 struct trace_array *tr = inode->i_private; in tracing_err_log_open() local
8010 ret = tracing_check_open_get_tr(tr); in tracing_err_log_open()
8016 clear_tracing_err_log(tr); in tracing_err_log_open()
8022 m->private = tr; in tracing_err_log_open()
8024 trace_array_put(tr); in tracing_err_log_open()
8039 struct trace_array *tr = inode->i_private; in tracing_err_log_release() local
8041 trace_array_put(tr); in tracing_err_log_release()
8059 struct trace_array *tr = inode->i_private; in tracing_buffers_open() local
8063 ret = tracing_check_open_get_tr(tr); in tracing_buffers_open()
8069 trace_array_put(tr); in tracing_buffers_open()
8075 info->iter.tr = tr; in tracing_buffers_open()
8077 info->iter.trace = tr->current_trace; in tracing_buffers_open()
8078 info->iter.array_buffer = &tr->array_buffer; in tracing_buffers_open()
8085 tr->trace_ref++; in tracing_buffers_open()
8091 trace_array_put(tr); in tracing_buffers_open()
8118 if (iter->snapshot && iter->tr->current_trace->use_max_tr) in tracing_buffers_read()
8186 iter->tr->trace_ref--; in tracing_buffers_release()
8188 __trace_array_put(iter->tr); in tracing_buffers_release()
8282 if (iter->snapshot && iter->tr->current_trace->use_max_tr) in tracing_buffers_splice_read()
8360 ret = wait_on_pipe(iter, iter->tr->buffer_percent); in tracing_buffers_splice_read()
8365 if (!tracer_tracing_is_on(iter->tr)) in tracing_buffers_splice_read()
8419 struct trace_array *tr = inode->i_private; in tracing_stats_read() local
8420 struct array_buffer *trace_buf = &tr->array_buffer; in tracing_stats_read()
8445 if (trace_clocks[tr->clock_id].in_ns) { in tracing_stats_read()
8520 struct trace_array *tr, struct ftrace_probe_ops *ops, in ftrace_snapshot() argument
8523 tracing_snapshot_instance(tr); in ftrace_snapshot()
8528 struct trace_array *tr, struct ftrace_probe_ops *ops, in ftrace_count_snapshot() argument
8545 tracing_snapshot_instance(tr); in ftrace_count_snapshot()
8571 ftrace_snapshot_init(struct ftrace_probe_ops *ops, struct trace_array *tr, in ftrace_snapshot_init() argument
8587 ftrace_snapshot_free(struct ftrace_probe_ops *ops, struct trace_array *tr, in ftrace_snapshot_free() argument
8615 ftrace_trace_snapshot_callback(struct trace_array *tr, struct ftrace_hash *hash, in ftrace_trace_snapshot_callback() argument
8623 if (!tr) in ftrace_trace_snapshot_callback()
8633 return unregister_ftrace_function_probe_func(glob+1, tr, ops); in ftrace_trace_snapshot_callback()
8652 ret = tracing_alloc_snapshot_instance(tr); in ftrace_trace_snapshot_callback()
8656 ret = register_ftrace_function_probe(glob, tr, ops, count); in ftrace_trace_snapshot_callback()
8675 static struct dentry *tracing_get_dentry(struct trace_array *tr) in tracing_get_dentry() argument
8677 if (WARN_ON(!tr->dir)) in tracing_get_dentry()
8681 if (tr->flags & TRACE_ARRAY_FL_GLOBAL) in tracing_get_dentry()
8685 return tr->dir; in tracing_get_dentry()
8688 static struct dentry *tracing_dentry_percpu(struct trace_array *tr, int cpu) in tracing_dentry_percpu() argument
8692 if (tr->percpu_dir) in tracing_dentry_percpu()
8693 return tr->percpu_dir; in tracing_dentry_percpu()
8695 d_tracer = tracing_get_dentry(tr); in tracing_dentry_percpu()
8699 tr->percpu_dir = tracefs_create_dir("per_cpu", d_tracer); in tracing_dentry_percpu()
8701 MEM_FAIL(!tr->percpu_dir, in tracing_dentry_percpu()
8704 return tr->percpu_dir; in tracing_dentry_percpu()
8719 tracing_init_tracefs_percpu(struct trace_array *tr, long cpu) in tracing_init_tracefs_percpu() argument
8721 struct dentry *d_percpu = tracing_dentry_percpu(tr, cpu); in tracing_init_tracefs_percpu()
8737 tr, cpu, &tracing_pipe_fops); in tracing_init_tracefs_percpu()
8741 tr, cpu, &tracing_fops); in tracing_init_tracefs_percpu()
8744 tr, cpu, &tracing_buffers_fops); in tracing_init_tracefs_percpu()
8747 tr, cpu, &tracing_stats_fops); in tracing_init_tracefs_percpu()
8750 tr, cpu, &tracing_entries_fops); in tracing_init_tracefs_percpu()
8754 tr, cpu, &snapshot_fops); in tracing_init_tracefs_percpu()
8757 tr, cpu, &snapshot_raw_fops); in tracing_init_tracefs_percpu()
8798 ret = __set_tracer_option(topt->tr, topt->flags, in trace_options_write()
8856 struct trace_array *tr; in trace_options_core_read() local
8860 get_tr_index(tr_index, &tr, &index); in trace_options_core_read()
8862 if (tr->trace_flags & (1 << index)) in trace_options_core_read()
8875 struct trace_array *tr; in trace_options_core_write() local
8880 get_tr_index(tr_index, &tr, &index); in trace_options_core_write()
8891 ret = set_tracer_flag(tr, 1 << index, val); in trace_options_core_write()
8926 static struct dentry *trace_options_init_dentry(struct trace_array *tr) in trace_options_init_dentry() argument
8930 if (tr->options) in trace_options_init_dentry()
8931 return tr->options; in trace_options_init_dentry()
8933 d_tracer = tracing_get_dentry(tr); in trace_options_init_dentry()
8937 tr->options = tracefs_create_dir("options", d_tracer); in trace_options_init_dentry()
8938 if (!tr->options) { in trace_options_init_dentry()
8943 return tr->options; in trace_options_init_dentry()
8947 create_trace_option_file(struct trace_array *tr, in create_trace_option_file() argument
8954 t_options = trace_options_init_dentry(tr); in create_trace_option_file()
8960 topt->tr = tr; in create_trace_option_file()
8968 create_trace_option_files(struct trace_array *tr, struct tracer *tracer) in create_trace_option_files() argument
8989 if (!trace_ok_for_array(tracer, tr)) in create_trace_option_files()
8992 for (i = 0; i < tr->nr_topts; i++) { in create_trace_option_files()
8994 if (WARN_ON_ONCE(tr->topts[i].tracer->flags == tracer->flags)) in create_trace_option_files()
9007 tr_topts = krealloc(tr->topts, sizeof(*tr->topts) * (tr->nr_topts + 1), in create_trace_option_files()
9014 tr->topts = tr_topts; in create_trace_option_files()
9015 tr->topts[tr->nr_topts].tracer = tracer; in create_trace_option_files()
9016 tr->topts[tr->nr_topts].topts = topts; in create_trace_option_files()
9017 tr->nr_topts++; in create_trace_option_files()
9020 create_trace_option_file(tr, &topts[cnt], flags, in create_trace_option_files()
9029 create_trace_option_core_file(struct trace_array *tr, in create_trace_option_core_file() argument
9034 t_options = trace_options_init_dentry(tr); in create_trace_option_core_file()
9039 (void *)&tr->trace_flags_index[index], in create_trace_option_core_file()
9043 static void create_trace_options_dir(struct trace_array *tr) in create_trace_options_dir() argument
9046 bool top_level = tr == &global_trace; in create_trace_options_dir()
9049 t_options = trace_options_init_dentry(tr); in create_trace_options_dir()
9056 create_trace_option_core_file(tr, trace_options[i], i); in create_trace_options_dir()
9064 struct trace_array *tr = filp->private_data; in rb_simple_read() local
9068 r = tracer_tracing_is_on(tr); in rb_simple_read()
9078 struct trace_array *tr = filp->private_data; in rb_simple_write() local
9079 struct trace_buffer *buffer = tr->array_buffer.buffer; in rb_simple_write()
9089 if (!!val == tracer_tracing_is_on(tr)) { in rb_simple_write()
9092 tracer_tracing_on(tr); in rb_simple_write()
9093 if (tr->current_trace->start) in rb_simple_write()
9094 tr->current_trace->start(tr); in rb_simple_write()
9096 tracer_tracing_off(tr); in rb_simple_write()
9097 if (tr->current_trace->stop) in rb_simple_write()
9098 tr->current_trace->stop(tr); in rb_simple_write()
9122 struct trace_array *tr = filp->private_data; in buffer_percent_read() local
9126 r = tr->buffer_percent; in buffer_percent_read()
9136 struct trace_array *tr = filp->private_data; in buffer_percent_write() local
9150 tr->buffer_percent = val; in buffer_percent_write()
9168 init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer);
9171 allocate_trace_buffer(struct trace_array *tr, struct array_buffer *buf, int size) in allocate_trace_buffer() argument
9175 rb_flags = tr->trace_flags & TRACE_ITER_OVERWRITE ? RB_FL_OVERWRITE : 0; in allocate_trace_buffer()
9177 buf->tr = tr; in allocate_trace_buffer()
9191 set_buffer_entries(&tr->array_buffer, in allocate_trace_buffer()
9192 ring_buffer_size(tr->array_buffer.buffer, 0)); in allocate_trace_buffer()
9207 static int allocate_trace_buffers(struct trace_array *tr, int size) in allocate_trace_buffers() argument
9211 ret = allocate_trace_buffer(tr, &tr->array_buffer, size); in allocate_trace_buffers()
9216 ret = allocate_trace_buffer(tr, &tr->max_buffer, in allocate_trace_buffers()
9219 free_trace_buffer(&tr->array_buffer); in allocate_trace_buffers()
9222 tr->allocated_snapshot = allocate_snapshot; in allocate_trace_buffers()
9234 static void free_trace_buffers(struct trace_array *tr) in free_trace_buffers() argument
9236 if (!tr) in free_trace_buffers()
9239 free_trace_buffer(&tr->array_buffer); in free_trace_buffers()
9242 free_trace_buffer(&tr->max_buffer); in free_trace_buffers()
9246 static void init_trace_flags_index(struct trace_array *tr) in init_trace_flags_index() argument
9252 tr->trace_flags_index[i] = i; in init_trace_flags_index()
9255 static void __update_tracer_options(struct trace_array *tr) in __update_tracer_options() argument
9260 add_tracer_options(tr, t); in __update_tracer_options()
9263 static void update_tracer_options(struct trace_array *tr) in update_tracer_options() argument
9267 __update_tracer_options(tr); in update_tracer_options()
9274 struct trace_array *tr, *found = NULL; in trace_array_find() local
9276 list_for_each_entry(tr, &ftrace_trace_arrays, list) { in trace_array_find()
9277 if (tr->name && strcmp(tr->name, instance) == 0) { in trace_array_find()
9278 found = tr; in trace_array_find()
9288 struct trace_array *tr; in trace_array_find_get() local
9291 tr = trace_array_find(instance); in trace_array_find_get()
9292 if (tr) in trace_array_find_get()
9293 tr->ref++; in trace_array_find_get()
9296 return tr; in trace_array_find_get()
9299 static int trace_array_create_dir(struct trace_array *tr) in trace_array_create_dir() argument
9303 tr->dir = tracefs_create_dir(tr->name, trace_instance_dir); in trace_array_create_dir()
9304 if (!tr->dir) in trace_array_create_dir()
9307 ret = event_trace_add_tracer(tr->dir, tr); in trace_array_create_dir()
9309 tracefs_remove(tr->dir); in trace_array_create_dir()
9313 init_tracer_tracefs(tr, tr->dir); in trace_array_create_dir()
9314 __update_tracer_options(tr); in trace_array_create_dir()
9321 struct trace_array *tr; in trace_array_create() local
9325 tr = kzalloc(sizeof(*tr), GFP_KERNEL); in trace_array_create()
9326 if (!tr) in trace_array_create()
9329 tr->name = kstrdup(name, GFP_KERNEL); in trace_array_create()
9330 if (!tr->name) in trace_array_create()
9333 if (!alloc_cpumask_var(&tr->tracing_cpumask, GFP_KERNEL)) in trace_array_create()
9336 tr->trace_flags = global_trace.trace_flags & ~ZEROED_TRACE_FLAGS; in trace_array_create()
9338 cpumask_copy(tr->tracing_cpumask, cpu_all_mask); in trace_array_create()
9340 raw_spin_lock_init(&tr->start_lock); in trace_array_create()
9342 tr->max_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; in trace_array_create()
9344 tr->current_trace = &nop_trace; in trace_array_create()
9346 INIT_LIST_HEAD(&tr->systems); in trace_array_create()
9347 INIT_LIST_HEAD(&tr->events); in trace_array_create()
9348 INIT_LIST_HEAD(&tr->hist_vars); in trace_array_create()
9349 INIT_LIST_HEAD(&tr->err_log); in trace_array_create()
9351 if (allocate_trace_buffers(tr, trace_buf_size) < 0) in trace_array_create()
9354 if (ftrace_allocate_ftrace_ops(tr) < 0) in trace_array_create()
9357 ftrace_init_trace_array(tr); in trace_array_create()
9359 init_trace_flags_index(tr); in trace_array_create()
9362 ret = trace_array_create_dir(tr); in trace_array_create()
9366 __trace_early_add_events(tr); in trace_array_create()
9368 list_add(&tr->list, &ftrace_trace_arrays); in trace_array_create()
9370 tr->ref++; in trace_array_create()
9372 return tr; in trace_array_create()
9375 ftrace_free_ftrace_ops(tr); in trace_array_create()
9376 free_trace_buffers(tr); in trace_array_create()
9377 free_cpumask_var(tr->tracing_cpumask); in trace_array_create()
9378 kfree(tr->name); in trace_array_create()
9379 kfree(tr); in trace_array_create()
9386 struct trace_array *tr; in instance_mkdir() local
9396 tr = trace_array_create(name); in instance_mkdir()
9398 ret = PTR_ERR_OR_ZERO(tr); in instance_mkdir()
9424 struct trace_array *tr; in trace_array_get_by_name() local
9429 list_for_each_entry(tr, &ftrace_trace_arrays, list) { in trace_array_get_by_name()
9430 if (tr->name && strcmp(tr->name, name) == 0) in trace_array_get_by_name()
9434 tr = trace_array_create(name); in trace_array_get_by_name()
9436 if (IS_ERR(tr)) in trace_array_get_by_name()
9437 tr = NULL; in trace_array_get_by_name()
9439 if (tr) in trace_array_get_by_name()
9440 tr->ref++; in trace_array_get_by_name()
9444 return tr; in trace_array_get_by_name()
9448 static int __remove_instance(struct trace_array *tr) in __remove_instance() argument
9453 if (tr->ref > 1 || (tr->current_trace && tr->trace_ref)) in __remove_instance()
9456 list_del(&tr->list); in __remove_instance()
9461 set_tracer_flag(tr, 1 << i, 0); in __remove_instance()
9464 tracing_set_nop(tr); in __remove_instance()
9465 clear_ftrace_function_probes(tr); in __remove_instance()
9466 event_trace_del_tracer(tr); in __remove_instance()
9467 ftrace_clear_pids(tr); in __remove_instance()
9468 ftrace_destroy_function_files(tr); in __remove_instance()
9469 tracefs_remove(tr->dir); in __remove_instance()
9470 free_percpu(tr->last_func_repeats); in __remove_instance()
9471 free_trace_buffers(tr); in __remove_instance()
9473 for (i = 0; i < tr->nr_topts; i++) { in __remove_instance()
9474 kfree(tr->topts[i].topts); in __remove_instance()
9476 kfree(tr->topts); in __remove_instance()
9478 free_cpumask_var(tr->tracing_cpumask); in __remove_instance()
9479 kfree(tr->name); in __remove_instance()
9480 kfree(tr); in __remove_instance()
9487 struct trace_array *tr; in trace_array_destroy() local
9499 list_for_each_entry(tr, &ftrace_trace_arrays, list) { in trace_array_destroy()
9500 if (tr == this_tr) { in trace_array_destroy()
9501 ret = __remove_instance(tr); in trace_array_destroy()
9515 struct trace_array *tr; in instance_rmdir() local
9522 tr = trace_array_find(name); in instance_rmdir()
9523 if (tr) in instance_rmdir()
9524 ret = __remove_instance(tr); in instance_rmdir()
9534 struct trace_array *tr; in create_trace_instances() local
9545 list_for_each_entry(tr, &ftrace_trace_arrays, list) { in create_trace_instances()
9546 if (!tr->name) in create_trace_instances()
9548 if (MEM_FAIL(trace_array_create_dir(tr) < 0, in create_trace_instances()
9558 init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer) in init_tracer_tracefs() argument
9564 tr, &show_traces_fops); in init_tracer_tracefs()
9567 tr, &set_tracer_fops); in init_tracer_tracefs()
9570 tr, &tracing_cpumask_fops); in init_tracer_tracefs()
9573 tr, &tracing_iter_fops); in init_tracer_tracefs()
9576 tr, &tracing_fops); in init_tracer_tracefs()
9579 tr, &tracing_pipe_fops); in init_tracer_tracefs()
9582 tr, &tracing_entries_fops); in init_tracer_tracefs()
9585 tr, &tracing_total_entries_fops); in init_tracer_tracefs()
9588 tr, &tracing_free_buffer_fops); in init_tracer_tracefs()
9591 tr, &tracing_mark_fops); in init_tracer_tracefs()
9593 file = __find_event_file(tr, "ftrace", "print"); in init_tracer_tracefs()
9597 tr->trace_marker_file = file; in init_tracer_tracefs()
9600 tr, &tracing_mark_raw_fops); in init_tracer_tracefs()
9602 trace_create_file("trace_clock", TRACE_MODE_WRITE, d_tracer, tr, in init_tracer_tracefs()
9606 tr, &rb_simple_fops); in init_tracer_tracefs()
9608 trace_create_file("timestamp_mode", TRACE_MODE_READ, d_tracer, tr, in init_tracer_tracefs()
9611 tr->buffer_percent = 50; in init_tracer_tracefs()
9614 tr, &buffer_percent_fops); in init_tracer_tracefs()
9616 create_trace_options_dir(tr); in init_tracer_tracefs()
9619 trace_create_maxlat_file(tr, d_tracer); in init_tracer_tracefs()
9622 if (ftrace_create_function_files(tr, d_tracer)) in init_tracer_tracefs()
9627 tr, &snapshot_fops); in init_tracer_tracefs()
9631 tr, &tracing_err_log_fops); in init_tracer_tracefs()
9634 tracing_init_tracefs_percpu(tr, cpu); in init_tracer_tracefs()
9636 ftrace_init_tracefs(tr, d_tracer); in init_tracer_tracefs()
9670 struct trace_array *tr = &global_trace; in tracing_init_dentry() local
9678 if (tr->dir) in tracing_init_dentry()
9690 tr->dir = debugfs_create_automount("tracing", NULL, in tracing_init_dentry()
9946 iter->tr = &global_trace; in trace_init_global_iter()
9947 iter->trace = iter->tr->current_trace; in trace_init_global_iter()
9959 if (trace_clocks[iter->tr->clock_id].in_ns) in trace_init_global_iter()
9974 struct trace_array *tr = &global_trace; in ftrace_dump() local
10004 old_userobj = tr->trace_flags & TRACE_ITER_SYM_USEROBJ; in ftrace_dump()
10007 tr->trace_flags &= ~TRACE_ITER_SYM_USEROBJ; in ftrace_dump()
10066 tr->trace_flags |= old_userobj; in ftrace_dump()