Patch "ring-buffer: Avoid softlockup in ring_buffer_resize()" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ring-buffer: Avoid softlockup in ring_buffer_resize()

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ring-buffer-avoid-softlockup-in-ring_buffer_resize.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9913ee74a5ca8a984732c73f3d824e56e1fd5090
Author: Zheng Yejian <zhengyejian1@xxxxxxxxxx>
Date:   Wed Sep 6 16:19:30 2023 +0800

    ring-buffer: Avoid softlockup in ring_buffer_resize()
    
    [ Upstream commit f6bd2c92488c30ef53b5bd80c52f0a7eee9d545a ]
    
    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/20230906081930.3939106-1-zhengyejian1@xxxxxxxxxx
    
    Cc: <mhiramat@xxxxxxxxxx>
    Signed-off-by: Zheng Yejian <zhengyejian1@xxxxxxxxxx>
    Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index db7cefd196cec..b15d72284c7f7 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2176,6 +2176,8 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
 				err = -ENOMEM;
 				goto out_err;
 			}
+
+			cond_resched();
 		}
 
 		cpus_read_lock();



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux