Skip to content

Commit b1169cc

Browse files
committed
tracing: Remove mock up poll wait function
Now that the ring buffer has a built in way to wake up readers when there's data, using irq_work such that it is safe to do it in any context. But it was still using the old "poor man's" wait polling that checks every 1/10 of a second to see if it should wake up a waiter. This makes the latency for a wake up excruciatingly long. No need to do that anymore. Completely remove the different wait_poll types from the tracers and have them all use the default one now. Reported-by: Johannes Berg <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent f487426 commit b1169cc

File tree

6 files changed

+4
-34
lines changed

6 files changed

+4
-34
lines changed

kernel/trace/trace.c

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu)
10851085
}
10861086
#endif /* CONFIG_TRACER_MAX_TRACE */
10871087

1088-
static void default_wait_pipe(struct trace_iterator *iter)
1088+
static void wait_on_pipe(struct trace_iterator *iter)
10891089
{
10901090
/* Iterators are static, they should be filled or empty */
10911091
if (trace_buffer_iter(iter, iter->cpu_file))
@@ -1202,8 +1202,6 @@ int register_tracer(struct tracer *type)
12021202
else
12031203
if (!type->flags->opts)
12041204
type->flags->opts = dummy_tracer_opt;
1205-
if (!type->wait_pipe)
1206-
type->wait_pipe = default_wait_pipe;
12071205

12081206
ret = run_tracer_selftest(type);
12091207
if (ret < 0)
@@ -4207,25 +4205,6 @@ tracing_poll_pipe(struct file *filp, poll_table *poll_table)
42074205
return trace_poll(iter, filp, poll_table);
42084206
}
42094207

4210-
/*
4211-
* This is a make-shift waitqueue.
4212-
* A tracer might use this callback on some rare cases:
4213-
*
4214-
* 1) the current tracer might hold the runqueue lock when it wakes up
4215-
* a reader, hence a deadlock (sched, function, and function graph tracers)
4216-
* 2) the function tracers, trace all functions, we don't want
4217-
* the overhead of calling wake_up and friends
4218-
* (and tracing them too)
4219-
*
4220-
* Anyway, this is really very primitive wakeup.
4221-
*/
4222-
void poll_wait_pipe(struct trace_iterator *iter)
4223-
{
4224-
set_current_state(TASK_INTERRUPTIBLE);
4225-
/* sleep for 100 msecs, and try again. */
4226-
schedule_timeout(HZ / 10);
4227-
}
4228-
42294208
/* Must be called with trace_types_lock mutex held. */
42304209
static int tracing_wait_pipe(struct file *filp)
42314210
{
@@ -4251,7 +4230,7 @@ static int tracing_wait_pipe(struct file *filp)
42514230

42524231
mutex_unlock(&iter->mutex);
42534232

4254-
iter->trace->wait_pipe(iter);
4233+
wait_on_pipe(iter);
42554234

42564235
mutex_lock(&iter->mutex);
42574236

@@ -5179,7 +5158,7 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
51795158
goto out_unlock;
51805159
}
51815160
mutex_unlock(&trace_types_lock);
5182-
iter->trace->wait_pipe(iter);
5161+
wait_on_pipe(iter);
51835162
mutex_lock(&trace_types_lock);
51845163
if (signal_pending(current)) {
51855164
size = -EINTR;
@@ -5390,7 +5369,7 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
53905369
goto out;
53915370
}
53925371
mutex_unlock(&trace_types_lock);
5393-
iter->trace->wait_pipe(iter);
5372+
wait_on_pipe(iter);
53945373
mutex_lock(&trace_types_lock);
53955374
if (signal_pending(current)) {
53965375
ret = -EINTR;

kernel/trace/trace.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ struct tracer_flags {
338338
* @stop: called when tracing is paused (echo 0 > tracing_enabled)
339339
* @open: called when the trace file is opened
340340
* @pipe_open: called when the trace_pipe file is opened
341-
* @wait_pipe: override how the user waits for traces on trace_pipe
342341
* @close: called when the trace file is released
343342
* @pipe_close: called when the trace_pipe file is released
344343
* @read: override the default read callback on trace_pipe
@@ -357,7 +356,6 @@ struct tracer {
357356
void (*stop)(struct trace_array *tr);
358357
void (*open)(struct trace_iterator *iter);
359358
void (*pipe_open)(struct trace_iterator *iter);
360-
void (*wait_pipe)(struct trace_iterator *iter);
361359
void (*close)(struct trace_iterator *iter);
362360
void (*pipe_close)(struct trace_iterator *iter);
363361
ssize_t (*read)(struct trace_iterator *iter,
@@ -566,8 +564,6 @@ void trace_init_global_iter(struct trace_iterator *iter);
566564

567565
void tracing_iter_reset(struct trace_iterator *iter, int cpu);
568566

569-
void poll_wait_pipe(struct trace_iterator *iter);
570-
571567
void tracing_sched_switch_trace(struct trace_array *tr,
572568
struct task_struct *prev,
573569
struct task_struct *next,

kernel/trace/trace_functions.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ static struct tracer function_trace __tracer_data =
252252
.init = function_trace_init,
253253
.reset = function_trace_reset,
254254
.start = function_trace_start,
255-
.wait_pipe = poll_wait_pipe,
256255
.flags = &func_flags,
257256
.set_flag = func_set_flag,
258257
.allow_instances = true,

kernel/trace/trace_functions_graph.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,6 @@ static struct tracer graph_trace __tracer_data = {
15051505
.pipe_open = graph_trace_open,
15061506
.close = graph_trace_close,
15071507
.pipe_close = graph_trace_close,
1508-
.wait_pipe = poll_wait_pipe,
15091508
.init = graph_trace_init,
15101509
.reset = graph_trace_reset,
15111510
.print_line = print_graph_function,

kernel/trace/trace_nop.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ struct tracer nop_trace __read_mostly =
9191
.name = "nop",
9292
.init = nop_trace_init,
9393
.reset = nop_trace_reset,
94-
.wait_pipe = poll_wait_pipe,
9594
#ifdef CONFIG_FTRACE_SELFTEST
9695
.selftest = trace_selftest_startup_nop,
9796
#endif

kernel/trace/trace_sched_wakeup.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@ static struct tracer wakeup_rt_tracer __read_mostly =
705705
.reset = wakeup_tracer_reset,
706706
.start = wakeup_tracer_start,
707707
.stop = wakeup_tracer_stop,
708-
.wait_pipe = poll_wait_pipe,
709708
.print_max = true,
710709
.print_header = wakeup_print_header,
711710
.print_line = wakeup_print_line,
@@ -728,7 +727,6 @@ static struct tracer wakeup_dl_tracer __read_mostly =
728727
.reset = wakeup_tracer_reset,
729728
.start = wakeup_tracer_start,
730729
.stop = wakeup_tracer_stop,
731-
.wait_pipe = poll_wait_pipe,
732730
.print_max = true,
733731
.print_header = wakeup_print_header,
734732
.print_line = wakeup_print_line,

0 commit comments

Comments
 (0)