Skip to content

Commit b94bc80

Browse files
committed
tracing: Use a no_filter_buffering_ref to stop using the filter buffer
Currently, the trace histograms relies on it using absolute time stamps to trigger the tracing to not use the temp buffer if filters are set. That's because the histograms need the full timestamp that is saved in the ring buffer. That is no longer the case, as the ring_buffer_event_time_stamp() can now return the time stamp for all events without all triggering a full absolute time stamp. Now that the absolute time stamp is an unrelated dependency to not using the filters. There's nothing about having absolute timestamps to keep from using the filter buffer. Instead, change the interface to explicitly state to disable filter buffering that the histogram logic can use. Link: https://lkml.kernel.org/r/20210316164113.847886563@goodmis.org Reviewed-by: Tom Zanussi <zanussi@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent efe6196 commit b94bc80

3 files changed

Lines changed: 17 additions & 21 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,12 +2737,13 @@ trace_event_buffer_lock_reserve(struct trace_buffer **current_rb,
27372737
unsigned int trace_ctx)
27382738
{
27392739
struct ring_buffer_event *entry;
2740+
struct trace_array *tr = trace_file->tr;
27402741
int val;
27412742

2742-
*current_rb = trace_file->tr->array_buffer.buffer;
2743+
*current_rb = tr->array_buffer.buffer;
27432744

2744-
if (!ring_buffer_time_stamp_abs(*current_rb) && (trace_file->flags &
2745-
(EVENT_FILE_FL_SOFT_DISABLED | EVENT_FILE_FL_FILTERED)) &&
2745+
if (!tr->no_filter_buffering_ref &&
2746+
(trace_file->flags & (EVENT_FILE_FL_SOFT_DISABLED | EVENT_FILE_FL_FILTERED)) &&
27462747
(entry = this_cpu_read(trace_buffered_event))) {
27472748
/* Try to use the per cpu buffer first */
27482749
val = this_cpu_inc_return(trace_buffered_event_cnt);
@@ -6971,31 +6972,26 @@ static int tracing_time_stamp_mode_open(struct inode *inode, struct file *file)
69716972
return ret;
69726973
}
69736974

6974-
int tracing_set_time_stamp_abs(struct trace_array *tr, bool abs)
6975+
/*
6976+
* Set or disable using the per CPU trace_buffer_event when possible.
6977+
*/
6978+
int tracing_set_filter_buffering(struct trace_array *tr, bool set)
69756979
{
69766980
int ret = 0;
69776981

69786982
mutex_lock(&trace_types_lock);
69796983

6980-
if (abs && tr->time_stamp_abs_ref++)
6984+
if (set && tr->no_filter_buffering_ref++)
69816985
goto out;
69826986

6983-
if (!abs) {
6984-
if (WARN_ON_ONCE(!tr->time_stamp_abs_ref)) {
6987+
if (!set) {
6988+
if (WARN_ON_ONCE(!tr->no_filter_buffering_ref)) {
69856989
ret = -EINVAL;
69866990
goto out;
69876991
}
69886992

6989-
if (--tr->time_stamp_abs_ref)
6990-
goto out;
6993+
--tr->no_filter_buffering_ref;
69916994
}
6992-
6993-
ring_buffer_set_time_stamp_abs(tr->array_buffer.buffer, abs);
6994-
6995-
#ifdef CONFIG_TRACER_MAX_TRACE
6996-
if (tr->max_buffer.buffer)
6997-
ring_buffer_set_time_stamp_abs(tr->max_buffer.buffer, abs);
6998-
#endif
69996995
out:
70006996
mutex_unlock(&trace_types_lock);
70016997

‎kernel/trace/trace.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ struct trace_array {
352352
/* function tracing enabled */
353353
int function_enabled;
354354
#endif
355-
int time_stamp_abs_ref;
355+
int no_filter_buffering_ref;
356356
struct list_head hist_vars;
357357
#ifdef CONFIG_TRACER_SNAPSHOT
358358
struct cond_snapshot *cond_snapshot;
@@ -372,7 +372,7 @@ extern int tracing_check_open_get_tr(struct trace_array *tr);
372372
extern struct trace_array *trace_array_find(const char *instance);
373373
extern struct trace_array *trace_array_find_get(const char *instance);
374374

375-
extern int tracing_set_time_stamp_abs(struct trace_array *tr, bool abs);
375+
extern int tracing_set_filter_buffering(struct trace_array *tr, bool set);
376376
extern int tracing_set_clock(struct trace_array *tr, const char *clockstr);
377377

378378
extern bool trace_clock_in_ns(struct trace_array *tr);

‎kernel/trace/trace_events_hist.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5484,7 +5484,7 @@ static int hist_register_trigger(char *glob, struct event_trigger_ops *ops,
54845484
goto out;
54855485
}
54865486

5487-
tracing_set_time_stamp_abs(file->tr, true);
5487+
tracing_set_filter_buffering(file->tr, true);
54885488
}
54895489

54905490
if (named_data)
@@ -5592,7 +5592,7 @@ static void hist_unregister_trigger(char *glob, struct event_trigger_ops *ops,
55925592

55935593
if (hist_data->enable_timestamps) {
55945594
if (!hist_data->remove || unregistered)
5595-
tracing_set_time_stamp_abs(file->tr, false);
5595+
tracing_set_filter_buffering(file->tr, false);
55965596
}
55975597
}
55985598

@@ -5639,7 +5639,7 @@ static void hist_unreg_all(struct trace_event_file *file)
56395639

56405640
update_cond_flag(file);
56415641
if (hist_data->enable_timestamps)
5642-
tracing_set_time_stamp_abs(file->tr, false);
5642+
tracing_set_filter_buffering(file->tr, false);
56435643
if (test->ops->free)
56445644
test->ops->free(test->ops, test);
56455645
}

0 commit comments

Comments
 (0)