From nobody Sun Feb 8 12:18:52 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 4239E21CC51 for ; Tue, 6 Jan 2026 13:47:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767707232; cv=none; b=WNtX0x0dK7CONmmGhRm965jK3bLf8+jzQY7X5YVVuMTDv8p0P/Cz/MK6K8EahEBO/9nLRxqGHUjwqYIW5RoYG2eSHy5Qz4ADHbhZzwyw/pZ+NVEEVMsvfHAKAVSacxE49C5z/Rx3F/q7SuSNx0DPqY/jT9iqJGb/6XlSn31uZ/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767707232; c=relaxed/simple; bh=kLhmG8r8/G/ZBzcMsD21dGTit7z/QexGf+BuN2OdGGU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qaWVLNbx0A6424irFqIZbWttU8KrsOk73NZtlzbOOY/5GD3j5G9R6X19J2C0DpX09zpAiRsk7gUnuJfAqiVwKxbUXZpBeik0cHrtp94JEODekpO9UuIhTLWkvsn28Ij32diJI5+jsue1pl1IbHIP0eglQyjHZV1hWYZe/fqP8BQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=MHApe9ZD; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MHApe9ZD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767707230; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K2MacZa0tkiAD+rR0g1h1MHJtgQHxTFEHFa+WubSNqk=; b=MHApe9ZDjr2DPHn51HOnvOcOmk2YtgeymV0QMCrN2xA0/HU8E2fjyAg+zCvxxGdLyibcDg m+HSlL7RATcTMBHUW2V3Uq9H4thPA80yK5m6Erz6xwgJhBLNk7gwW8mVqeGfOccGiBqJw+ ator3pgG+2ZWtpA5vkivgYID6XKyj9w= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-404-U3IkJEZZNYiniFGAwG_s1A-1; Tue, 06 Jan 2026 08:47:06 -0500 X-MC-Unique: U3IkJEZZNYiniFGAwG_s1A-1 X-Mimecast-MFC-AGG-ID: U3IkJEZZNYiniFGAwG_s1A_1767707225 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 117521956068; Tue, 6 Jan 2026 13:47:05 +0000 (UTC) Received: from wcosta-thinkpadt14gen4.rmtbr.csb (unknown [10.22.89.23]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8A7DD1800367; Tue, 6 Jan 2026 13:47:01 +0000 (UTC) From: Wander Lairson Costa To: Steven Rostedt , Tomas Glozar , Wander Lairson Costa , Crystal Wood , Ivan Pravdin , Costa Shulyupin , John Kacur , Tiezhu Yang , linux-trace-kernel@vger.kernel.org (open list:Real-time Linux Analysis (RTLA) tools), linux-kernel@vger.kernel.org (open list:Real-time Linux Analysis (RTLA) tools), bpf@vger.kernel.org (open list:BPF [MISC]:Keyword:(?:\b|_)bpf(?:\b|_)) Subject: [PATCH v2 15/18] rtla: Make stop_tracing variable volatile Date: Tue, 6 Jan 2026 08:49:51 -0300 Message-ID: <20260106133655.249887-16-wander@redhat.com> In-Reply-To: <20260106133655.249887-1-wander@redhat.com> References: <20260106133655.249887-1-wander@redhat.com> 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 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" The stop_tracing global variable is accessed from both the signal handler context and the main program flow without synchronization. This creates a potential race condition where compiler optimizations could cache the variable value in registers, preventing the signal handler's updates from being visible to other parts of the program. Add the volatile qualifier to stop_tracing in both common.c and common.h to ensure all accesses to this variable bypass compiler optimizations and read directly from memory. This guarantees that when the signal handler sets stop_tracing, the change is immediately visible to the main program loop, preventing potential hangs or delayed shutdown when termination signals are received. Signed-off-by: Wander Lairson Costa --- tools/tracing/rtla/src/common.c | 2 +- tools/tracing/rtla/src/common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/commo= n.c index d608ffe12e7b0..1e6542a1e9630 100644 --- a/tools/tracing/rtla/src/common.c +++ b/tools/tracing/rtla/src/common.c @@ -8,7 +8,7 @@ #include "common.h" =20 struct trace_instance *trace_inst; -int stop_tracing; +volatile int stop_tracing; =20 static void stop_trace(int sig) { diff --git a/tools/tracing/rtla/src/common.h b/tools/tracing/rtla/src/commo= n.h index f2c9e21c03651..283641f3e7c9b 100644 --- a/tools/tracing/rtla/src/common.h +++ b/tools/tracing/rtla/src/common.h @@ -54,7 +54,7 @@ struct osnoise_context { }; =20 extern struct trace_instance *trace_inst; -extern int stop_tracing; +extern volatile int stop_tracing; =20 struct hist_params { char no_irq; --=20 2.52.0