diff options
author | Zheng Yejian <[email protected]> | 2024-08-27 20:46:54 +0800 |
---|---|---|
committer | Steven Rostedt (Google) <[email protected]> | 2024-09-05 10:18:48 -0400 |
commit | 49aa8a1f4d6800721c7971ed383078257f12e8f9 (patch) | |
tree | 59e72d4260bf75cc3d79a91feaa408a68f51b8b1 | |
parent | bc754cc76d1bbc87be5d8b7eee05ceb0ae613bce (diff) |
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: 2f26ebd549b9a ("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]>
-rw-r--r-- | kernel/trace/trace.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index ebe7ce2f5f4a..edf6bc817aa1 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -3958,6 +3958,8 @@ void tracing_iter_reset(struct trace_iterator *iter, int cpu) break; entries++; ring_buffer_iter_advance(buf_iter); + /* This could be a big loop */ + cond_resched(); } per_cpu_ptr(iter->array_buffer->data, cpu)->skipped_entries = entries; |