From nobody Tue Feb 10 02:59:33 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 EBE2677111 for ; Thu, 26 Dec 2024 14:38:37 +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=1735223918; cv=none; b=WNu7K/6SBe1+OFWi1II299wXK75U2W8TGJbfjhsivEGimy+RpVS5dHVliNaUAjpkTp/ZK5HiVjL0abOQuEoKWRxHvRN6Yd5WlLCOpStAZj1jqmVSmuHVqgp+da+mIsZCsiKLH2TeJHpbAM7sKtbovkWUmh+R0MEtx4SIjLicN8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735223918; c=relaxed/simple; bh=6AK9YpB9eAbbbYNfIOUotEypBy9Eyh1nvpV3EcyJs6A=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=DLFEEokipcsxhyTOWmCwIWib1bZHI9CcpfXJDLxFL8ZgFVAafLHuIIb2X7W4SUB+0ZHMTUPylpHQ+MSx2gV8dckjThx9birH7MDx1X2BDn2d2ZIYk1p0/gZHycSaXGMUTesoGdxtVoq3DbqrKDcAMPNkhYZcVHvgjrp/fuDQNs0= 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 93E9FC4CED4; Thu, 26 Dec 2024 14:38:37 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tQp1U-0000000G1tp-24CQ; Thu, 26 Dec 2024 09:39:36 -0500 Message-ID: <20241226143936.343939431@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 26 Dec 2024 09:39:24 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Peter Zijlstra Subject: [for-next][PATCH 10/15] tracing: Switch trace_events_synth.c code over to use guard() References: <20241226143914.397394975@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 There are a couple functions in trace_events_synth.c that have "goto out" or equivalent on error in order to release locks that were taken. This can be error prone or just simply make the code more complex. Switch every location that ends with unlocking a mutex on error over to using the guard(mutex)() infrastructure to let the compiler worry about releasing locks. This makes the code easier to read and understand. Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Peter Zijlstra Link: https://lore.kernel.org/20241219201346.371082515@goodmis.org Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_synth.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_= synth.c index c82b401a294d..e3f7d09e5512 100644 --- a/kernel/trace/trace_events_synth.c +++ b/kernel/trace/trace_events_synth.c @@ -49,16 +49,11 @@ static char *last_cmd; =20 static int errpos(const char *str) { - int ret =3D 0; - - mutex_lock(&lastcmd_mutex); + guard(mutex)(&lastcmd_mutex); if (!str || !last_cmd) - goto out; + return 0; =20 - ret =3D err_pos(last_cmd, str); - out: - mutex_unlock(&lastcmd_mutex); - return ret; + return err_pos(last_cmd, str); } =20 static void last_cmd_set(const char *str) @@ -74,14 +69,12 @@ static void last_cmd_set(const char *str) =20 static void synth_err(u8 err_type, u16 err_pos) { - mutex_lock(&lastcmd_mutex); + guard(mutex)(&lastcmd_mutex); if (!last_cmd) - goto out; + return; =20 tracing_log_err(NULL, "synthetic_events", last_cmd, err_text, err_type, err_pos); - out: - mutex_unlock(&lastcmd_mutex); } =20 static int create_synth_event(const char *raw_command); --=20 2.45.2