From nobody Sun Feb 8 17:43:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FC3B823D9 for ; Fri, 23 Feb 2024 14:17:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697830; cv=none; b=PkyqrRVIRGLfQqMOmEhw8l/8bVL7/PrhzfZ2c7hkUiQuXZbSgMpgy6MAWeuBuw7MwwjtDE7mCtmNWU2VDpoqsXeM6OROOuNQy2thyjdL4p2GAeX40DOSfFqzcQQyBcQzob73/tJfoApaI5/jnMjMyrUCTlzGN37PPwxX20bRuhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697830; c=relaxed/simple; bh=SSAkBsKZDXS3J7H5zDJ3fM4StROONFq7WOqxGyruuNk=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=JlqaSG1tA/xd47yOlaOmX2UFbXGjNm92lgBga0dgbp8WFFNVrSLccWhZfZhaKL38tVJ9efe0YsPgn68Q1HImqUiY7j0X3H7Sz1fYc4VdYtEx+VzZVHqMm1/goLW+yhYUCfgR/4CQGwthXahSBt0AARjPdXXPODzp1jA9xT0c4OI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80E06C43142; Fri, 23 Feb 2024 14:17:10 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rdWOF-000000077Qf-23xN; Fri, 23 Feb 2024 09:19:03 -0500 Message-ID: <20240223141903.347912102@goodmis.org> User-Agent: quilt/0.67 Date: Fri, 23 Feb 2024 09:18:50 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Vincent Donnefort Subject: [for-next][PATCH 12/13] tracing: Fix snapshot counter going between two tracers that use it References: <20240223141838.985298316@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" 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@g= oodmis.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Vincent Donnefort Fixes: 16f7e48ffc53a ("tracing: Add snapshot refcount") Signed-off-by: Steven Rostedt (Google) --- 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); } =20 - if (t->use_max_tr) { + if (!had_max_tr && t->use_max_tr) { ret =3D tracing_arm_snapshot_locked(tr); if (ret) goto out; --=20 2.43.0