mirror of https://gitee.com/openkylin/linux.git
This contains fixes, optimizations and some clean ups
Some of the fixes need to go back to 3.10. They are minor, and deal mostly with incorrect ref counting in accessing event files. There was a couple of optimizations that should have perf perform a bit better when accessing trace events. And some various clean ups. Some of the clean ups are necessary to help in a fix to a theoretical race between opening a event file and deleting that event. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAABAgAGBQJR7TuSAAoJEOdOSU1xswtMFsEIALOQWth+jUEmd+TJNMgW7vHd aJ4pjc0Br2ur0XOm4xsOOsuexQ/sKG4J0qJT4z01Ny4ZJ6UcL6CvLKlQXlySrUw5 POH6+7B7os3ikav+4KGDYJpeyR7l+uveA7IcqZz5OWAbz2yi3HbluPUUyFn+62ic Q0IOi4KkCly4buHNqJqfQRUo+0eBb8sZUfaklIQE07Dd66YVyq4w2WogI2PxBanP b6p4sE9n7wf7GxXXur5jPBz8PheAFu6a6dM9d9BX28ia79OGSGN4mYWbSNOn8wzl gJr1ZqxKJBq73IHpNV7QBOCCgDJ9vtuqxKKm4kuLCMfjCTPBsQ3Bmo/qJulnnGI= =AlmI -----END PGP SIGNATURE----- Merge tag 'trace-3.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace Pull tracing fixes and cleanups from Steven Rostedt: "This contains fixes, optimizations and some clean ups Some of the fixes need to go back to 3.10. They are minor, and deal mostly with incorrect ref counting in accessing event files. There was a couple of optimizations that should have perf perform a bit better when accessing trace events. And some various clean ups. Some of the clean ups are necessary to help in a fix to a theoretical race between opening a event file and deleting that event" * tag 'trace-3.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Kill the unbalanced tr->ref++ in tracing_buffers_open() tracing: Kill trace_array->waiter tracing: Do not (ab)use trace_seq in event_id_read() tracing: Simplify the iteration logic in f_start/f_next tracing: Add ref_data to function and fgraph tracer structs tracing: Miscellaneous fixes for trace_array ref counting tracing: Fix error handling to ensure instances can always be removed tracing/kprobe: Wait for disabling all running kprobe handlers tracing/perf: Move the PERF_MAX_TRACE_SIZE check into perf_trace_buf_prepare() tracing/syscall: Avoid perf_trace_buf_*() if sys_data->perf_events is empty tracing/function: Avoid perf_trace_buf_*() if event_function.perf_events is empty tracing: Typo fix on ring buffer comments tracing: Use trace_seq_puts()/trace_seq_putc() where possible tracing: Use correct config guard CONFIG_STACK_TRACER
This commit is contained in:
commit
b3a3a9c441
|
@ -670,10 +670,6 @@ perf_trace_##call(void *__data, proto) \
|
||||||
sizeof(u64)); \
|
sizeof(u64)); \
|
||||||
__entry_size -= sizeof(u32); \
|
__entry_size -= sizeof(u32); \
|
||||||
\
|
\
|
||||||
if (WARN_ONCE(__entry_size > PERF_MAX_TRACE_SIZE, \
|
|
||||||
"profile buffer not large enough")) \
|
|
||||||
return; \
|
|
||||||
\
|
|
||||||
entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare( \
|
entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare( \
|
||||||
__entry_size, event_call->event.type, &__regs, &rctx); \
|
__entry_size, event_call->event.type, &__regs, &rctx); \
|
||||||
if (!entry) \
|
if (!entry) \
|
||||||
|
|
|
@ -36,11 +36,11 @@ int ring_buffer_print_entry_header(struct trace_seq *s)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = trace_seq_printf(s, "# compressed entry header\n");
|
ret = trace_seq_puts(s, "# compressed entry header\n");
|
||||||
ret = trace_seq_printf(s, "\ttype_len : 5 bits\n");
|
ret = trace_seq_puts(s, "\ttype_len : 5 bits\n");
|
||||||
ret = trace_seq_printf(s, "\ttime_delta : 27 bits\n");
|
ret = trace_seq_puts(s, "\ttime_delta : 27 bits\n");
|
||||||
ret = trace_seq_printf(s, "\tarray : 32 bits\n");
|
ret = trace_seq_puts(s, "\tarray : 32 bits\n");
|
||||||
ret = trace_seq_printf(s, "\n");
|
ret = trace_seq_putc(s, '\n');
|
||||||
ret = trace_seq_printf(s, "\tpadding : type == %d\n",
|
ret = trace_seq_printf(s, "\tpadding : type == %d\n",
|
||||||
RINGBUF_TYPE_PADDING);
|
RINGBUF_TYPE_PADDING);
|
||||||
ret = trace_seq_printf(s, "\ttime_extend : type == %d\n",
|
ret = trace_seq_printf(s, "\ttime_extend : type == %d\n",
|
||||||
|
@ -1066,7 +1066,7 @@ static int rb_check_list(struct ring_buffer_per_cpu *cpu_buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check_pages - integrity check of buffer pages
|
* rb_check_pages - integrity check of buffer pages
|
||||||
* @cpu_buffer: CPU buffer with pages to test
|
* @cpu_buffer: CPU buffer with pages to test
|
||||||
*
|
*
|
||||||
* As a safety measure we check to make sure the data pages have not
|
* As a safety measure we check to make sure the data pages have not
|
||||||
|
@ -1258,7 +1258,7 @@ static int rb_cpu_notify(struct notifier_block *self,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ring_buffer_alloc - allocate a new ring_buffer
|
* __ring_buffer_alloc - allocate a new ring_buffer
|
||||||
* @size: the size in bytes per cpu that is needed.
|
* @size: the size in bytes per cpu that is needed.
|
||||||
* @flags: attributes to set for the ring buffer.
|
* @flags: attributes to set for the ring buffer.
|
||||||
*
|
*
|
||||||
|
@ -1607,6 +1607,7 @@ static void update_pages_handler(struct work_struct *work)
|
||||||
* ring_buffer_resize - resize the ring buffer
|
* ring_buffer_resize - resize the ring buffer
|
||||||
* @buffer: the buffer to resize.
|
* @buffer: the buffer to resize.
|
||||||
* @size: the new size.
|
* @size: the new size.
|
||||||
|
* @cpu_id: the cpu buffer to resize
|
||||||
*
|
*
|
||||||
* Minimum size is 2 * BUF_PAGE_SIZE.
|
* Minimum size is 2 * BUF_PAGE_SIZE.
|
||||||
*
|
*
|
||||||
|
@ -3956,11 +3957,11 @@ EXPORT_SYMBOL_GPL(ring_buffer_consume);
|
||||||
* expected.
|
* expected.
|
||||||
*
|
*
|
||||||
* After a sequence of ring_buffer_read_prepare calls, the user is
|
* After a sequence of ring_buffer_read_prepare calls, the user is
|
||||||
* expected to make at least one call to ring_buffer_prepare_sync.
|
* expected to make at least one call to ring_buffer_read_prepare_sync.
|
||||||
* Afterwards, ring_buffer_read_start is invoked to get things going
|
* Afterwards, ring_buffer_read_start is invoked to get things going
|
||||||
* for real.
|
* for real.
|
||||||
*
|
*
|
||||||
* This overall must be paired with ring_buffer_finish.
|
* This overall must be paired with ring_buffer_read_finish.
|
||||||
*/
|
*/
|
||||||
struct ring_buffer_iter *
|
struct ring_buffer_iter *
|
||||||
ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu)
|
ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu)
|
||||||
|
@ -4009,7 +4010,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_read_prepare_sync);
|
||||||
* an intervening ring_buffer_read_prepare_sync must have been
|
* an intervening ring_buffer_read_prepare_sync must have been
|
||||||
* performed.
|
* performed.
|
||||||
*
|
*
|
||||||
* Must be paired with ring_buffer_finish.
|
* Must be paired with ring_buffer_read_finish.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ring_buffer_read_start(struct ring_buffer_iter *iter)
|
ring_buffer_read_start(struct ring_buffer_iter *iter)
|
||||||
|
@ -4031,7 +4032,7 @@ ring_buffer_read_start(struct ring_buffer_iter *iter)
|
||||||
EXPORT_SYMBOL_GPL(ring_buffer_read_start);
|
EXPORT_SYMBOL_GPL(ring_buffer_read_start);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ring_buffer_finish - finish reading the iterator of the buffer
|
* ring_buffer_read_finish - finish reading the iterator of the buffer
|
||||||
* @iter: The iterator retrieved by ring_buffer_start
|
* @iter: The iterator retrieved by ring_buffer_start
|
||||||
*
|
*
|
||||||
* This re-enables the recording to the buffer, and frees the
|
* This re-enables the recording to the buffer, and frees the
|
||||||
|
@ -4346,6 +4347,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu);
|
||||||
/**
|
/**
|
||||||
* ring_buffer_alloc_read_page - allocate a page to read from buffer
|
* ring_buffer_alloc_read_page - allocate a page to read from buffer
|
||||||
* @buffer: the buffer to allocate for.
|
* @buffer: the buffer to allocate for.
|
||||||
|
* @cpu: the cpu buffer to allocate.
|
||||||
*
|
*
|
||||||
* This function is used in conjunction with ring_buffer_read_page.
|
* This function is used in conjunction with ring_buffer_read_page.
|
||||||
* When reading a full page from the ring buffer, these functions
|
* When reading a full page from the ring buffer, these functions
|
||||||
|
@ -4403,7 +4405,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_free_read_page);
|
||||||
* to swap with a page in the ring buffer.
|
* to swap with a page in the ring buffer.
|
||||||
*
|
*
|
||||||
* for example:
|
* for example:
|
||||||
* rpage = ring_buffer_alloc_read_page(buffer);
|
* rpage = ring_buffer_alloc_read_page(buffer, cpu);
|
||||||
* if (!rpage)
|
* if (!rpage)
|
||||||
* return error;
|
* return error;
|
||||||
* ret = ring_buffer_read_page(buffer, &rpage, len, cpu, 0);
|
* ret = ring_buffer_read_page(buffer, &rpage, len, cpu, 0);
|
||||||
|
|
|
@ -3008,7 +3008,6 @@ static int tracing_release(struct inode *inode, struct file *file)
|
||||||
|
|
||||||
iter = m->private;
|
iter = m->private;
|
||||||
tr = iter->tr;
|
tr = iter->tr;
|
||||||
trace_array_put(tr);
|
|
||||||
|
|
||||||
mutex_lock(&trace_types_lock);
|
mutex_lock(&trace_types_lock);
|
||||||
|
|
||||||
|
@ -3023,6 +3022,9 @@ static int tracing_release(struct inode *inode, struct file *file)
|
||||||
if (!iter->snapshot)
|
if (!iter->snapshot)
|
||||||
/* reenable tracing if it was previously enabled */
|
/* reenable tracing if it was previously enabled */
|
||||||
tracing_start_tr(tr);
|
tracing_start_tr(tr);
|
||||||
|
|
||||||
|
__trace_array_put(tr);
|
||||||
|
|
||||||
mutex_unlock(&trace_types_lock);
|
mutex_unlock(&trace_types_lock);
|
||||||
|
|
||||||
mutex_destroy(&iter->mutex);
|
mutex_destroy(&iter->mutex);
|
||||||
|
@ -3447,6 +3449,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
|
||||||
static int tracing_trace_options_open(struct inode *inode, struct file *file)
|
static int tracing_trace_options_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
struct trace_array *tr = inode->i_private;
|
struct trace_array *tr = inode->i_private;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (tracing_disabled)
|
if (tracing_disabled)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
@ -3454,7 +3457,11 @@ static int tracing_trace_options_open(struct inode *inode, struct file *file)
|
||||||
if (trace_array_get(tr) < 0)
|
if (trace_array_get(tr) < 0)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
return single_open(file, tracing_trace_options_show, inode->i_private);
|
ret = single_open(file, tracing_trace_options_show, inode->i_private);
|
||||||
|
if (ret < 0)
|
||||||
|
trace_array_put(tr);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct file_operations tracing_iter_fops = {
|
static const struct file_operations tracing_iter_fops = {
|
||||||
|
@ -3537,14 +3544,14 @@ static const char readme_msg[] =
|
||||||
"\n snapshot\t\t- Like 'trace' but shows the content of the static snapshot buffer\n"
|
"\n snapshot\t\t- Like 'trace' but shows the content of the static snapshot buffer\n"
|
||||||
"\t\t\t Read the contents for more information\n"
|
"\t\t\t Read the contents for more information\n"
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_STACKTRACE
|
#ifdef CONFIG_STACK_TRACER
|
||||||
" stack_trace\t\t- Shows the max stack trace when active\n"
|
" stack_trace\t\t- Shows the max stack trace when active\n"
|
||||||
" stack_max_size\t- Shows current max stack size that was traced\n"
|
" stack_max_size\t- Shows current max stack size that was traced\n"
|
||||||
"\t\t\t Write into this file to reset the max size (trigger a new trace)\n"
|
"\t\t\t Write into this file to reset the max size (trigger a new trace)\n"
|
||||||
#ifdef CONFIG_DYNAMIC_FTRACE
|
#ifdef CONFIG_DYNAMIC_FTRACE
|
||||||
" stack_trace_filter\t- Like set_ftrace_filter but limits what stack_trace traces\n"
|
" stack_trace_filter\t- Like set_ftrace_filter but limits what stack_trace traces\n"
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_STACKTRACE */
|
#endif /* CONFIG_STACK_TRACER */
|
||||||
;
|
;
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
|
@ -3958,6 +3965,7 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp)
|
||||||
iter = kzalloc(sizeof(*iter), GFP_KERNEL);
|
iter = kzalloc(sizeof(*iter), GFP_KERNEL);
|
||||||
if (!iter) {
|
if (!iter) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
__trace_array_put(tr);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4704,21 +4712,24 @@ static int tracing_snapshot_open(struct inode *inode, struct file *file)
|
||||||
ret = PTR_ERR(iter);
|
ret = PTR_ERR(iter);
|
||||||
} else {
|
} else {
|
||||||
/* Writes still need the seq_file to hold the private data */
|
/* Writes still need the seq_file to hold the private data */
|
||||||
|
ret = -ENOMEM;
|
||||||
m = kzalloc(sizeof(*m), GFP_KERNEL);
|
m = kzalloc(sizeof(*m), GFP_KERNEL);
|
||||||
if (!m)
|
if (!m)
|
||||||
return -ENOMEM;
|
goto out;
|
||||||
iter = kzalloc(sizeof(*iter), GFP_KERNEL);
|
iter = kzalloc(sizeof(*iter), GFP_KERNEL);
|
||||||
if (!iter) {
|
if (!iter) {
|
||||||
kfree(m);
|
kfree(m);
|
||||||
return -ENOMEM;
|
goto out;
|
||||||
}
|
}
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
iter->tr = tr;
|
iter->tr = tr;
|
||||||
iter->trace_buffer = &tc->tr->max_buffer;
|
iter->trace_buffer = &tc->tr->max_buffer;
|
||||||
iter->cpu_file = tc->cpu;
|
iter->cpu_file = tc->cpu;
|
||||||
m->private = iter;
|
m->private = iter;
|
||||||
file->private_data = m;
|
file->private_data = m;
|
||||||
}
|
}
|
||||||
|
out:
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
trace_array_put(tr);
|
trace_array_put(tr);
|
||||||
|
|
||||||
|
@ -4948,8 +4959,6 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp)
|
||||||
|
|
||||||
mutex_lock(&trace_types_lock);
|
mutex_lock(&trace_types_lock);
|
||||||
|
|
||||||
tr->ref++;
|
|
||||||
|
|
||||||
info->iter.tr = tr;
|
info->iter.tr = tr;
|
||||||
info->iter.cpu_file = tc->cpu;
|
info->iter.cpu_file = tc->cpu;
|
||||||
info->iter.trace = tr->current_trace;
|
info->iter.trace = tr->current_trace;
|
||||||
|
@ -5328,9 +5337,10 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct file_operations tracing_stats_fops = {
|
static const struct file_operations tracing_stats_fops = {
|
||||||
.open = tracing_open_generic,
|
.open = tracing_open_generic_tc,
|
||||||
.read = tracing_stats_read,
|
.read = tracing_stats_read,
|
||||||
.llseek = generic_file_llseek,
|
.llseek = generic_file_llseek,
|
||||||
|
.release = tracing_release_generic_tc,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_DYNAMIC_FTRACE
|
#ifdef CONFIG_DYNAMIC_FTRACE
|
||||||
|
@ -5973,8 +5983,10 @@ static int new_instance_create(const char *name)
|
||||||
goto out_free_tr;
|
goto out_free_tr;
|
||||||
|
|
||||||
ret = event_trace_add_tracer(tr->dir, tr);
|
ret = event_trace_add_tracer(tr->dir, tr);
|
||||||
if (ret)
|
if (ret) {
|
||||||
|
debugfs_remove_recursive(tr->dir);
|
||||||
goto out_free_tr;
|
goto out_free_tr;
|
||||||
|
}
|
||||||
|
|
||||||
init_tracer_debugfs(tr, tr->dir);
|
init_tracer_debugfs(tr, tr->dir);
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,6 @@ struct trace_array {
|
||||||
struct dentry *event_dir;
|
struct dentry *event_dir;
|
||||||
struct list_head systems;
|
struct list_head systems;
|
||||||
struct list_head events;
|
struct list_head events;
|
||||||
struct task_struct *waiter;
|
|
||||||
int ref;
|
int ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -680,6 +679,15 @@ extern int trace_selftest_startup_sched_switch(struct tracer *trace,
|
||||||
struct trace_array *tr);
|
struct trace_array *tr);
|
||||||
extern int trace_selftest_startup_branch(struct tracer *trace,
|
extern int trace_selftest_startup_branch(struct tracer *trace,
|
||||||
struct trace_array *tr);
|
struct trace_array *tr);
|
||||||
|
/*
|
||||||
|
* Tracer data references selftest functions that only occur
|
||||||
|
* on boot up. These can be __init functions. Thus, when selftests
|
||||||
|
* are enabled, then the tracers need to reference __init functions.
|
||||||
|
*/
|
||||||
|
#define __tracer_data __refdata
|
||||||
|
#else
|
||||||
|
/* Tracers are seldom changed. Optimize when selftests are disabled. */
|
||||||
|
#define __tracer_data __read_mostly
|
||||||
#endif /* CONFIG_FTRACE_STARTUP_TEST */
|
#endif /* CONFIG_FTRACE_STARTUP_TEST */
|
||||||
|
|
||||||
extern void *head_page(struct trace_array_cpu *data);
|
extern void *head_page(struct trace_array_cpu *data);
|
||||||
|
|
|
@ -236,6 +236,10 @@ __kprobes void *perf_trace_buf_prepare(int size, unsigned short type,
|
||||||
|
|
||||||
BUILD_BUG_ON(PERF_MAX_TRACE_SIZE % sizeof(unsigned long));
|
BUILD_BUG_ON(PERF_MAX_TRACE_SIZE % sizeof(unsigned long));
|
||||||
|
|
||||||
|
if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
|
||||||
|
"perf buffer not large enough"))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
pc = preempt_count();
|
pc = preempt_count();
|
||||||
|
|
||||||
*rctxp = perf_swevent_get_recursion_context();
|
*rctxp = perf_swevent_get_recursion_context();
|
||||||
|
@ -266,6 +270,10 @@ perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
|
||||||
struct pt_regs regs;
|
struct pt_regs regs;
|
||||||
int rctx;
|
int rctx;
|
||||||
|
|
||||||
|
head = this_cpu_ptr(event_function.perf_events);
|
||||||
|
if (hlist_empty(head))
|
||||||
|
return;
|
||||||
|
|
||||||
#define ENTRY_SIZE (ALIGN(sizeof(struct ftrace_entry) + sizeof(u32), \
|
#define ENTRY_SIZE (ALIGN(sizeof(struct ftrace_entry) + sizeof(u32), \
|
||||||
sizeof(u64)) - sizeof(u32))
|
sizeof(u64)) - sizeof(u32))
|
||||||
|
|
||||||
|
@ -279,8 +287,6 @@ perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
|
||||||
|
|
||||||
entry->ip = ip;
|
entry->ip = ip;
|
||||||
entry->parent_ip = parent_ip;
|
entry->parent_ip = parent_ip;
|
||||||
|
|
||||||
head = this_cpu_ptr(event_function.perf_events);
|
|
||||||
perf_trace_buf_submit(entry, ENTRY_SIZE, rctx, 0,
|
perf_trace_buf_submit(entry, ENTRY_SIZE, rctx, 0,
|
||||||
1, ®s, head, NULL);
|
1, ®s, head, NULL);
|
||||||
|
|
||||||
|
|
|
@ -826,59 +826,33 @@ enum {
|
||||||
static void *f_next(struct seq_file *m, void *v, loff_t *pos)
|
static void *f_next(struct seq_file *m, void *v, loff_t *pos)
|
||||||
{
|
{
|
||||||
struct ftrace_event_call *call = m->private;
|
struct ftrace_event_call *call = m->private;
|
||||||
struct ftrace_event_field *field;
|
|
||||||
struct list_head *common_head = &ftrace_common_fields;
|
struct list_head *common_head = &ftrace_common_fields;
|
||||||
struct list_head *head = trace_get_fields(call);
|
struct list_head *head = trace_get_fields(call);
|
||||||
|
struct list_head *node = v;
|
||||||
|
|
||||||
(*pos)++;
|
(*pos)++;
|
||||||
|
|
||||||
switch ((unsigned long)v) {
|
switch ((unsigned long)v) {
|
||||||
case FORMAT_HEADER:
|
case FORMAT_HEADER:
|
||||||
if (unlikely(list_empty(common_head)))
|
node = common_head;
|
||||||
return NULL;
|
break;
|
||||||
|
|
||||||
field = list_entry(common_head->prev,
|
|
||||||
struct ftrace_event_field, link);
|
|
||||||
return field;
|
|
||||||
|
|
||||||
case FORMAT_FIELD_SEPERATOR:
|
case FORMAT_FIELD_SEPERATOR:
|
||||||
if (unlikely(list_empty(head)))
|
node = head;
|
||||||
return NULL;
|
break;
|
||||||
|
|
||||||
field = list_entry(head->prev, struct ftrace_event_field, link);
|
|
||||||
return field;
|
|
||||||
|
|
||||||
case FORMAT_PRINTFMT:
|
case FORMAT_PRINTFMT:
|
||||||
/* all done */
|
/* all done */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
field = v;
|
node = node->prev;
|
||||||
if (field->link.prev == common_head)
|
if (node == common_head)
|
||||||
return (void *)FORMAT_FIELD_SEPERATOR;
|
return (void *)FORMAT_FIELD_SEPERATOR;
|
||||||
else if (field->link.prev == head)
|
else if (node == head)
|
||||||
return (void *)FORMAT_PRINTFMT;
|
return (void *)FORMAT_PRINTFMT;
|
||||||
|
else
|
||||||
field = list_entry(field->link.prev, struct ftrace_event_field, link);
|
return node;
|
||||||
|
|
||||||
return field;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *f_start(struct seq_file *m, loff_t *pos)
|
|
||||||
{
|
|
||||||
loff_t l = 0;
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
/* Start by showing the header */
|
|
||||||
if (!*pos)
|
|
||||||
return (void *)FORMAT_HEADER;
|
|
||||||
|
|
||||||
p = (void *)FORMAT_HEADER;
|
|
||||||
do {
|
|
||||||
p = f_next(m, p, &l);
|
|
||||||
} while (p && l < *pos);
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int f_show(struct seq_file *m, void *v)
|
static int f_show(struct seq_file *m, void *v)
|
||||||
|
@ -904,8 +878,7 @@ static int f_show(struct seq_file *m, void *v)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
field = v;
|
field = list_entry(v, struct ftrace_event_field, link);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Smartly shows the array type(except dynamic array).
|
* Smartly shows the array type(except dynamic array).
|
||||||
* Normal:
|
* Normal:
|
||||||
|
@ -932,6 +905,17 @@ static int f_show(struct seq_file *m, void *v)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *f_start(struct seq_file *m, loff_t *pos)
|
||||||
|
{
|
||||||
|
void *p = (void *)FORMAT_HEADER;
|
||||||
|
loff_t l = 0;
|
||||||
|
|
||||||
|
while (l < *pos && p)
|
||||||
|
p = f_next(m, p, &l);
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
static void f_stop(struct seq_file *m, void *p)
|
static void f_stop(struct seq_file *m, void *p)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -963,23 +947,14 @@ static ssize_t
|
||||||
event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
|
event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
|
||||||
{
|
{
|
||||||
struct ftrace_event_call *call = filp->private_data;
|
struct ftrace_event_call *call = filp->private_data;
|
||||||
struct trace_seq *s;
|
char buf[32];
|
||||||
int r;
|
int len;
|
||||||
|
|
||||||
if (*ppos)
|
if (*ppos)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
s = kmalloc(sizeof(*s), GFP_KERNEL);
|
len = sprintf(buf, "%d\n", call->event.type);
|
||||||
if (!s)
|
return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
trace_seq_init(s);
|
|
||||||
trace_seq_printf(s, "%d\n", call->event.type);
|
|
||||||
|
|
||||||
r = simple_read_from_buffer(ubuf, cnt, ppos,
|
|
||||||
s->buffer, s->len);
|
|
||||||
kfree(s);
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
|
@ -1218,6 +1193,7 @@ show_header(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
|
||||||
|
|
||||||
static int ftrace_event_avail_open(struct inode *inode, struct file *file);
|
static int ftrace_event_avail_open(struct inode *inode, struct file *file);
|
||||||
static int ftrace_event_set_open(struct inode *inode, struct file *file);
|
static int ftrace_event_set_open(struct inode *inode, struct file *file);
|
||||||
|
static int ftrace_event_release(struct inode *inode, struct file *file);
|
||||||
|
|
||||||
static const struct seq_operations show_event_seq_ops = {
|
static const struct seq_operations show_event_seq_ops = {
|
||||||
.start = t_start,
|
.start = t_start,
|
||||||
|
@ -1245,7 +1221,7 @@ static const struct file_operations ftrace_set_event_fops = {
|
||||||
.read = seq_read,
|
.read = seq_read,
|
||||||
.write = ftrace_event_write,
|
.write = ftrace_event_write,
|
||||||
.llseek = seq_lseek,
|
.llseek = seq_lseek,
|
||||||
.release = seq_release,
|
.release = ftrace_event_release,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct file_operations ftrace_enable_fops = {
|
static const struct file_operations ftrace_enable_fops = {
|
||||||
|
@ -1323,6 +1299,15 @@ ftrace_event_open(struct inode *inode, struct file *file,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ftrace_event_release(struct inode *inode, struct file *file)
|
||||||
|
{
|
||||||
|
struct trace_array *tr = inode->i_private;
|
||||||
|
|
||||||
|
trace_array_put(tr);
|
||||||
|
|
||||||
|
return seq_release(inode, file);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ftrace_event_avail_open(struct inode *inode, struct file *file)
|
ftrace_event_avail_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
|
@ -1336,12 +1321,19 @@ ftrace_event_set_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
const struct seq_operations *seq_ops = &show_set_event_seq_ops;
|
const struct seq_operations *seq_ops = &show_set_event_seq_ops;
|
||||||
struct trace_array *tr = inode->i_private;
|
struct trace_array *tr = inode->i_private;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (trace_array_get(tr) < 0)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
if ((file->f_mode & FMODE_WRITE) &&
|
if ((file->f_mode & FMODE_WRITE) &&
|
||||||
(file->f_flags & O_TRUNC))
|
(file->f_flags & O_TRUNC))
|
||||||
ftrace_clear_events(tr);
|
ftrace_clear_events(tr);
|
||||||
|
|
||||||
return ftrace_event_open(inode, file, seq_ops);
|
ret = ftrace_event_open(inode, file, seq_ops);
|
||||||
|
if (ret < 0)
|
||||||
|
trace_array_put(tr);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct event_subsystem *
|
static struct event_subsystem *
|
||||||
|
|
|
@ -646,7 +646,7 @@ void print_event_filter(struct ftrace_event_call *call, struct trace_seq *s)
|
||||||
if (filter && filter->filter_string)
|
if (filter && filter->filter_string)
|
||||||
trace_seq_printf(s, "%s\n", filter->filter_string);
|
trace_seq_printf(s, "%s\n", filter->filter_string);
|
||||||
else
|
else
|
||||||
trace_seq_printf(s, "none\n");
|
trace_seq_puts(s, "none\n");
|
||||||
mutex_unlock(&event_mutex);
|
mutex_unlock(&event_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,7 +660,7 @@ void print_subsystem_event_filter(struct event_subsystem *system,
|
||||||
if (filter && filter->filter_string)
|
if (filter && filter->filter_string)
|
||||||
trace_seq_printf(s, "%s\n", filter->filter_string);
|
trace_seq_printf(s, "%s\n", filter->filter_string);
|
||||||
else
|
else
|
||||||
trace_seq_printf(s, DEFAULT_SYS_FILTER_MESSAGE "\n");
|
trace_seq_puts(s, DEFAULT_SYS_FILTER_MESSAGE "\n");
|
||||||
mutex_unlock(&event_mutex);
|
mutex_unlock(&event_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ static int func_set_flag(u32 old_flags, u32 bit, int set)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct tracer function_trace __read_mostly =
|
static struct tracer function_trace __tracer_data =
|
||||||
{
|
{
|
||||||
.name = "function",
|
.name = "function",
|
||||||
.init = function_trace_init,
|
.init = function_trace_init,
|
||||||
|
|
|
@ -446,7 +446,7 @@ print_graph_proc(struct trace_seq *s, pid_t pid)
|
||||||
|
|
||||||
/* First spaces to align center */
|
/* First spaces to align center */
|
||||||
for (i = 0; i < spaces / 2; i++) {
|
for (i = 0; i < spaces / 2; i++) {
|
||||||
ret = trace_seq_printf(s, " ");
|
ret = trace_seq_putc(s, ' ');
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
}
|
}
|
||||||
|
@ -457,7 +457,7 @@ print_graph_proc(struct trace_seq *s, pid_t pid)
|
||||||
|
|
||||||
/* Last spaces to align center */
|
/* Last spaces to align center */
|
||||||
for (i = 0; i < spaces - (spaces / 2); i++) {
|
for (i = 0; i < spaces - (spaces / 2); i++) {
|
||||||
ret = trace_seq_printf(s, " ");
|
ret = trace_seq_putc(s, ' ');
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
}
|
}
|
||||||
|
@ -503,7 +503,7 @@ verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data)
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
*/
|
*/
|
||||||
ret = trace_seq_printf(s,
|
ret = trace_seq_puts(s,
|
||||||
" ------------------------------------------\n");
|
" ------------------------------------------\n");
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
|
@ -516,7 +516,7 @@ verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data)
|
||||||
if (ret == TRACE_TYPE_PARTIAL_LINE)
|
if (ret == TRACE_TYPE_PARTIAL_LINE)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
|
|
||||||
ret = trace_seq_printf(s, " => ");
|
ret = trace_seq_puts(s, " => ");
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data)
|
||||||
if (ret == TRACE_TYPE_PARTIAL_LINE)
|
if (ret == TRACE_TYPE_PARTIAL_LINE)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
|
|
||||||
ret = trace_seq_printf(s,
|
ret = trace_seq_puts(s,
|
||||||
"\n ------------------------------------------\n\n");
|
"\n ------------------------------------------\n\n");
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
|
@ -645,7 +645,7 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
|
||||||
ret = print_graph_proc(s, pid);
|
ret = print_graph_proc(s, pid);
|
||||||
if (ret == TRACE_TYPE_PARTIAL_LINE)
|
if (ret == TRACE_TYPE_PARTIAL_LINE)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
ret = trace_seq_printf(s, " | ");
|
ret = trace_seq_puts(s, " | ");
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
}
|
}
|
||||||
|
@ -657,9 +657,9 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (type == TRACE_GRAPH_ENT)
|
if (type == TRACE_GRAPH_ENT)
|
||||||
ret = trace_seq_printf(s, "==========>");
|
ret = trace_seq_puts(s, "==========>");
|
||||||
else
|
else
|
||||||
ret = trace_seq_printf(s, "<==========");
|
ret = trace_seq_puts(s, "<==========");
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
|
@ -668,7 +668,7 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
|
||||||
if (ret != TRACE_TYPE_HANDLED)
|
if (ret != TRACE_TYPE_HANDLED)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = trace_seq_printf(s, "\n");
|
ret = trace_seq_putc(s, '\n');
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
|
@ -705,13 +705,13 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
|
||||||
len += strlen(nsecs_str);
|
len += strlen(nsecs_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = trace_seq_printf(s, " us ");
|
ret = trace_seq_puts(s, " us ");
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
|
|
||||||
/* Print remaining spaces to fit the row's width */
|
/* Print remaining spaces to fit the row's width */
|
||||||
for (i = len; i < 7; i++) {
|
for (i = len; i < 7; i++) {
|
||||||
ret = trace_seq_printf(s, " ");
|
ret = trace_seq_putc(s, ' ');
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
}
|
}
|
||||||
|
@ -731,13 +731,13 @@ print_graph_duration(unsigned long long duration, struct trace_seq *s,
|
||||||
/* No real adata, just filling the column with spaces */
|
/* No real adata, just filling the column with spaces */
|
||||||
switch (duration) {
|
switch (duration) {
|
||||||
case DURATION_FILL_FULL:
|
case DURATION_FILL_FULL:
|
||||||
ret = trace_seq_printf(s, " | ");
|
ret = trace_seq_puts(s, " | ");
|
||||||
return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
|
return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
|
||||||
case DURATION_FILL_START:
|
case DURATION_FILL_START:
|
||||||
ret = trace_seq_printf(s, " ");
|
ret = trace_seq_puts(s, " ");
|
||||||
return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
|
return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
|
||||||
case DURATION_FILL_END:
|
case DURATION_FILL_END:
|
||||||
ret = trace_seq_printf(s, " |");
|
ret = trace_seq_puts(s, " |");
|
||||||
return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
|
return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,10 +745,10 @@ print_graph_duration(unsigned long long duration, struct trace_seq *s,
|
||||||
if (flags & TRACE_GRAPH_PRINT_OVERHEAD) {
|
if (flags & TRACE_GRAPH_PRINT_OVERHEAD) {
|
||||||
/* Duration exceeded 100 msecs */
|
/* Duration exceeded 100 msecs */
|
||||||
if (duration > 100000ULL)
|
if (duration > 100000ULL)
|
||||||
ret = trace_seq_printf(s, "! ");
|
ret = trace_seq_puts(s, "! ");
|
||||||
/* Duration exceeded 10 msecs */
|
/* Duration exceeded 10 msecs */
|
||||||
else if (duration > 10000ULL)
|
else if (duration > 10000ULL)
|
||||||
ret = trace_seq_printf(s, "+ ");
|
ret = trace_seq_puts(s, "+ ");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -757,7 +757,7 @@ print_graph_duration(unsigned long long duration, struct trace_seq *s,
|
||||||
* to fill out the space.
|
* to fill out the space.
|
||||||
*/
|
*/
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
ret = trace_seq_printf(s, " ");
|
ret = trace_seq_puts(s, " ");
|
||||||
|
|
||||||
/* Catching here any failure happenned above */
|
/* Catching here any failure happenned above */
|
||||||
if (!ret)
|
if (!ret)
|
||||||
|
@ -767,7 +767,7 @@ print_graph_duration(unsigned long long duration, struct trace_seq *s,
|
||||||
if (ret != TRACE_TYPE_HANDLED)
|
if (ret != TRACE_TYPE_HANDLED)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = trace_seq_printf(s, "| ");
|
ret = trace_seq_puts(s, "| ");
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
|
|
||||||
|
@ -817,7 +817,7 @@ print_graph_entry_leaf(struct trace_iterator *iter,
|
||||||
|
|
||||||
/* Function */
|
/* Function */
|
||||||
for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) {
|
for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) {
|
||||||
ret = trace_seq_printf(s, " ");
|
ret = trace_seq_putc(s, ' ');
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
}
|
}
|
||||||
|
@ -858,7 +858,7 @@ print_graph_entry_nested(struct trace_iterator *iter,
|
||||||
|
|
||||||
/* Function */
|
/* Function */
|
||||||
for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) {
|
for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) {
|
||||||
ret = trace_seq_printf(s, " ");
|
ret = trace_seq_putc(s, ' ');
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
}
|
}
|
||||||
|
@ -917,7 +917,7 @@ print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s,
|
||||||
if (ret == TRACE_TYPE_PARTIAL_LINE)
|
if (ret == TRACE_TYPE_PARTIAL_LINE)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
|
|
||||||
ret = trace_seq_printf(s, " | ");
|
ret = trace_seq_puts(s, " | ");
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
}
|
}
|
||||||
|
@ -1117,7 +1117,7 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
|
||||||
|
|
||||||
/* Closing brace */
|
/* Closing brace */
|
||||||
for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) {
|
for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) {
|
||||||
ret = trace_seq_printf(s, " ");
|
ret = trace_seq_putc(s, ' ');
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
}
|
}
|
||||||
|
@ -1129,7 +1129,7 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
|
||||||
* belongs to, write out the function name.
|
* belongs to, write out the function name.
|
||||||
*/
|
*/
|
||||||
if (func_match) {
|
if (func_match) {
|
||||||
ret = trace_seq_printf(s, "}\n");
|
ret = trace_seq_puts(s, "}\n");
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1179,13 +1179,13 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
|
||||||
/* Indentation */
|
/* Indentation */
|
||||||
if (depth > 0)
|
if (depth > 0)
|
||||||
for (i = 0; i < (depth + 1) * TRACE_GRAPH_INDENT; i++) {
|
for (i = 0; i < (depth + 1) * TRACE_GRAPH_INDENT; i++) {
|
||||||
ret = trace_seq_printf(s, " ");
|
ret = trace_seq_putc(s, ' ');
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The comment */
|
/* The comment */
|
||||||
ret = trace_seq_printf(s, "/* ");
|
ret = trace_seq_puts(s, "/* ");
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
|
|
||||||
|
@ -1216,7 +1216,7 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
|
||||||
s->len--;
|
s->len--;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = trace_seq_printf(s, " */\n");
|
ret = trace_seq_puts(s, " */\n");
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
|
|
||||||
|
@ -1448,7 +1448,7 @@ static struct trace_event graph_trace_ret_event = {
|
||||||
.funcs = &graph_functions
|
.funcs = &graph_functions
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct tracer graph_trace __read_mostly = {
|
static struct tracer graph_trace __tracer_data = {
|
||||||
.name = "function_graph",
|
.name = "function_graph",
|
||||||
.open = graph_trace_open,
|
.open = graph_trace_open,
|
||||||
.pipe_open = graph_trace_open,
|
.pipe_open = graph_trace_open,
|
||||||
|
|
|
@ -243,11 +243,11 @@ find_event_file_link(struct trace_probe *tp, struct ftrace_event_file *file)
|
||||||
static int
|
static int
|
||||||
disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
|
disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
|
||||||
{
|
{
|
||||||
|
struct event_file_link *link = NULL;
|
||||||
|
int wait = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
struct event_file_link *link;
|
|
||||||
|
|
||||||
link = find_event_file_link(tp, file);
|
link = find_event_file_link(tp, file);
|
||||||
if (!link) {
|
if (!link) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
@ -255,10 +255,7 @@ disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
list_del_rcu(&link->list);
|
list_del_rcu(&link->list);
|
||||||
/* synchronize with kprobe_trace_func/kretprobe_trace_func */
|
wait = 1;
|
||||||
synchronize_sched();
|
|
||||||
kfree(link);
|
|
||||||
|
|
||||||
if (!list_empty(&tp->files))
|
if (!list_empty(&tp->files))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -271,8 +268,22 @@ disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
|
||||||
disable_kretprobe(&tp->rp);
|
disable_kretprobe(&tp->rp);
|
||||||
else
|
else
|
||||||
disable_kprobe(&tp->rp.kp);
|
disable_kprobe(&tp->rp.kp);
|
||||||
|
wait = 1;
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
|
if (wait) {
|
||||||
|
/*
|
||||||
|
* Synchronize with kprobe_trace_func/kretprobe_trace_func
|
||||||
|
* to ensure disabled (all running handlers are finished).
|
||||||
|
* This is not only for kfree(), but also the caller,
|
||||||
|
* trace_remove_event_call() supposes it for releasing
|
||||||
|
* event_call related objects, which will be accessed in
|
||||||
|
* the kprobe_trace_func/kretprobe_trace_func.
|
||||||
|
*/
|
||||||
|
synchronize_sched();
|
||||||
|
kfree(link); /* Ignored if link == NULL */
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1087,9 +1098,6 @@ kprobe_perf_func(struct trace_probe *tp, struct pt_regs *regs)
|
||||||
__size = sizeof(*entry) + tp->size + dsize;
|
__size = sizeof(*entry) + tp->size + dsize;
|
||||||
size = ALIGN(__size + sizeof(u32), sizeof(u64));
|
size = ALIGN(__size + sizeof(u32), sizeof(u64));
|
||||||
size -= sizeof(u32);
|
size -= sizeof(u32);
|
||||||
if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
|
|
||||||
"profile buffer not large enough"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
|
entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
|
@ -1120,9 +1128,6 @@ kretprobe_perf_func(struct trace_probe *tp, struct kretprobe_instance *ri,
|
||||||
__size = sizeof(*entry) + tp->size + dsize;
|
__size = sizeof(*entry) + tp->size + dsize;
|
||||||
size = ALIGN(__size + sizeof(u32), sizeof(u64));
|
size = ALIGN(__size + sizeof(u32), sizeof(u64));
|
||||||
size -= sizeof(u32);
|
size -= sizeof(u32);
|
||||||
if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
|
|
||||||
"profile buffer not large enough"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
|
entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
|
|
|
@ -90,7 +90,7 @@ static int mmio_print_pcidev(struct trace_seq *s, const struct pci_dev *dev)
|
||||||
if (drv)
|
if (drv)
|
||||||
ret += trace_seq_printf(s, " %s\n", drv->name);
|
ret += trace_seq_printf(s, " %s\n", drv->name);
|
||||||
else
|
else
|
||||||
ret += trace_seq_printf(s, " \n");
|
ret += trace_seq_puts(s, " \n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ static void mmio_pipe_open(struct trace_iterator *iter)
|
||||||
struct header_iter *hiter;
|
struct header_iter *hiter;
|
||||||
struct trace_seq *s = &iter->seq;
|
struct trace_seq *s = &iter->seq;
|
||||||
|
|
||||||
trace_seq_printf(s, "VERSION 20070824\n");
|
trace_seq_puts(s, "VERSION 20070824\n");
|
||||||
|
|
||||||
hiter = kzalloc(sizeof(*hiter), GFP_KERNEL);
|
hiter = kzalloc(sizeof(*hiter), GFP_KERNEL);
|
||||||
if (!hiter)
|
if (!hiter)
|
||||||
|
@ -209,7 +209,7 @@ static enum print_line_t mmio_print_rw(struct trace_iterator *iter)
|
||||||
(rw->value >> 0) & 0xff, rw->pc, 0);
|
(rw->value >> 0) & 0xff, rw->pc, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = trace_seq_printf(s, "rw what?\n");
|
ret = trace_seq_puts(s, "rw what?\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -245,7 +245,7 @@ static enum print_line_t mmio_print_map(struct trace_iterator *iter)
|
||||||
secs, usec_rem, m->map_id, 0UL, 0);
|
secs, usec_rem, m->map_id, 0UL, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = trace_seq_printf(s, "map what?\n");
|
ret = trace_seq_puts(s, "map what?\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
@ -78,7 +78,7 @@ enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter)
|
||||||
|
|
||||||
trace_assign_type(field, entry);
|
trace_assign_type(field, entry);
|
||||||
|
|
||||||
ret = trace_seq_printf(s, "%s", field->buf);
|
ret = trace_seq_puts(s, field->buf);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return TRACE_TYPE_PARTIAL_LINE;
|
return TRACE_TYPE_PARTIAL_LINE;
|
||||||
|
|
||||||
|
@ -558,14 +558,14 @@ seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s,
|
||||||
if (ret)
|
if (ret)
|
||||||
ret = trace_seq_puts(s, "??");
|
ret = trace_seq_puts(s, "??");
|
||||||
if (ret)
|
if (ret)
|
||||||
ret = trace_seq_puts(s, "\n");
|
ret = trace_seq_putc(s, '\n');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!ret)
|
if (!ret)
|
||||||
break;
|
break;
|
||||||
if (ret)
|
if (ret)
|
||||||
ret = seq_print_user_ip(s, mm, ip, sym_flags);
|
ret = seq_print_user_ip(s, mm, ip, sym_flags);
|
||||||
ret = trace_seq_puts(s, "\n");
|
ret = trace_seq_putc(s, '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mm)
|
if (mm)
|
||||||
|
@ -579,7 +579,7 @@ seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!ip)
|
if (!ip)
|
||||||
return trace_seq_printf(s, "0");
|
return trace_seq_putc(s, '0');
|
||||||
|
|
||||||
if (sym_flags & TRACE_ITER_SYM_OFFSET)
|
if (sym_flags & TRACE_ITER_SYM_OFFSET)
|
||||||
ret = seq_print_sym_offset(s, "%s", ip);
|
ret = seq_print_sym_offset(s, "%s", ip);
|
||||||
|
@ -964,14 +964,14 @@ static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags,
|
||||||
goto partial;
|
goto partial;
|
||||||
|
|
||||||
if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) {
|
if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) {
|
||||||
if (!trace_seq_printf(s, " <-"))
|
if (!trace_seq_puts(s, " <-"))
|
||||||
goto partial;
|
goto partial;
|
||||||
if (!seq_print_ip_sym(s,
|
if (!seq_print_ip_sym(s,
|
||||||
field->parent_ip,
|
field->parent_ip,
|
||||||
flags))
|
flags))
|
||||||
goto partial;
|
goto partial;
|
||||||
}
|
}
|
||||||
if (!trace_seq_printf(s, "\n"))
|
if (!trace_seq_putc(s, '\n'))
|
||||||
goto partial;
|
goto partial;
|
||||||
|
|
||||||
return TRACE_TYPE_HANDLED;
|
return TRACE_TYPE_HANDLED;
|
||||||
|
@ -1210,7 +1210,7 @@ static enum print_line_t trace_stack_print(struct trace_iterator *iter,
|
||||||
|
|
||||||
if (!seq_print_ip_sym(s, *p, flags))
|
if (!seq_print_ip_sym(s, *p, flags))
|
||||||
goto partial;
|
goto partial;
|
||||||
if (!trace_seq_puts(s, "\n"))
|
if (!trace_seq_putc(s, '\n'))
|
||||||
goto partial;
|
goto partial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ print_syscall_exit(struct trace_iterator *iter, int flags,
|
||||||
entry = syscall_nr_to_meta(syscall);
|
entry = syscall_nr_to_meta(syscall);
|
||||||
|
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
trace_seq_printf(s, "\n");
|
trace_seq_putc(s, '\n');
|
||||||
return TRACE_TYPE_HANDLED;
|
return TRACE_TYPE_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,15 +566,15 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
|
||||||
if (!sys_data)
|
if (!sys_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
head = this_cpu_ptr(sys_data->enter_event->perf_events);
|
||||||
|
if (hlist_empty(head))
|
||||||
|
return;
|
||||||
|
|
||||||
/* get the size after alignment with the u32 buffer size field */
|
/* get the size after alignment with the u32 buffer size field */
|
||||||
size = sizeof(unsigned long) * sys_data->nb_args + sizeof(*rec);
|
size = sizeof(unsigned long) * sys_data->nb_args + sizeof(*rec);
|
||||||
size = ALIGN(size + sizeof(u32), sizeof(u64));
|
size = ALIGN(size + sizeof(u32), sizeof(u64));
|
||||||
size -= sizeof(u32);
|
size -= sizeof(u32);
|
||||||
|
|
||||||
if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
|
|
||||||
"perf buffer not large enough"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
rec = (struct syscall_trace_enter *)perf_trace_buf_prepare(size,
|
rec = (struct syscall_trace_enter *)perf_trace_buf_prepare(size,
|
||||||
sys_data->enter_event->event.type, regs, &rctx);
|
sys_data->enter_event->event.type, regs, &rctx);
|
||||||
if (!rec)
|
if (!rec)
|
||||||
|
@ -583,8 +583,6 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
|
||||||
rec->nr = syscall_nr;
|
rec->nr = syscall_nr;
|
||||||
syscall_get_arguments(current, regs, 0, sys_data->nb_args,
|
syscall_get_arguments(current, regs, 0, sys_data->nb_args,
|
||||||
(unsigned long *)&rec->args);
|
(unsigned long *)&rec->args);
|
||||||
|
|
||||||
head = this_cpu_ptr(sys_data->enter_event->perf_events);
|
|
||||||
perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
|
perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,18 +640,14 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
|
||||||
if (!sys_data)
|
if (!sys_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
head = this_cpu_ptr(sys_data->exit_event->perf_events);
|
||||||
|
if (hlist_empty(head))
|
||||||
|
return;
|
||||||
|
|
||||||
/* We can probably do that at build time */
|
/* We can probably do that at build time */
|
||||||
size = ALIGN(sizeof(*rec) + sizeof(u32), sizeof(u64));
|
size = ALIGN(sizeof(*rec) + sizeof(u32), sizeof(u64));
|
||||||
size -= sizeof(u32);
|
size -= sizeof(u32);
|
||||||
|
|
||||||
/*
|
|
||||||
* Impossible, but be paranoid with the future
|
|
||||||
* How to put this check outside runtime?
|
|
||||||
*/
|
|
||||||
if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
|
|
||||||
"exit event has grown above perf buffer size"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
rec = (struct syscall_trace_exit *)perf_trace_buf_prepare(size,
|
rec = (struct syscall_trace_exit *)perf_trace_buf_prepare(size,
|
||||||
sys_data->exit_event->event.type, regs, &rctx);
|
sys_data->exit_event->event.type, regs, &rctx);
|
||||||
if (!rec)
|
if (!rec)
|
||||||
|
@ -661,8 +655,6 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
|
||||||
|
|
||||||
rec->nr = syscall_nr;
|
rec->nr = syscall_nr;
|
||||||
rec->ret = syscall_get_return_value(current, regs);
|
rec->ret = syscall_get_return_value(current, regs);
|
||||||
|
|
||||||
head = this_cpu_ptr(sys_data->exit_event->perf_events);
|
|
||||||
perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
|
perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -818,8 +818,6 @@ static void uprobe_perf_print(struct trace_uprobe *tu,
|
||||||
|
|
||||||
size = SIZEOF_TRACE_ENTRY(is_ret_probe(tu));
|
size = SIZEOF_TRACE_ENTRY(is_ret_probe(tu));
|
||||||
size = ALIGN(size + tu->size + sizeof(u32), sizeof(u64)) - sizeof(u32);
|
size = ALIGN(size + tu->size + sizeof(u32), sizeof(u64)) - sizeof(u32);
|
||||||
if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, "profile buffer not large enough"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
preempt_disable();
|
preempt_disable();
|
||||||
head = this_cpu_ptr(call->perf_events);
|
head = this_cpu_ptr(call->perf_events);
|
||||||
|
|
Loading…
Reference in New Issue