tracing: Avoid possible softlockup in tracing_iter_reset()

commit 49aa8a1f4d6800721c7971ed383078257f12e8f9 upstream.

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: stable@vger.kernel.org
Fixes: 2f26ebd549 ("tracing: use timestamp to determine start of latency traces")
Link: https://lore.kernel.org/20240827124654.3817443-1-zhengyejian@huaweicloud.com
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Zheng Yejian <zhengyejian@huaweicloud.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Zheng Yejian 2024-08-27 20:46:54 +08:00 коммит произвёл Greg Kroah-Hartman
Родитель 513c8fc189
Коммит 3816867d2f
1 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -4068,6 +4068,8 @@ void tracing_iter_reset(struct trace_iterator *iter, int cpu)
break; break;
entries++; entries++;
ring_buffer_iter_advance(buf_iter); 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; per_cpu_ptr(iter->array_buffer->data, cpu)->skipped_entries = entries;