提交 2c9b238e 编写于 作者: A Arnaldo Carvalho de Melo 提交者: Ingo Molnar

trace: Change struct trace_event callbacks parameter list

Impact: API change

The trace_seq and trace_entry are in trace_iterator, where there are
more fields that may be needed by tracers, so just pass the
tracer_iterator as is already the case for struct tracer->print_line.
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 c4a8e8be
...@@ -1140,10 +1140,10 @@ static struct { ...@@ -1140,10 +1140,10 @@ static struct {
[__BLK_TA_REMAP] = {{ "A", "remap" }, blk_log_remap }, [__BLK_TA_REMAP] = {{ "A", "remap" }, blk_log_remap },
}; };
static int blk_trace_event_print(struct trace_seq *s, struct trace_entry *ent, static int blk_trace_event_print(struct trace_iterator *iter, int flags)
int flags)
{ {
const struct blk_io_trace *t = (struct blk_io_trace *)ent; struct trace_seq *s = &iter->seq;
const struct blk_io_trace *t = (struct blk_io_trace *)iter->ent;
const u16 what = t->action & ((1 << BLK_TC_SHIFT) - 1); const u16 what = t->action & ((1 << BLK_TC_SHIFT) - 1);
int ret; int ret;
...@@ -1153,7 +1153,7 @@ static int blk_trace_event_print(struct trace_seq *s, struct trace_entry *ent, ...@@ -1153,7 +1153,7 @@ static int blk_trace_event_print(struct trace_seq *s, struct trace_entry *ent,
const bool long_act = !!(trace_flags & TRACE_ITER_VERBOSE); const bool long_act = !!(trace_flags & TRACE_ITER_VERBOSE);
ret = blk_log_action_seq(s, t, what2act[what].act[long_act]); ret = blk_log_action_seq(s, t, what2act[what].act[long_act]);
if (ret) if (ret)
ret = what2act[what].print(s, ent); ret = what2act[what].print(s, iter->ent);
} }
return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE; return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
......
...@@ -1388,7 +1388,7 @@ static enum print_line_t print_lat_fmt(struct trace_iterator *iter) ...@@ -1388,7 +1388,7 @@ static enum print_line_t print_lat_fmt(struct trace_iterator *iter)
} }
if (event && event->latency_trace) { if (event && event->latency_trace) {
ret = event->latency_trace(s, entry, sym_flags); ret = event->latency_trace(iter, sym_flags);
if (ret) if (ret)
return ret; return ret;
return TRACE_TYPE_HANDLED; return TRACE_TYPE_HANDLED;
...@@ -1419,7 +1419,7 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter) ...@@ -1419,7 +1419,7 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
} }
if (event && event->trace) { if (event && event->trace) {
ret = event->trace(s, entry, sym_flags); ret = event->trace(iter, sym_flags);
if (ret) if (ret)
return ret; return ret;
return TRACE_TYPE_HANDLED; return TRACE_TYPE_HANDLED;
...@@ -1449,7 +1449,7 @@ static enum print_line_t print_raw_fmt(struct trace_iterator *iter) ...@@ -1449,7 +1449,7 @@ static enum print_line_t print_raw_fmt(struct trace_iterator *iter)
event = ftrace_find_event(entry->type); event = ftrace_find_event(entry->type);
if (event && event->raw) { if (event && event->raw) {
ret = event->raw(s, entry, 0); ret = event->raw(iter, 0);
if (ret) if (ret)
return ret; return ret;
return TRACE_TYPE_HANDLED; return TRACE_TYPE_HANDLED;
...@@ -1478,7 +1478,7 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter) ...@@ -1478,7 +1478,7 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
event = ftrace_find_event(entry->type); event = ftrace_find_event(entry->type);
if (event && event->hex) if (event && event->hex)
event->hex(s, entry, 0); event->hex(iter, 0);
SEQ_PUT_FIELD_RET(s, newline); SEQ_PUT_FIELD_RET(s, newline);
...@@ -1517,7 +1517,7 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter) ...@@ -1517,7 +1517,7 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
event = ftrace_find_event(entry->type); event = ftrace_find_event(entry->type);
if (event && event->binary) if (event && event->binary)
event->binary(s, entry, 0); event->binary(iter, 0);
return TRACE_TYPE_HANDLED; return TRACE_TYPE_HANDLED;
} }
......
...@@ -160,14 +160,13 @@ trace_print_print(struct trace_seq *s, struct trace_entry *entry, int flags) ...@@ -160,14 +160,13 @@ trace_print_print(struct trace_seq *s, struct trace_entry *entry, int flags)
return TRACE_TYPE_PARTIAL_LINE; return TRACE_TYPE_PARTIAL_LINE;
} }
static int static int trace_branch_print(struct trace_iterator *iter, int flags)
trace_branch_print(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
struct trace_branch *field; struct trace_branch *field;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
if (trace_seq_printf(s, "[%s] %s:%s:%d\n", if (trace_seq_printf(&iter->seq, "[%s] %s:%s:%d\n",
field->correct ? " ok " : " MISS ", field->correct ? " ok " : " MISS ",
field->func, field->func,
field->file, field->file,
......
...@@ -484,19 +484,18 @@ int unregister_ftrace_event(struct trace_event *event) ...@@ -484,19 +484,18 @@ int unregister_ftrace_event(struct trace_event *event)
* Standard events * Standard events
*/ */
int int trace_nop_print(struct trace_iterator *iter, int flags)
trace_nop_print(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
return 0; return 0;
} }
/* TRACE_FN */ /* TRACE_FN */
static int static int trace_fn_latency(struct trace_iterator *iter, int flags)
trace_fn_latency(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
struct ftrace_entry *field; struct ftrace_entry *field;
struct trace_seq *s = &iter->seq;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
if (!seq_print_ip_sym(s, field->ip, flags)) if (!seq_print_ip_sym(s, field->ip, flags))
goto partial; goto partial;
...@@ -513,12 +512,12 @@ trace_fn_latency(struct trace_seq *s, struct trace_entry *entry, int flags) ...@@ -513,12 +512,12 @@ trace_fn_latency(struct trace_seq *s, struct trace_entry *entry, int flags)
return TRACE_TYPE_PARTIAL_LINE; return TRACE_TYPE_PARTIAL_LINE;
} }
static int static int trace_fn_trace(struct trace_iterator *iter, int flags)
trace_fn_trace(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
struct ftrace_entry *field; struct ftrace_entry *field;
struct trace_seq *s = &iter->seq;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
if (!seq_print_ip_sym(s, field->ip, flags)) if (!seq_print_ip_sym(s, field->ip, flags))
goto partial; goto partial;
...@@ -540,14 +539,13 @@ trace_fn_trace(struct trace_seq *s, struct trace_entry *entry, int flags) ...@@ -540,14 +539,13 @@ trace_fn_trace(struct trace_seq *s, struct trace_entry *entry, int flags)
return TRACE_TYPE_PARTIAL_LINE; return TRACE_TYPE_PARTIAL_LINE;
} }
static int static int trace_fn_raw(struct trace_iterator *iter, int flags)
trace_fn_raw(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
struct ftrace_entry *field; struct ftrace_entry *field;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
if (!trace_seq_printf(s, "%lx %lx\n", if (!trace_seq_printf(&iter->seq, "%lx %lx\n",
field->ip, field->ip,
field->parent_ip)) field->parent_ip))
return TRACE_TYPE_PARTIAL_LINE; return TRACE_TYPE_PARTIAL_LINE;
...@@ -555,12 +553,12 @@ trace_fn_raw(struct trace_seq *s, struct trace_entry *entry, int flags) ...@@ -555,12 +553,12 @@ trace_fn_raw(struct trace_seq *s, struct trace_entry *entry, int flags)
return 0; return 0;
} }
static int static int trace_fn_hex(struct trace_iterator *iter, int flags)
trace_fn_hex(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
struct ftrace_entry *field; struct ftrace_entry *field;
struct trace_seq *s = &iter->seq;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
SEQ_PUT_HEX_FIELD_RET(s, field->ip); SEQ_PUT_HEX_FIELD_RET(s, field->ip);
SEQ_PUT_HEX_FIELD_RET(s, field->parent_ip); SEQ_PUT_HEX_FIELD_RET(s, field->parent_ip);
...@@ -568,12 +566,12 @@ trace_fn_hex(struct trace_seq *s, struct trace_entry *entry, int flags) ...@@ -568,12 +566,12 @@ trace_fn_hex(struct trace_seq *s, struct trace_entry *entry, int flags)
return 0; return 0;
} }
static int static int trace_fn_bin(struct trace_iterator *iter, int flags)
trace_fn_bin(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
struct ftrace_entry *field; struct ftrace_entry *field;
struct trace_seq *s = &iter->seq;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
SEQ_PUT_FIELD_RET(s, field->ip); SEQ_PUT_FIELD_RET(s, field->ip);
SEQ_PUT_FIELD_RET(s, field->parent_ip); SEQ_PUT_FIELD_RET(s, field->parent_ip);
...@@ -591,20 +589,19 @@ static struct trace_event trace_fn_event = { ...@@ -591,20 +589,19 @@ static struct trace_event trace_fn_event = {
}; };
/* TRACE_CTX an TRACE_WAKE */ /* TRACE_CTX an TRACE_WAKE */
static int static int trace_ctxwake_print(struct trace_iterator *iter, char *delim)
trace_ctxwake_print(struct trace_seq *s, struct trace_entry *entry, int flags,
char *delim)
{ {
struct ctx_switch_entry *field; struct ctx_switch_entry *field;
char *comm; char *comm;
int S, T; int S, T;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
T = task_state_char(field->next_state); T = task_state_char(field->next_state);
S = task_state_char(field->prev_state); S = task_state_char(field->prev_state);
comm = trace_find_cmdline(field->next_pid); comm = trace_find_cmdline(field->next_pid);
if (!trace_seq_printf(s, " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n", if (!trace_seq_printf(&iter->seq,
" %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n",
field->prev_pid, field->prev_pid,
field->prev_prio, field->prev_prio,
S, delim, S, delim,
...@@ -617,31 +614,27 @@ trace_ctxwake_print(struct trace_seq *s, struct trace_entry *entry, int flags, ...@@ -617,31 +614,27 @@ trace_ctxwake_print(struct trace_seq *s, struct trace_entry *entry, int flags,
return 0; return 0;
} }
static int static int trace_ctx_print(struct trace_iterator *iter, int flags)
trace_ctx_print(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
return trace_ctxwake_print(s, entry, flags, "==>"); return trace_ctxwake_print(iter, "==>");
} }
static int static int trace_wake_print(struct trace_iterator *iter, int flags)
trace_wake_print(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
return trace_ctxwake_print(s, entry, flags, " +"); return trace_ctxwake_print(iter, " +");
} }
static int static int trace_ctxwake_raw(struct trace_iterator *iter, char S)
trace_ctxwake_raw(struct trace_seq *s, struct trace_entry *entry, int flags,
char S)
{ {
struct ctx_switch_entry *field; struct ctx_switch_entry *field;
int T; int T;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
if (!S) if (!S)
task_state_char(field->prev_state); task_state_char(field->prev_state);
T = task_state_char(field->next_state); T = task_state_char(field->next_state);
if (!trace_seq_printf(s, "%d %d %c %d %d %d %c\n", if (!trace_seq_printf(&iter->seq, "%d %d %c %d %d %d %c\n",
field->prev_pid, field->prev_pid,
field->prev_prio, field->prev_prio,
S, S,
...@@ -654,27 +647,24 @@ trace_ctxwake_raw(struct trace_seq *s, struct trace_entry *entry, int flags, ...@@ -654,27 +647,24 @@ trace_ctxwake_raw(struct trace_seq *s, struct trace_entry *entry, int flags,
return 0; return 0;
} }
static int static int trace_ctx_raw(struct trace_iterator *iter, int flags)
trace_ctx_raw(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
return trace_ctxwake_raw(s, entry, flags, 0); return trace_ctxwake_raw(iter, 0);
} }
static int static int trace_wake_raw(struct trace_iterator *iter, int flags)
trace_wake_raw(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
return trace_ctxwake_raw(s, entry, flags, '+'); return trace_ctxwake_raw(iter, '+');
} }
static int static int trace_ctxwake_hex(struct trace_iterator *iter, char S)
trace_ctxwake_hex(struct trace_seq *s, struct trace_entry *entry, int flags,
char S)
{ {
struct ctx_switch_entry *field; struct ctx_switch_entry *field;
struct trace_seq *s = &iter->seq;
int T; int T;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
if (!S) if (!S)
task_state_char(field->prev_state); task_state_char(field->prev_state);
...@@ -691,24 +681,22 @@ trace_ctxwake_hex(struct trace_seq *s, struct trace_entry *entry, int flags, ...@@ -691,24 +681,22 @@ trace_ctxwake_hex(struct trace_seq *s, struct trace_entry *entry, int flags,
return 0; return 0;
} }
static int static int trace_ctx_hex(struct trace_iterator *iter, int flags)
trace_ctx_hex(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
return trace_ctxwake_hex(s, entry, flags, 0); return trace_ctxwake_hex(iter, 0);
} }
static int static int trace_wake_hex(struct trace_iterator *iter, int flags)
trace_wake_hex(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
return trace_ctxwake_hex(s, entry, flags, '+'); return trace_ctxwake_hex(iter, '+');
} }
static int static int trace_ctxwake_bin(struct trace_iterator *iter, int flags)
trace_ctxwake_bin(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
struct ctx_switch_entry *field; struct ctx_switch_entry *field;
struct trace_seq *s = &iter->seq;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
SEQ_PUT_FIELD_RET(s, field->prev_pid); SEQ_PUT_FIELD_RET(s, field->prev_pid);
SEQ_PUT_FIELD_RET(s, field->prev_prio); SEQ_PUT_FIELD_RET(s, field->prev_prio);
...@@ -739,14 +727,13 @@ static struct trace_event trace_wake_event = { ...@@ -739,14 +727,13 @@ static struct trace_event trace_wake_event = {
}; };
/* TRACE_SPECIAL */ /* TRACE_SPECIAL */
static int static int trace_special_print(struct trace_iterator *iter, int flags)
trace_special_print(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
struct special_entry *field; struct special_entry *field;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
if (!trace_seq_printf(s, "# %ld %ld %ld\n", if (!trace_seq_printf(&iter->seq, "# %ld %ld %ld\n",
field->arg1, field->arg1,
field->arg2, field->arg2,
field->arg3)) field->arg3))
...@@ -755,12 +742,12 @@ trace_special_print(struct trace_seq *s, struct trace_entry *entry, int flags) ...@@ -755,12 +742,12 @@ trace_special_print(struct trace_seq *s, struct trace_entry *entry, int flags)
return 0; return 0;
} }
static int static int trace_special_hex(struct trace_iterator *iter, int flags)
trace_special_hex(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
struct special_entry *field; struct special_entry *field;
struct trace_seq *s = &iter->seq;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
SEQ_PUT_HEX_FIELD_RET(s, field->arg1); SEQ_PUT_HEX_FIELD_RET(s, field->arg1);
SEQ_PUT_HEX_FIELD_RET(s, field->arg2); SEQ_PUT_HEX_FIELD_RET(s, field->arg2);
...@@ -769,12 +756,12 @@ trace_special_hex(struct trace_seq *s, struct trace_entry *entry, int flags) ...@@ -769,12 +756,12 @@ trace_special_hex(struct trace_seq *s, struct trace_entry *entry, int flags)
return 0; return 0;
} }
static int static int trace_special_bin(struct trace_iterator *iter, int flags)
trace_special_bin(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
struct special_entry *field; struct special_entry *field;
struct trace_seq *s = &iter->seq;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
SEQ_PUT_FIELD_RET(s, field->arg1); SEQ_PUT_FIELD_RET(s, field->arg1);
SEQ_PUT_FIELD_RET(s, field->arg2); SEQ_PUT_FIELD_RET(s, field->arg2);
...@@ -794,13 +781,13 @@ static struct trace_event trace_special_event = { ...@@ -794,13 +781,13 @@ static struct trace_event trace_special_event = {
/* TRACE_STACK */ /* TRACE_STACK */
static int static int trace_stack_print(struct trace_iterator *iter, int flags)
trace_stack_print(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
struct stack_entry *field; struct stack_entry *field;
struct trace_seq *s = &iter->seq;
int i; int i;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
for (i = 0; i < FTRACE_STACK_ENTRIES; i++) { for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
if (i) { if (i) {
...@@ -830,13 +817,12 @@ static struct trace_event trace_stack_event = { ...@@ -830,13 +817,12 @@ static struct trace_event trace_stack_event = {
}; };
/* TRACE_USER_STACK */ /* TRACE_USER_STACK */
static int static int trace_user_stack_print(struct trace_iterator *iter, int flags)
trace_user_stack_print(struct trace_seq *s, struct trace_entry *entry,
int flags)
{ {
struct userstack_entry *field; struct userstack_entry *field;
struct trace_seq *s = &iter->seq;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
if (!seq_print_userip_objs(field, s, flags)) if (!seq_print_userip_objs(field, s, flags))
goto partial; goto partial;
...@@ -860,12 +846,12 @@ static struct trace_event trace_user_stack_event = { ...@@ -860,12 +846,12 @@ static struct trace_event trace_user_stack_event = {
}; };
/* TRACE_PRINT */ /* TRACE_PRINT */
static int static int trace_print_print(struct trace_iterator *iter, int flags)
trace_print_print(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
struct print_entry *field; struct print_entry *field;
struct trace_seq *s = &iter->seq;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
if (!seq_print_ip_sym(s, field->ip, flags)) if (!seq_print_ip_sym(s, field->ip, flags))
goto partial; goto partial;
...@@ -879,14 +865,13 @@ trace_print_print(struct trace_seq *s, struct trace_entry *entry, int flags) ...@@ -879,14 +865,13 @@ trace_print_print(struct trace_seq *s, struct trace_entry *entry, int flags)
return TRACE_TYPE_PARTIAL_LINE; return TRACE_TYPE_PARTIAL_LINE;
} }
static int static int trace_print_raw(struct trace_iterator *iter, int flags)
trace_print_raw(struct trace_seq *s, struct trace_entry *entry, int flags)
{ {
struct print_entry *field; struct print_entry *field;
trace_assign_type(field, entry); trace_assign_type(field, iter->ent);
if (!trace_seq_printf(s, "# %lx %s", field->ip, field->buf)) if (!trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf))
goto partial; goto partial;
return 0; return 0;
......
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
#include "trace.h" #include "trace.h"
typedef int (*trace_print_func)(struct trace_seq *s, struct trace_entry *entry, typedef int (*trace_print_func)(struct trace_iterator *iter, int flags);
int flags);
struct trace_event { struct trace_event {
struct hlist_node node; struct hlist_node node;
...@@ -40,8 +39,7 @@ struct trace_event *ftrace_find_event(int type); ...@@ -40,8 +39,7 @@ struct trace_event *ftrace_find_event(int type);
int register_ftrace_event(struct trace_event *event); int register_ftrace_event(struct trace_event *event);
int unregister_ftrace_event(struct trace_event *event); int unregister_ftrace_event(struct trace_event *event);
int int trace_nop_print(struct trace_iterator *iter, int flags);
trace_nop_print(struct trace_seq *s, struct trace_entry *entry, int flags);
#define MAX_MEMHEX_BYTES 8 #define MAX_MEMHEX_BYTES 8
#define HEX_CHARS (MAX_MEMHEX_BYTES*2 + 1) #define HEX_CHARS (MAX_MEMHEX_BYTES*2 + 1)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册