Skip to content

Commit 49aa8a1

Browse files
Zheng Yejianrostedt
authored andcommitted
tracing: Avoid possible softlockup in tracing_iter_reset()
In __tracing_open(), when max latency tracers took place on the cpu, the time start of its buffer would be updated, then event entries with timestamps being earlier than start of the buffer would be skipped (see tracing_iter_reset()). Softlockup will occur if the kernel is non-preemptible and too many entries were skipped in the loop that reset every cpu buffer, so add cond_resched() to avoid it. Cc: [email protected] Fixes: 2f26ebd ("tracing: use timestamp to determine start of latency traces") Link: https://lore.kernel.org/[email protected] Suggested-by: Steven Rostedt <[email protected]> Signed-off-by: Zheng Yejian <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent bc754cc commit 49aa8a1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/trace/trace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3958,6 +3958,8 @@ void tracing_iter_reset(struct trace_iterator *iter, int cpu)
39583958
break;
39593959
entries++;
39603960
ring_buffer_iter_advance(buf_iter);
3961+
/* This could be a big loop */
3962+
cond_resched();
39613963
}
39623964

39633965
per_cpu_ptr(iter->array_buffer->data, cpu)->skipped_entries = entries;

0 commit comments

Comments
 (0)