Patch "tracing: Fix a warning when allocating buffered events fails" has been added to the 6.6-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

    tracing: Fix a warning when allocating buffered events fails

to the 6.6-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:
     tracing-fix-a-warning-when-allocating-buffered-event.patch
and it can be found in the queue-6.6 subdirectory.

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



commit babf3836136486e40f2fa3302d5dca692caa64e5
Author: Petr Pavlu <petr.pavlu@xxxxxxxx>
Date:   Tue Dec 5 17:17:35 2023 +0100

    tracing: Fix a warning when allocating buffered events fails
    
    [ Upstream commit 34209fe83ef8404353f91ab4ea4035dbc9922d04 ]
    
    Function trace_buffered_event_disable() produces an unexpected warning
    when the previous call to trace_buffered_event_enable() fails to
    allocate pages for buffered events.
    
    The situation can occur as follows:
    
    * The counter trace_buffered_event_ref is at 0.
    
    * The soft mode gets enabled for some event and
      trace_buffered_event_enable() is called. The function increments
      trace_buffered_event_ref to 1 and starts allocating event pages.
    
    * The allocation fails for some page and trace_buffered_event_disable()
      is called for cleanup.
    
    * Function trace_buffered_event_disable() decrements
      trace_buffered_event_ref back to 0, recognizes that it was the last
      use of buffered events and frees all allocated pages.
    
    * The control goes back to trace_buffered_event_enable() which returns.
      The caller of trace_buffered_event_enable() has no information that
      the function actually failed.
    
    * Some time later, the soft mode is disabled for the same event.
      Function trace_buffered_event_disable() is called. It warns on
      "WARN_ON_ONCE(!trace_buffered_event_ref)" and returns.
    
    Buffered events are just an optimization and can handle failures. Make
    trace_buffered_event_enable() exit on the first failure and left any
    cleanup later to when trace_buffered_event_disable() is called.
    
    Link: https://lore.kernel.org/all/20231127151248.7232-2-petr.pavlu@xxxxxxxx/
    Link: https://lkml.kernel.org/r/20231205161736.19663-3-petr.pavlu@xxxxxxxx
    
    Fixes: 0fc1b09ff1ff ("tracing: Use temp buffer when filtering events")
    Signed-off-by: Petr Pavlu <petr.pavlu@xxxxxxxx>
    Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a40d6baf101f0..689d063dd2062 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2769,8 +2769,11 @@ void trace_buffered_event_enable(void)
 	for_each_tracing_cpu(cpu) {
 		page = alloc_pages_node(cpu_to_node(cpu),
 					GFP_KERNEL | __GFP_NORETRY, 0);
-		if (!page)
-			goto failed;
+		/* This is just an optimization and can handle failures */
+		if (!page) {
+			pr_err("Failed to allocate event buffer\n");
+			break;
+		}
 
 		event = page_address(page);
 		memset(event, 0, sizeof(*event));
@@ -2784,10 +2787,6 @@ void trace_buffered_event_enable(void)
 			WARN_ON_ONCE(1);
 		preempt_enable();
 	}
-
-	return;
- failed:
-	trace_buffered_event_disable();
 }
 
 static void enable_trace_buffered_event(void *data)




[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