tracing: Pass buffer of event to trigger operations

The ring_buffer_event_time_stamp() is going to be updated to extract the
time stamp for the event without needing it to be set to have absolute
values for all events. But to do so, it needs the buffer that the event is
on as the buffer saves information for the event before it is committed to
the buffer.

If the trace buffer is disabled, a temporary buffer is used, and there's
no access to this buffer from the current histogram triggers, even though
it is passed to the trace event code.

Pass the buffer that the event is on all the way down to the histogram
triggers.

Link: https://lkml.kernel.org/r/20210316164113.542448131@goodmis.orgReviewed-by: default avatarTom Zanussi <zanussi@kernel.org>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 8672e494
...@@ -640,7 +640,8 @@ enum event_trigger_type { ...@@ -640,7 +640,8 @@ enum event_trigger_type {
extern int filter_match_preds(struct event_filter *filter, void *rec); extern int filter_match_preds(struct event_filter *filter, void *rec);
extern enum event_trigger_type extern enum event_trigger_type
event_triggers_call(struct trace_event_file *file, void *rec, event_triggers_call(struct trace_event_file *file,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event); struct ring_buffer_event *event);
extern void extern void
event_triggers_post_call(struct trace_event_file *file, event_triggers_post_call(struct trace_event_file *file,
...@@ -664,7 +665,7 @@ trace_trigger_soft_disabled(struct trace_event_file *file) ...@@ -664,7 +665,7 @@ trace_trigger_soft_disabled(struct trace_event_file *file)
if (!(eflags & EVENT_FILE_FL_TRIGGER_COND)) { if (!(eflags & EVENT_FILE_FL_TRIGGER_COND)) {
if (eflags & EVENT_FILE_FL_TRIGGER_MODE) if (eflags & EVENT_FILE_FL_TRIGGER_MODE)
event_triggers_call(file, NULL, NULL); event_triggers_call(file, NULL, NULL, NULL);
if (eflags & EVENT_FILE_FL_SOFT_DISABLED) if (eflags & EVENT_FILE_FL_SOFT_DISABLED)
return true; return true;
if (eflags & EVENT_FILE_FL_PID_FILTER) if (eflags & EVENT_FILE_FL_PID_FILTER)
......
...@@ -6763,7 +6763,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, ...@@ -6763,7 +6763,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
if (tr->trace_marker_file && !list_empty(&tr->trace_marker_file->triggers)) { if (tr->trace_marker_file && !list_empty(&tr->trace_marker_file->triggers)) {
/* do not add \n before testing triggers, but add \0 */ /* do not add \n before testing triggers, but add \0 */
entry->buf[cnt] = '\0'; entry->buf[cnt] = '\0';
tt = event_triggers_call(tr->trace_marker_file, entry, event); tt = event_triggers_call(tr->trace_marker_file, buffer, entry, event);
} }
if (entry->buf[cnt - 1] != '\n') { if (entry->buf[cnt - 1] != '\n') {
......
...@@ -1329,7 +1329,7 @@ __event_trigger_test_discard(struct trace_event_file *file, ...@@ -1329,7 +1329,7 @@ __event_trigger_test_discard(struct trace_event_file *file,
unsigned long eflags = file->flags; unsigned long eflags = file->flags;
if (eflags & EVENT_FILE_FL_TRIGGER_COND) if (eflags & EVENT_FILE_FL_TRIGGER_COND)
*tt = event_triggers_call(file, entry, event); *tt = event_triggers_call(file, buffer, entry, event);
if (test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags) || if (test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags) ||
(unlikely(file->flags & EVENT_FILE_FL_FILTERED) && (unlikely(file->flags & EVENT_FILE_FL_FILTERED) &&
...@@ -1626,7 +1626,7 @@ extern int register_trigger_hist_enable_disable_cmds(void); ...@@ -1626,7 +1626,7 @@ extern int register_trigger_hist_enable_disable_cmds(void);
*/ */
struct event_trigger_ops { struct event_trigger_ops {
void (*func)(struct event_trigger_data *data, void (*func)(struct event_trigger_data *data,
void *rec, struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *rbe); struct ring_buffer_event *rbe);
int (*init)(struct event_trigger_ops *ops, int (*init)(struct event_trigger_ops *ops,
struct event_trigger_data *data); struct event_trigger_data *data);
......
This diff is collapsed.
...@@ -53,7 +53,8 @@ void trigger_data_free(struct event_trigger_data *data) ...@@ -53,7 +53,8 @@ void trigger_data_free(struct event_trigger_data *data)
* any trigger that should be deferred, ETT_NONE if nothing to defer. * any trigger that should be deferred, ETT_NONE if nothing to defer.
*/ */
enum event_trigger_type enum event_trigger_type
event_triggers_call(struct trace_event_file *file, void *rec, event_triggers_call(struct trace_event_file *file,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event) struct ring_buffer_event *event)
{ {
struct event_trigger_data *data; struct event_trigger_data *data;
...@@ -67,7 +68,7 @@ event_triggers_call(struct trace_event_file *file, void *rec, ...@@ -67,7 +68,7 @@ event_triggers_call(struct trace_event_file *file, void *rec,
if (data->paused) if (data->paused)
continue; continue;
if (!rec) { if (!rec) {
data->ops->func(data, rec, event); data->ops->func(data, buffer, rec, event);
continue; continue;
} }
filter = rcu_dereference_sched(data->filter); filter = rcu_dereference_sched(data->filter);
...@@ -77,7 +78,7 @@ event_triggers_call(struct trace_event_file *file, void *rec, ...@@ -77,7 +78,7 @@ event_triggers_call(struct trace_event_file *file, void *rec,
tt |= data->cmd_ops->trigger_type; tt |= data->cmd_ops->trigger_type;
continue; continue;
} }
data->ops->func(data, rec, event); data->ops->func(data, buffer, rec, event);
} }
return tt; return tt;
} }
...@@ -105,7 +106,7 @@ event_triggers_post_call(struct trace_event_file *file, ...@@ -105,7 +106,7 @@ event_triggers_post_call(struct trace_event_file *file,
if (data->paused) if (data->paused)
continue; continue;
if (data->cmd_ops->trigger_type & tt) if (data->cmd_ops->trigger_type & tt)
data->ops->func(data, NULL, NULL); data->ops->func(data, NULL, NULL, NULL);
} }
} }
EXPORT_SYMBOL_GPL(event_triggers_post_call); EXPORT_SYMBOL_GPL(event_triggers_post_call);
...@@ -937,7 +938,8 @@ get_named_trigger_data(struct event_trigger_data *data) ...@@ -937,7 +938,8 @@ get_named_trigger_data(struct event_trigger_data *data)
} }
static void static void
traceon_trigger(struct event_trigger_data *data, void *rec, traceon_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event) struct ring_buffer_event *event)
{ {
if (tracing_is_on()) if (tracing_is_on())
...@@ -947,7 +949,8 @@ traceon_trigger(struct event_trigger_data *data, void *rec, ...@@ -947,7 +949,8 @@ traceon_trigger(struct event_trigger_data *data, void *rec,
} }
static void static void
traceon_count_trigger(struct event_trigger_data *data, void *rec, traceon_count_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event) struct ring_buffer_event *event)
{ {
if (tracing_is_on()) if (tracing_is_on())
...@@ -963,7 +966,8 @@ traceon_count_trigger(struct event_trigger_data *data, void *rec, ...@@ -963,7 +966,8 @@ traceon_count_trigger(struct event_trigger_data *data, void *rec,
} }
static void static void
traceoff_trigger(struct event_trigger_data *data, void *rec, traceoff_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event) struct ring_buffer_event *event)
{ {
if (!tracing_is_on()) if (!tracing_is_on())
...@@ -973,7 +977,8 @@ traceoff_trigger(struct event_trigger_data *data, void *rec, ...@@ -973,7 +977,8 @@ traceoff_trigger(struct event_trigger_data *data, void *rec,
} }
static void static void
traceoff_count_trigger(struct event_trigger_data *data, void *rec, traceoff_count_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event) struct ring_buffer_event *event)
{ {
if (!tracing_is_on()) if (!tracing_is_on())
...@@ -1071,7 +1076,8 @@ static struct event_command trigger_traceoff_cmd = { ...@@ -1071,7 +1076,8 @@ static struct event_command trigger_traceoff_cmd = {
#ifdef CONFIG_TRACER_SNAPSHOT #ifdef CONFIG_TRACER_SNAPSHOT
static void static void
snapshot_trigger(struct event_trigger_data *data, void *rec, snapshot_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event) struct ring_buffer_event *event)
{ {
struct trace_event_file *file = data->private_data; struct trace_event_file *file = data->private_data;
...@@ -1083,7 +1089,8 @@ snapshot_trigger(struct event_trigger_data *data, void *rec, ...@@ -1083,7 +1089,8 @@ snapshot_trigger(struct event_trigger_data *data, void *rec,
} }
static void static void
snapshot_count_trigger(struct event_trigger_data *data, void *rec, snapshot_count_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event) struct ring_buffer_event *event)
{ {
if (!data->count) if (!data->count)
...@@ -1092,7 +1099,7 @@ snapshot_count_trigger(struct event_trigger_data *data, void *rec, ...@@ -1092,7 +1099,7 @@ snapshot_count_trigger(struct event_trigger_data *data, void *rec,
if (data->count != -1) if (data->count != -1)
(data->count)--; (data->count)--;
snapshot_trigger(data, rec, event); snapshot_trigger(data, buffer, rec, event);
} }
static int static int
...@@ -1176,14 +1183,16 @@ static __init int register_trigger_snapshot_cmd(void) { return 0; } ...@@ -1176,14 +1183,16 @@ static __init int register_trigger_snapshot_cmd(void) { return 0; }
#endif #endif
static void static void
stacktrace_trigger(struct event_trigger_data *data, void *rec, stacktrace_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event) struct ring_buffer_event *event)
{ {
trace_dump_stack(STACK_SKIP); trace_dump_stack(STACK_SKIP);
} }
static void static void
stacktrace_count_trigger(struct event_trigger_data *data, void *rec, stacktrace_count_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event) struct ring_buffer_event *event)
{ {
if (!data->count) if (!data->count)
...@@ -1192,7 +1201,7 @@ stacktrace_count_trigger(struct event_trigger_data *data, void *rec, ...@@ -1192,7 +1201,7 @@ stacktrace_count_trigger(struct event_trigger_data *data, void *rec,
if (data->count != -1) if (data->count != -1)
(data->count)--; (data->count)--;
stacktrace_trigger(data, rec, event); stacktrace_trigger(data, buffer, rec, event);
} }
static int static int
...@@ -1254,7 +1263,8 @@ static __init void unregister_trigger_traceon_traceoff_cmds(void) ...@@ -1254,7 +1263,8 @@ static __init void unregister_trigger_traceon_traceoff_cmds(void)
} }
static void static void
event_enable_trigger(struct event_trigger_data *data, void *rec, event_enable_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event) struct ring_buffer_event *event)
{ {
struct enable_trigger_data *enable_data = data->private_data; struct enable_trigger_data *enable_data = data->private_data;
...@@ -1266,7 +1276,8 @@ event_enable_trigger(struct event_trigger_data *data, void *rec, ...@@ -1266,7 +1276,8 @@ event_enable_trigger(struct event_trigger_data *data, void *rec,
} }
static void static void
event_enable_count_trigger(struct event_trigger_data *data, void *rec, event_enable_count_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event) struct ring_buffer_event *event)
{ {
struct enable_trigger_data *enable_data = data->private_data; struct enable_trigger_data *enable_data = data->private_data;
...@@ -1281,7 +1292,7 @@ event_enable_count_trigger(struct event_trigger_data *data, void *rec, ...@@ -1281,7 +1292,7 @@ event_enable_count_trigger(struct event_trigger_data *data, void *rec,
if (data->count != -1) if (data->count != -1)
(data->count)--; (data->count)--;
event_enable_trigger(data, rec, event); event_enable_trigger(data, buffer, rec, event);
} }
int event_enable_trigger_print(struct seq_file *m, int event_enable_trigger_print(struct seq_file *m,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment