public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vincent Donnefort <vdonnefort@google.com>
Subject: [for-next][PATCH 12/13] tracing: Fix snapshot counter going between two tracers that use it
Date: Fri, 23 Feb 2024 09:18:50 -0500	[thread overview]
Message-ID: <20240223141903.347912102@goodmis.org> (raw)
In-Reply-To: 20240223141838.985298316@goodmis.org

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Running the ftrace selftests caused the ring buffer mapping test to fail.
Investigating, I found that the snapshot counter would be incremented
every time a tracer that uses the snapshot is enabled even if the snapshot
was used by the previous tracer.

That is:

 # cd /sys/kernel/tracing
 # echo wakeup_rt > current_tracer
 # echo wakeup_dl > current_tracer
 # echo nop > current_tracer

would leave the snapshot counter at 1 and not zero. That's because the
enabling of wakeup_dl would increment the counter again but the setting
the tracer to nop would only decrement it once.

Do not arm the snapshot for a tracer if the previous tracer already had it
armed.

Link: https://lore.kernel.org/linux-trace-kernel/20240223013344.570525723@goodmis.org

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Vincent Donnefort <vdonnefort@google.com>
Fixes: 16f7e48ffc53a ("tracing: Add snapshot refcount")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index f56b3275c676..1bcfbc21fb3e 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6148,7 +6148,7 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf)
 		tracing_disarm_snapshot(tr);
 	}
 
-	if (t->use_max_tr) {
+	if (!had_max_tr && t->use_max_tr) {
 		ret = tracing_arm_snapshot_locked(tr);
 		if (ret)
 			goto out;
-- 
2.43.0



  parent reply	other threads:[~2024-02-23 14:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23 14:18 [for-next][PATCH 00/13] tracing: Updates for 6.9 Steven Rostedt
2024-02-23 14:18 ` [for-next][PATCH 01/13] tracing/user_events: Prepare find/delete for same name events Steven Rostedt
2024-02-23 14:18 ` [for-next][PATCH 02/13] tracing/user_events: Introduce multi-format events Steven Rostedt
2024-02-23 14:18 ` [for-next][PATCH 03/13] selftests/user_events: Test " Steven Rostedt
2024-02-23 14:18 ` [for-next][PATCH 04/13] tracing/user_events: Document multi-format flag Steven Rostedt
2024-02-23 14:18 ` [for-next][PATCH 05/13] tracing: Use init_utsname()->release Steven Rostedt
2024-02-23 14:18 ` [for-next][PATCH 06/13] NFSD: Fix nfsd_clid_class use of __string_len() macro Steven Rostedt
2024-02-23 14:36   ` Jeff Layton
2024-02-23 15:14     ` Steven Rostedt
2024-02-23 14:18 ` [for-next][PATCH 07/13] drm/i915: Add missing ; to __assign_str() macros in tracepoint code Steven Rostedt
2024-02-23 14:18 ` [for-next][PATCH 08/13] tracing: Rework __assign_str() and __string() to not duplicate getting the string Steven Rostedt
2024-02-23 14:18 ` [for-next][PATCH 09/13] tracing: Do not calculate strlen() twice for __string() fields Steven Rostedt
2024-02-23 14:18 ` [for-next][PATCH 10/13] tracing: Use ? : shortcut in trace macros Steven Rostedt
2024-02-23 14:18 ` [for-next][PATCH 11/13] tracing: Use EVENT_NULL_STR macro instead of open coding "(null)" Steven Rostedt
2024-02-23 14:18 ` Steven Rostedt [this message]
2024-02-23 14:18 ` [for-next][PATCH 13/13] tracing: Decrement the snapshot if the snapshot trigger fails to register Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240223141903.347912102@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=vdonnefort@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox