From nobody Sun Feb 8 05:35:36 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 1A9BB2DAFB0 for ; Fri, 23 Jan 2026 15:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769183009; cv=none; b=HZHERrFl7SmxvosnCQ41gP5SesDzrCluPxiPcazVs68kcLNvYv05URhbsrN0K9FGYVA1pGuYh+5D3g8RFIlVxblmBOU/ECyrWl6HZ+boaOyTVzAkM8Ho2P9QFesTqGmy/6r9lCoOLT79MQvF4RMKDpALn9Ze3nmNtquHUZyP42k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769183009; c=relaxed/simple; bh=B1apLdGdbSeS7TZ9uWJagJsoGYG3fb4E+Tmcww/wsEE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k2wJz0I5Q7lmvYMGmyAi7QTePZaNTpmD00F02rg69Q+okmmnfRdJ4s4NOa3aSweLy0HiTDF8w6RTTxNUvva3m1RnP8ZGADwWo/SYgYvYeEmiJk1UWW3FL9+QeZu1V/FONbXE9afKB4/AkNYbPfq3hklBFHsQVef5Nz4eD/yVUJM= 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=aA9hjnu/; arc=none smtp.client-ip=170.10.129.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="aA9hjnu/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769183007; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XChOJQVNTKzLAzN/OE5pi3ush6z4OzNOlNgezYKdP9s=; b=aA9hjnu/YDHz2B0X51NqkabKzrRI0lxvCU04S1YwDOyR96/IiDKKp/BEmG7jsWGW7Py7wn Cb6YtYyH1P/LiRQdzwoe7R4Fo1kY4HgUvAtnSypvrRB3VQAzOFMdifwuB3J8JR6DrInwXk RxUcoBZmA+IIcE1UtYsqd2QasXfrotc= Received: from mx-prod-mc-05.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-9-zzfGPp-TNKqfiHwHjfYDUA-1; Fri, 23 Jan 2026 10:43:23 -0500 X-MC-Unique: zzfGPp-TNKqfiHwHjfYDUA-1 X-Mimecast-MFC-AGG-ID: zzfGPp-TNKqfiHwHjfYDUA_1769183002 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B1ACC1956094; Fri, 23 Jan 2026 15:43:22 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.59]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8DA9018004D8; Fri, 23 Jan 2026 15:43:19 +0000 (UTC) From: Tomas Glozar To: Steven Rostedt , Masami Hiramatsu Cc: Mathieu Desnoyers , Crystal Wood , John Kacur , Luis Goncalves , LKML , Linux Trace Kernel , Tomas Glozar Subject: [RFC PATCH 1/3] tracing/osnoise: Record timerlat instance counts Date: Fri, 23 Jan 2026 16:25:32 +0100 Message-ID: <20260123152534.1036533-2-tglozar@redhat.com> In-Reply-To: <20260123152534.1036533-1-tglozar@redhat.com> References: <20260123152534.1036533-1-tglozar@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" While recording a timerlat sample, track how many timerlat instances are registered at the moment and how many instances have tracing on. This enables a user of the timerlat_sample threshold to synchronize with any users of the timerlat tracer instance buffer. Note that this also reverses the order in which the trace buffer record and the tracepoint are processed: the tracepoint now fires after the trace buffer entries are recorded. Signed-off-by: Tomas Glozar --- include/trace/events/osnoise.h | 14 ++++++++++---- kernel/trace/trace_osnoise.c | 10 ++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/trace/events/osnoise.h b/include/trace/events/osnoise.h index 3f4273623801..50beaf8fbb52 100644 --- a/include/trace/events/osnoise.h +++ b/include/trace/events/osnoise.h @@ -79,26 +79,32 @@ TRACE_EVENT(osnoise_sample, #ifdef CONFIG_TIMERLAT_TRACER TRACE_EVENT(timerlat_sample, =20 - TP_PROTO(struct timerlat_sample *s), + TP_PROTO(struct timerlat_sample *s, int instances_registered, int instanc= es_on), =20 - TP_ARGS(s), + TP_ARGS(s, instances_registered, instances_on), =20 TP_STRUCT__entry( __field( u64, timer_latency ) __field( unsigned int, seqnum ) __field( int, context ) + __field( int, instances_registered ) + __field( int, instances_on ) ), =20 TP_fast_assign( __entry->timer_latency =3D s->timer_latency; __entry->seqnum =3D s->seqnum; __entry->context =3D s->context; + __entry->instances_registered =3D instances_registered; + __entry->instances_on =3D instances_on; ), =20 - TP_printk("timer_latency=3D%llu seqnum=3D%u context=3D%d", + TP_printk("timer_latency=3D%llu seqnum=3D%u context=3D%d instances_regist= ered=3D%d instances_on=3D%d", __entry->timer_latency, __entry->seqnum, - __entry->context) + __entry->context, + __entry->instances_registered, + __entry->instances_on) ); #endif // CONFIG_TIMERLAT_TRACER =20 diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c index 827104d00bc0..65ddc1f49c19 100644 --- a/kernel/trace/trace_osnoise.c +++ b/kernel/trace/trace_osnoise.c @@ -574,15 +574,21 @@ static void record_timerlat_sample(struct timerlat_sa= mple *sample) { struct osnoise_instance *inst; struct trace_buffer *buffer; - - trace_timerlat_sample(sample); + int instances_registered =3D 0; + int instances_on =3D 0; =20 rcu_read_lock(); list_for_each_entry_rcu(inst, &osnoise_instances, list) { + if (tracer_tracing_is_on(inst->tr)) + instances_on++; + instances_registered++; + buffer =3D inst->tr->array_buffer.buffer; __record_timerlat_sample(sample, buffer); } rcu_read_unlock(); + + trace_timerlat_sample(sample, instances_registered, instances_on); } =20 #ifdef CONFIG_STACKTRACE --=20 2.52.0 From nobody Sun Feb 8 05:35:36 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 50C562BEC23 for ; Fri, 23 Jan 2026 15:43:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769183012; cv=none; b=TL4UYeFjJKSrTfUsxirsf8NagivJ6gUoWIDA5SUoYROqVazc4BuPmCk+KMB7q9P6iB5ds3A9oC0fYQlxr04bfh86jhopkrzwhRYkxm8M9V0Jv/EYpX9cf1yZxyeeoIW26TVwwwMSepk7T32vIZmBeYxRPV9Ch07twx5q2aUqfds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769183012; c=relaxed/simple; bh=goOQxHCj2q719asakqaKi2POkVV34ZyBdCHDD6XMC6k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fIRPI1jzwaqVFXpiP8IvWDsAmFiUdYFCR8JQPJKmCoRd2/Pos6q7buz60syH24lbaeroW/PLYGHb5ylWq9CBBwSX0NpspyTNx8FNtEHQrZor4f+YzHEFAMLkRTgP6/R4skIeutXm1m1B59zh+fNfun3boLOfbj7FvEqzK0FUxv8= 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=GToTghO8; arc=none smtp.client-ip=170.10.129.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="GToTghO8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769183010; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7s3CG28SINLAnsPeyywEoMXoWeorpu/T3Sj9MCqAl38=; b=GToTghO8YVY0x97uEismGqr2LTxS9IQjGeG9RIuSThhksW9sfPBJ1d714S19FdEBcvwT0X a+cb+oixSD88uu5qMhDV0MxjIMcjrJtiwMZkekeAtinx0zUBIwiP0vT+RW2hHxxMwtNpVG +b4KH1U2LCH28G3wczoY/LLRpEcpb/Q= 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-689-8k_52l5XOVey1j8YxvzLpg-1; Fri, 23 Jan 2026 10:43:27 -0500 X-MC-Unique: 8k_52l5XOVey1j8YxvzLpg-1 X-Mimecast-MFC-AGG-ID: 8k_52l5XOVey1j8YxvzLpg_1769183006 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 1E9D81956054; Fri, 23 Jan 2026 15:43:26 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.59]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 352321800998; Fri, 23 Jan 2026 15:43:22 +0000 (UTC) From: Tomas Glozar To: Steven Rostedt , Masami Hiramatsu Cc: Mathieu Desnoyers , Crystal Wood , John Kacur , Luis Goncalves , LKML , Linux Trace Kernel , Tomas Glozar Subject: [RFC PATCH 2/3] rtla/timerlat_bpf: Filter samples unseen by tracer Date: Fri, 23 Jan 2026 16:25:33 +0100 Message-ID: <20260123152534.1036533-3-tglozar@redhat.com> In-Reply-To: <20260123152534.1036533-1-tglozar@redhat.com> References: <20260123152534.1036533-1-tglozar@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" If both BPF and tracefs sample collection are used (mixed mode), drop samples seen by BPF program when the count of timerlat instances that are both registered and have tracing on does not match the expected value. This ensures that there are no samples seen by BPF that are not included in auto-analysis or trace output. Signed-off-by: Tomas Glozar --- tools/tracing/rtla/src/timerlat.bpf.c | 9 +++++++++ tools/tracing/rtla/src/timerlat.c | 18 +++++++++++++++++- tools/tracing/rtla/src/timerlat.h | 2 ++ tools/tracing/rtla/src/timerlat_bpf.c | 8 ++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tools/tracing/rtla/src/timerlat.bpf.c b/tools/tracing/rtla/src= /timerlat.bpf.c index 549d2d2191d2..2724a9bfea4e 100644 --- a/tools/tracing/rtla/src/timerlat.bpf.c +++ b/tools/tracing/rtla/src/timerlat.bpf.c @@ -12,6 +12,8 @@ char LICENSE[] SEC("license") =3D "GPL"; struct trace_event_raw_timerlat_sample { unsigned long long timer_latency; int context; + int instances_registered; + int instances_on; } __attribute__((preserve_access_index)); =20 struct { @@ -58,6 +60,8 @@ const volatile int entries =3D 256; const volatile int irq_threshold; const volatile int thread_threshold; const volatile bool aa_only; +const volatile int instances_registered =3D -1; +const volatile int instances_on =3D -1; =20 nosubprog unsigned long long map_get(void *map, unsigned int key) @@ -143,6 +147,11 @@ int handle_timerlat_sample(struct trace_event_raw_time= rlat_sample *tp_args) unsigned long long latency, latency_us; int bucket; =20 + if ((instances_registered !=3D -1 && tp_args->instances_registered !=3D i= nstances_registered) + || (instances_on !=3D -1 && tp_args->instances_on !=3D instances_on)) + /* This sample is not seen by all trace instances, filter it out */ + return 0; + if (map_get(&stop_tracing, 0)) return 0; =20 diff --git a/tools/tracing/rtla/src/timerlat.c b/tools/tracing/rtla/src/tim= erlat.c index 8f8811f7a13b..069f916100e7 100644 --- a/tools/tracing/rtla/src/timerlat.c +++ b/tools/tracing/rtla/src/timerlat.c @@ -28,6 +28,7 @@ int timerlat_apply_config(struct osnoise_tool *tool, struct timerlat_params *p= arams) { int retval; + struct tep_event *event =3D NULL; =20 /* * Try to enable BPF, unless disabled explicitly. @@ -36,10 +37,25 @@ timerlat_apply_config(struct osnoise_tool *tool, struct= timerlat_params *params) if (getenv("RTLA_NO_BPF") && strncmp(getenv("RTLA_NO_BPF"), "1", 2) =3D= =3D 0) { debug_msg("RTLA_NO_BPF set, disabling BPF\n"); params->mode =3D TRACING_MODE_TRACEFS; - } else if (!tep_find_event_by_name(tool->trace.tep, "osnoise", "timerlat_= sample")) { + } else if (!(event =3D tep_find_event_by_name(tool->trace.tep, "osnoise",= "timerlat_sample"))) { debug_msg("osnoise:timerlat_sample missing, disabling BPF\n"); params->mode =3D TRACING_MODE_TRACEFS; + } + + if (event && tep_find_field(event, "instances_registered") && + tep_find_field(event, "instances_on")) { + params->has_instance_count_fields =3D true; + + if (!params->no_aa) + params->instances_on++; + if (params->common.threshold_actions.present[ACTION_TRACE_OUTPUT] || + params->common.end_actions.present[ACTION_TRACE_OUTPUT]) + params->instances_on++; } else { + params->has_instance_count_fields =3D false; + } + + if (params->mode !=3D TRACING_MODE_TRACEFS) { retval =3D timerlat_bpf_init(params); if (retval) { debug_msg("Could not enable BPF\n"); diff --git a/tools/tracing/rtla/src/timerlat.h b/tools/tracing/rtla/src/tim= erlat.h index 8dd5d134ce08..ef97e545c7ff 100644 --- a/tools/tracing/rtla/src/timerlat.h +++ b/tools/tracing/rtla/src/timerlat.h @@ -28,6 +28,8 @@ struct timerlat_params { int deepest_idle_state; enum timerlat_tracing_mode mode; const char *bpf_action_program; + bool has_instance_count_fields; + int instances_on; }; =20 #define to_timerlat_params(ptr) container_of(ptr, struct timerlat_params, = common) diff --git a/tools/tracing/rtla/src/timerlat_bpf.c b/tools/tracing/rtla/src= /timerlat_bpf.c index 05adf18303df..80801796bbf0 100644 --- a/tools/tracing/rtla/src/timerlat_bpf.c +++ b/tools/tracing/rtla/src/timerlat_bpf.c @@ -53,6 +53,14 @@ int timerlat_bpf_init(struct timerlat_params *params) bpf_map__set_autocreate(bpf->maps.summary_user, false); } =20 + if (params->mode =3D=3D TRACING_MODE_MIXED && params->has_instance_count_= fields) { + bpf->rodata->instances_on =3D params->instances_on; + bpf->rodata->instances_registered =3D params->instances_on + 1; /* +1 fo= r the main instance */ + } else { + bpf->rodata->instances_registered =3D -1; + bpf->rodata->instances_on =3D -1; + } + /* Load and verify BPF program */ err =3D timerlat_bpf__load(bpf); if (err) { --=20 2.52.0 From nobody Sun Feb 8 05:35:36 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 574872DFF1D for ; Fri, 23 Jan 2026 15:43:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769183020; cv=none; b=GuZHhkrtBvyJ2v/ONJ7alqOKbWX33ACpVz0GtpPe9LPxPYGjYPlVxKd02EJFSG8FflSMUvjI3Im5lWAIj/x8OITgAbOabUgZ9CyBgcP7GQAs+c8lr0QpqBGrltSdS1k1IGfRaQRJdVoVTXZCLAyjCbcJ2NCJ6tLx0AepHROsQvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769183020; c=relaxed/simple; bh=9LoUwfXrMrjPUPnHDS7DWd0SWwF3Ha/G4b/0MLy344w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P74VeTfOztSdkPXYzi2ShIAzeHa54R2r9cGB7IoVAylMpXnNUlV4M1Ax0bTVdxhJ+6YPqUaLTXZhFyEbr+I0mM4w2AcZpRWp1oBuOGWefEmBTLzY6qZddZv3Vqr+av7XL5YMLDOPXihjaEYIrmVwbgaTjBOt+mYKrykHSVv25Ec= 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=VlX8mOvq; arc=none smtp.client-ip=170.10.129.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="VlX8mOvq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769183015; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LTMLV/ktvUIYmallXY3510Gw9B5viJgJMKNSmr/W1f8=; b=VlX8mOvqyrNK2Xzw+xs551NyqB6TY4WtO6UjwKGsNk4K3tyV5wLThTkmdCTlsgJlDN6xCm DblAEtm9C28mgORp6k5fy4IK8vLxjm9IGj1xzTNe/GSNtNkcWDBCFSHpNp2n5hR2QWQ0Io q4iHzH9TMOZaPo5f67oL0HJVQofbu1A= 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-437-YpqCMGX4Mo-jaOX6q2FnSQ-1; Fri, 23 Jan 2026 10:43:30 -0500 X-MC-Unique: YpqCMGX4Mo-jaOX6q2FnSQ-1 X-Mimecast-MFC-AGG-ID: YpqCMGX4Mo-jaOX6q2FnSQ_1769183009 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 BC4E41955D80; Fri, 23 Jan 2026 15:43:29 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.59]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AAB6718004D8; Fri, 23 Jan 2026 15:43:26 +0000 (UTC) From: Tomas Glozar To: Steven Rostedt , Masami Hiramatsu Cc: Mathieu Desnoyers , Crystal Wood , John Kacur , Luis Goncalves , LKML , Linux Trace Kernel , Tomas Glozar Subject: [RFC PATCH 3/3] rtla/timerlat: Attach BPF program before tracers Date: Fri, 23 Jan 2026 16:25:34 +0100 Message-ID: <20260123152534.1036533-4-tglozar@redhat.com> In-Reply-To: <20260123152534.1036533-1-tglozar@redhat.com> References: <20260123152534.1036533-1-tglozar@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" If osnoise:timerlat_sample has instance count fields, attach the BPF program before starting trace instances in BPF/mixed mode. This ensures that what is seen by BPF sample collection is exactly what is seen by the last enabled tracefs instance. Signed-off-by: Tomas Glozar --- tools/tracing/rtla/src/timerlat.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/tracing/rtla/src/timerlat.c b/tools/tracing/rtla/src/tim= erlat.c index 069f916100e7..da2e2d003ec9 100644 --- a/tools/tracing/rtla/src/timerlat.c +++ b/tools/tracing/rtla/src/timerlat.c @@ -170,6 +170,21 @@ int timerlat_enable(struct osnoise_tool *tool) return -1; } =20 + if (params->mode !=3D TRACING_MODE_TRACEFS && params->has_instance_count_= fields) { + /* + * If the timerlat tracer has instance count fields, it is safe + * to attach the BPF program before starting the trace instances. + * + * The BPF program will ignore any samples that arrive before + * the trace instances are started. + */ + retval =3D timerlat_bpf_attach(); + if (retval) { + err_msg("Error attaching BPF program\n"); + return retval; + } + } + /* * Start the tracers here, after having set all instances. * @@ -183,7 +198,15 @@ int timerlat_enable(struct osnoise_tool *tool) trace_instance_start(&tool->aa->trace); if (params->mode =3D=3D TRACING_MODE_TRACEFS) { trace_instance_start(&tool->trace); - } else { + } else if (!params->has_instance_count_fields) { + /* + * Without instance count fields, play safe and attach the BPF program + * after starting the trace instances. + * + * This might lead to samples being seen only by trace output and + * auto analysis, but it is better than RTLA reporting results over + * threshold that cannot be analyzed further. + */ retval =3D timerlat_bpf_attach(); if (retval) { err_msg("Error attaching BPF program\n"); --=20 2.52.0