ring-buffer: Avoid softlockup in ring_buffer_resize()

When user resize all trace ring buffer through file 'buffer_size_kb',
then in ring_buffer_resize(), kernel allocates buffer pages for each
cpu in a loop.

If the kernel preemption model is PREEMPT_NONE and there are many cpus
and there are many buffer pages to be allocated, it may not give up cpu
for a long time and finally cause a softlockup.

To avoid it, call cond_resched() after each cpu buffer allocation.

Link: https://lore.kernel.org/linux-trace-kernel/[email protected]

Cc: <[email protected]>
Signed-off-by: Zheng Yejian <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>
This commit is contained in:
Zheng Yejian authored and Steven Rostedt (Google) committed 2023-09-07 16:38:54 -04:00
1 parent e5c624f027
commit f6bd2c9248
1 file changed
+2
+2
View File
@@ -2198,6 +2198,8 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
err = -ENOMEM;
goto out_err;
}
cond_resched();
}
cpus_read_lock();