Patch "tracing: Do not free snapshot if tracer is on cmdline" has been added to the 5.19-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: Do not free snapshot if tracer is on cmdline

to the 5.19-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-do-not-free-snapshot-if-tracer-is-on-cmdline.patch
and it can be found in the queue-5.19 subdirectory.

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


>From a541a9559bb0a8ecc434de01d3e4826c32e8bb53 Mon Sep 17 00:00:00 2001
From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>
Date: Wed, 5 Oct 2022 11:37:57 -0400
Subject: tracing: Do not free snapshot if tracer is on cmdline

From: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>

commit a541a9559bb0a8ecc434de01d3e4826c32e8bb53 upstream.

The ftrace_boot_snapshot and alloc_snapshot cmdline options allocate the
snapshot buffer at boot up for use later. The ftrace_boot_snapshot in
particular requires the snapshot to be allocated because it will take a
snapshot at the end of boot up allowing to see the traces that happened
during boot so that it's not lost when user space takes over.

When a tracer is registered (started) there's a path that checks if it
requires the snapshot buffer or not, and if it does not and it was
allocated it will do a synchronization and free the snapshot buffer.

This is only required if the previous tracer was using it for "max
latency" snapshots, as it needs to make sure all max snapshots are
complete before freeing. But this is only needed if the previous tracer
was using the snapshot buffer for latency (like irqoff tracer and
friends). But it does not make sense to free it, if the previous tracer
was not using it, and the snapshot was allocated by the cmdline
parameters. This basically takes away the point of allocating it in the
first place!

Note, the allocated snapshot worked fine for just trace events, but fails
when a tracer is enabled on the cmdline.

Further investigation, this goes back even further and it does not require
a tracer on the cmdline to fail. Simply enable snapshots and then enable a
tracer, and it will remove the snapshot.

Link: https://lkml.kernel.org/r/20221005113757.041df7fe@xxxxxxxxxxxxxxxxxx

Cc: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
Fixes: 45ad21ca5530 ("tracing: Have trace_array keep track if snapshot buffer is allocated")
Reported-by: Ross Zwisler <zwisler@xxxxxxxxxx>
Tested-by: Ross Zwisler <zwisler@xxxxxxxxxx>
Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 kernel/trace/trace.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6428,12 +6428,12 @@ int tracing_set_tracer(struct trace_arra
 	if (tr->current_trace->reset)
 		tr->current_trace->reset(tr);
 
+#ifdef CONFIG_TRACER_MAX_TRACE
+	had_max_tr = tr->current_trace->use_max_tr;
+
 	/* Current trace needs to be nop_trace before synchronize_rcu */
 	tr->current_trace = &nop_trace;
 
-#ifdef CONFIG_TRACER_MAX_TRACE
-	had_max_tr = tr->allocated_snapshot;
-
 	if (had_max_tr && !t->use_max_tr) {
 		/*
 		 * We need to make sure that the update_max_tr sees that
@@ -6446,11 +6446,13 @@ int tracing_set_tracer(struct trace_arra
 		free_snapshot(tr);
 	}
 
-	if (t->use_max_tr && !had_max_tr) {
+	if (t->use_max_tr && !tr->allocated_snapshot) {
 		ret = tracing_alloc_snapshot_instance(tr);
 		if (ret < 0)
 			goto out;
 	}
+#else
+	tr->current_trace = &nop_trace;
 #endif
 
 	if (t->init) {


Patches currently in stable-queue which might be from rostedt@xxxxxxxxxxx are

queue-5.19/tracing-fix-reading-strings-from-synthetic-events.patch
queue-5.19/tracing-add-ioctl-to-force-ring-buffer-waiters-to-wake-up.patch
queue-5.19/ring-buffer-have-the-shortest_full-queue-be-the-shortest-not-longest.patch
queue-5.19/ring-buffer-add-ring_buffer_wake_waiters.patch
queue-5.19/tracing-move-duplicate-code-of-trace_kprobe-eprobe.c-into-header.patch
queue-5.19/tracing-add-fault-name-injection-to-kernel-probes.patch
queue-5.19/ring-buffer-fix-race-between-reset-page-and-reading-page.patch
queue-5.19/tracing-wake-up-ring-buffer-waiters-on-closing-of-the-file.patch
queue-5.19/ftrace-still-disable-enabled-records-marked-as-disabled.patch
queue-5.19/tracing-disable-interrupt-or-preemption-before-acquiring-arch_spinlock_t.patch
queue-5.19/tracing-do-not-free-snapshot-if-tracer-is-on-cmdline.patch
queue-5.19/tracing-wake-up-waiters-when-tracing-is-disabled.patch
queue-5.19/ring-buffer-allow-splice-to-read-previous-partially-read-pages.patch
queue-5.19/ring-buffer-check-pending-waiters-when-doing-wake-ups-as-well.patch
queue-5.19/ftrace-properly-unset-ftrace_hash_fl_mod.patch



[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