From nobody Sat Feb 7 18:20:18 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 F2173335062 for ; Fri, 17 Oct 2025 14:47:19 +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=1760712441; cv=none; b=nIwjaKQwnPfRtvpILJ64UYc8WmWb21S+XLaABqb0RkjEH89aP7RZYxS6cukD53h22U4UJyTBhErAO5tbJlZEPBQs4yIjI8NNI8y3f2LwlkoEFsbFujHrgwqDB7KXIGImCaZM1FU6tCKKMmxSkgmA3YkuMNg0MqigHfNImvUChuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760712441; c=relaxed/simple; bh=rGu5A3OU4ZSpORG0UAOqi+ojq3qcrJOfyOMyESOti20=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PIzBjRNSHIB4hx1teBUIp2d6XdKk/AVMtA5HLArVmR0aWVPlynhaFQHf2f2yj2WnHr+dBUsw8H3el3kss/PeWIrNh3/mfTsPI7KTYwAaAnKQ6HZkhZqV1MrgeEaWnH0Tbvtkxmlw3gRtyWpKYkKy//h6qZtfVocp8aFFL4duRwk= 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=GFxavFrO; 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="GFxavFrO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760712439; 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=mb0dB1veQuyN7Er4i7PkFCiU6cwrLRWf+Zv8v4WzqA0=; b=GFxavFrONddI9Wghkp0xGuib94bITu6OGq8/tJgQN3zNp4LQrK5lcHpV0sXFHwixiyHLQ4 SIopocZjYVwyJs0d2zM5TVkQ9rAfZCdEOmcdm3sXnQ+Xx7ORasJ5rwCMd1TKVTFP9CeZmi FKb0gGb0uCv80rucyfFB1/2HNU9SJtE= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-194-bvfLuctGN6iLm61LYnhsgg-1; Fri, 17 Oct 2025 10:47:15 -0400 X-MC-Unique: bvfLuctGN6iLm61LYnhsgg-1 X-Mimecast-MFC-AGG-ID: bvfLuctGN6iLm61LYnhsgg_1760712434 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B0BF71800675; Fri, 17 Oct 2025 14:47:14 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.32.24]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 68296180044F; Fri, 17 Oct 2025 14:47:11 +0000 (UTC) From: Tomas Glozar To: Steven Rostedt Cc: LKML , Linux Trace Kernel , John Kacur , Luis Goncalves , Costa Shulyupin , Crystal Wood , Wander Lairson Costa , Arnaldo Carvalho de Melo , Tomas Glozar Subject: [PATCH 1/4] rtla/timerlat: Support tail call from BPF program Date: Fri, 17 Oct 2025 16:46:47 +0200 Message-ID: <20251017144650.663238-2-tglozar@redhat.com> In-Reply-To: <20251017144650.663238-1-tglozar@redhat.com> References: <20251017144650.663238-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.111 Content-Type: text/plain; charset="utf-8" Add a map to the rtla-timerlat BPF program that holds a file descriptor of another BPF program, to be executed on threshold overflow. timerlat_bpf_set_action() is added as an interface to set the program. Signed-off-by: Tomas Glozar --- tools/tracing/rtla/src/timerlat.bpf.c | 23 ++++++++++++++++++++--- tools/tracing/rtla/src/timerlat_bpf.c | 13 +++++++++++++ tools/tracing/rtla/src/timerlat_bpf.h | 1 + 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat.bpf.c b/tools/tracing/rtla/src= /timerlat.bpf.c index 084cd10c21fc..19ccd9abf8d4 100644 --- a/tools/tracing/rtla/src/timerlat.bpf.c +++ b/tools/tracing/rtla/src/timerlat.bpf.c @@ -40,6 +40,17 @@ struct { __uint(max_entries, 1); } signal_stop_tracing SEC(".maps"); =20 +struct { + __uint(type, BPF_MAP_TYPE_PROG_ARRAY); + __uint(key_size, sizeof(unsigned int)); + __uint(max_entries, 1); + __array(values, unsigned int (void *)); +} bpf_action SEC(".maps") =3D { + .values =3D { + [0] =3D 0 + }, +}; + /* Params to be set by rtla */ const volatile int bucket_size =3D 1; const volatile int output_divisor =3D 1000; @@ -109,7 +120,7 @@ nosubprog void update_summary(void *map, map_set(map, SUMMARY_SUM, map_get(map, SUMMARY_SUM) + latency); } =20 -nosubprog void set_stop_tracing(void) +nosubprog void set_stop_tracing(struct trace_event_raw_timerlat_sample *tp= _args) { int value =3D 0; =20 @@ -118,6 +129,12 @@ nosubprog void set_stop_tracing(void) =20 /* Signal to userspace */ bpf_ringbuf_output(&signal_stop_tracing, &value, sizeof(value), 0); + + /* + * Call into BPF action program, if attached. + * Otherwise, just silently fail. + */ + bpf_tail_call(tp_args, &bpf_action, 0); } =20 SEC("tp/osnoise/timerlat_sample") @@ -138,13 +155,13 @@ int handle_timerlat_sample(struct trace_event_raw_tim= erlat_sample *tp_args) update_summary(&summary_irq, latency, bucket); =20 if (irq_threshold !=3D 0 && latency_us >=3D irq_threshold) - set_stop_tracing(); + set_stop_tracing(tp_args); } else if (tp_args->context =3D=3D 1) { update_main_hist(&hist_thread, bucket); update_summary(&summary_thread, latency, bucket); =20 if (thread_threshold !=3D 0 && latency_us >=3D thread_threshold) - set_stop_tracing(); + set_stop_tracing(tp_args); } else { update_main_hist(&hist_user, bucket); update_summary(&summary_user, latency, bucket); diff --git a/tools/tracing/rtla/src/timerlat_bpf.c b/tools/tracing/rtla/src= /timerlat_bpf.c index e97d16646bcd..1d619e502c65 100644 --- a/tools/tracing/rtla/src/timerlat_bpf.c +++ b/tools/tracing/rtla/src/timerlat_bpf.c @@ -59,6 +59,19 @@ int timerlat_bpf_init(struct timerlat_params *params) return 0; } =20 +/* + * timerlat_bpf_set_action - set action on threshold executed on BPF side + */ +static int timerlat_bpf_set_action(struct bpf_program *prog) +{ + unsigned int key =3D 0, value =3D bpf_program__fd(prog); + + return bpf_map__update_elem(bpf->maps.bpf_action, + &key, sizeof(key), + &value, sizeof(value), + BPF_ANY); +} + /* * timerlat_bpf_attach - attach BPF program to collect timerlat data */ diff --git a/tools/tracing/rtla/src/timerlat_bpf.h b/tools/tracing/rtla/src= /timerlat_bpf.h index 118487436d30..b5009092c7a3 100644 --- a/tools/tracing/rtla/src/timerlat_bpf.h +++ b/tools/tracing/rtla/src/timerlat_bpf.h @@ -12,6 +12,7 @@ enum summary_field { }; =20 #ifndef __bpf__ +#include #ifdef HAVE_BPF_SKEL int timerlat_bpf_init(struct timerlat_params *params); int timerlat_bpf_attach(void); --=20 2.51.0 From nobody Sat Feb 7 18:20:18 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 67222335075 for ; Fri, 17 Oct 2025 14:47:21 +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=1760712443; cv=none; b=GYvmJe3F5wYdt2YEIeWiM35ffXGT7+CFu35U2FjgpNuOwHgnFEQ0uph7CsMlV8U8slg4IDfea4aSDdjRoe1qgJYP4sA56FX3wKeHnIyDr+QOpzK9wWwZbClGP6b0kRM0hXtqzZqIUMjTT4TB9W/5zZxb0P17Lg7gekbaUmqaKog= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760712443; c=relaxed/simple; bh=Dgd+l3pCcDMnmxhnKz9B7VjOyqW2djhLzE6UYChDPck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X/vyW5hjwI7keKQ6ME8vQrqXAa57iK/l2dA7tPGTvAbbGShLz6UcRhSxtbjKUDYYQRJjS9bx9uza3zhhVic8q/3AM7a+OUrqIKJ984C3cALDwWEl1wCu1CEro31ZPYOrK7z2I2fWog5zjCvGkuMPvtJxuj/widfg91aL5bBRqdE= 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=iMdFv7d8; 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="iMdFv7d8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760712440; 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=FZVwvtyNqsIzzjoNvH4aAIMQ2MEEUWR/Rn3UkgTbh74=; b=iMdFv7d82eu4dZHgA1gShw/W07J3uK+yt80XZbm9BzZcqoLqlKiFQrlqYE5lqu7jFUwD8r 8LSni46msO6qfA7BNDyF5CUulfKtVNEnOspmRYFBPifzhsk2I/P0Z16gyxuxsclsJnIRCI aT9fpt9CCC07kH94IMtWRJbgI/v2hc4= 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-481-9HcKxReBOPyrtsgM3CZuPg-1; Fri, 17 Oct 2025 10:47:19 -0400 X-MC-Unique: 9HcKxReBOPyrtsgM3CZuPg-1 X-Mimecast-MFC-AGG-ID: 9HcKxReBOPyrtsgM3CZuPg_1760712438 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 2542A195608A; Fri, 17 Oct 2025 14:47:18 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.32.24]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 34A351800452; Fri, 17 Oct 2025 14:47:14 +0000 (UTC) From: Tomas Glozar To: Steven Rostedt Cc: LKML , Linux Trace Kernel , John Kacur , Luis Goncalves , Costa Shulyupin , Crystal Wood , Wander Lairson Costa , Arnaldo Carvalho de Melo , Tomas Glozar Subject: [PATCH 2/4] rtla/timerlat: Add --bpf-action option Date: Fri, 17 Oct 2025 16:46:48 +0200 Message-ID: <20251017144650.663238-3-tglozar@redhat.com> In-Reply-To: <20251017144650.663238-1-tglozar@redhat.com> References: <20251017144650.663238-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.111 Content-Type: text/plain; charset="utf-8" Add option --bpf-action that allows the user to attach an external BPF program that will be executed via BPF tail call on latency threshold overflow. Executing additional BPF code on latency threshold overflow allows doing doing low-latency and in-kernel troubleshooting of the cause of the overflow. The option takes an argument, which is a path to a BPF ELF file expected to contain a function named "action_handler" in a section named "tp/timerlat_action" (the section is necessary for libbpf to asssign the correct BPF program type to it). Signed-off-by: Tomas Glozar --- tools/tracing/rtla/src/timerlat.c | 11 ++++++ tools/tracing/rtla/src/timerlat.h | 2 +- tools/tracing/rtla/src/timerlat_bpf.c | 54 ++++++++++++++++++++++++++ tools/tracing/rtla/src/timerlat_bpf.h | 6 ++- tools/tracing/rtla/src/timerlat_hist.c | 5 +++ tools/tracing/rtla/src/timerlat_top.c | 5 +++ 6 files changed, 81 insertions(+), 2 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat.c b/tools/tracing/rtla/src/tim= erlat.c index b69212874127..6907a323f9ec 100644 --- a/tools/tracing/rtla/src/timerlat.c +++ b/tools/tracing/rtla/src/timerlat.c @@ -48,6 +48,17 @@ timerlat_apply_config(struct osnoise_tool *tool, struct = timerlat_params *params) } } =20 + /* Check if BPF action program is requested but BPF is not available */ + if (params->bpf_action_program) { + if (params->mode =3D=3D TRACING_MODE_TRACEFS) { + err_msg("BPF actions are not supported in tracefs-only mode\n"); + goto out_err; + } + + if (timerlat_load_bpf_action_program(params->bpf_action_program)) + goto out_err; + } + if (params->mode !=3D TRACING_MODE_BPF) { /* * In tracefs and mixed mode, timerlat tracer handles stopping diff --git a/tools/tracing/rtla/src/timerlat.h b/tools/tracing/rtla/src/tim= erlat.h index fd6065f48bb7..8dd5d134ce08 100644 --- a/tools/tracing/rtla/src/timerlat.h +++ b/tools/tracing/rtla/src/timerlat.h @@ -27,6 +27,7 @@ struct timerlat_params { int dump_tasks; int deepest_idle_state; enum timerlat_tracing_mode mode; + const char *bpf_action_program; }; =20 #define to_timerlat_params(ptr) container_of(ptr, struct timerlat_params, = common) @@ -36,4 +37,3 @@ int timerlat_main(int argc, char *argv[]); int timerlat_enable(struct osnoise_tool *tool); void timerlat_analyze(struct osnoise_tool *tool, bool stopped); void timerlat_free(struct osnoise_tool *tool); - diff --git a/tools/tracing/rtla/src/timerlat_bpf.c b/tools/tracing/rtla/src= /timerlat_bpf.c index 1d619e502c65..3c63bf7aa607 100644 --- a/tools/tracing/rtla/src/timerlat_bpf.c +++ b/tools/tracing/rtla/src/timerlat_bpf.c @@ -7,6 +7,10 @@ =20 static struct timerlat_bpf *bpf; =20 +/* BPF object and program for action program */ +static struct bpf_object *obj; +static struct bpf_program *prog; + /* * timerlat_bpf_init - load and initialize BPF program to collect timerlat= data */ @@ -56,6 +60,10 @@ int timerlat_bpf_init(struct timerlat_params *params) return err; } =20 + /* Set BPF action program to NULL */ + prog =3D NULL; + obj =3D NULL; + return 0; } =20 @@ -96,6 +104,11 @@ void timerlat_bpf_detach(void) void timerlat_bpf_destroy(void) { timerlat_bpf__destroy(bpf); + bpf =3D NULL; + if (obj) + bpf_object__close(obj); + obj =3D NULL; + prog =3D NULL; } =20 static int handle_rb_event(void *ctx, void *data, size_t data_sz) @@ -190,4 +203,45 @@ int timerlat_bpf_get_summary_value(enum summary_field = key, bpf->maps.summary_user, key, value_irq, value_thread, value_user, cpus); } + +/* + * timerlat_load_bpf_action_program - load and register a BPF action progr= am + */ +int timerlat_load_bpf_action_program(const char *program_path) +{ + int err; + + obj =3D bpf_object__open_file(program_path, NULL); + if (!obj) { + err_msg("Failed to open BPF action program: %s\n", program_path); + return -1; + } + + err =3D bpf_object__load(obj); + if (err) { + err_msg("Failed to load BPF action program: %s\n", program_path); + return -1; + } + + prog =3D bpf_object__find_program_by_name(obj, "action_handler"); + if (!prog) { + err_msg("BPF action program must have 'action_handler' function: %s\n", + program_path); + bpf_object__close(obj); + obj =3D NULL; + return -1; + } + + err =3D timerlat_bpf_set_action(prog); + if (err) { + err_msg("Failed to register BPF action program: %s\n", program_path); + bpf_object__close(obj); + obj =3D NULL; + prog =3D NULL; + return -1; + } + + return 0; +} + #endif /* HAVE_BPF_SKEL */ diff --git a/tools/tracing/rtla/src/timerlat_bpf.h b/tools/tracing/rtla/src= /timerlat_bpf.h index b5009092c7a3..169abeaf4363 100644 --- a/tools/tracing/rtla/src/timerlat_bpf.h +++ b/tools/tracing/rtla/src/timerlat_bpf.h @@ -30,7 +30,7 @@ int timerlat_bpf_get_summary_value(enum summary_field key, long long *value_thread, long long *value_user, int cpus); - +int timerlat_load_bpf_action_program(const char *program_path); static inline int have_libbpf_support(void) { return 1; } #else static inline int timerlat_bpf_init(struct timerlat_params *params) @@ -58,6 +58,10 @@ static inline int timerlat_bpf_get_summary_value(enum su= mmary_field key, { return -1; } +static inline int timerlat_load_bpf_action_program(const char *program_pat= h) +{ + return -1; +} static inline int have_libbpf_support(void) { return 0; } #endif /* HAVE_BPF_SKEL */ #endif /* __bpf__ */ diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index 606c1688057b..5e639cc34f64 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -763,6 +763,7 @@ static void timerlat_hist_usage(char *usage) " --deepest-idle-state n: only go down to idle state n on cpus used= by timerlat to reduce exit from idle latency", " --on-threshold : define action to be executed at latency = threshold, multiple are allowed", " --on-end : define action to be executed at measurement en= d, multiple are allowed", + " --bpf-action : load and execute BPF program when latency= threshold is exceeded", NULL, }; =20 @@ -853,6 +854,7 @@ static struct common_params {"deepest-idle-state", required_argument, 0, '\4'}, {"on-threshold", required_argument, 0, '\5'}, {"on-end", required_argument, 0, '\6'}, + {"bpf-action", required_argument, 0, '\7'}, {0, 0, 0, 0} }; =20 @@ -1062,6 +1064,9 @@ static struct common_params exit(EXIT_FAILURE); } break; + case '\7': + params->bpf_action_program =3D optarg; + break; default: timerlat_hist_usage("Invalid option"); } diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index fc479a0dcb59..da5d5db1bc17 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -521,6 +521,7 @@ static void timerlat_top_usage(char *usage) " --deepest-idle-state n: only go down to idle state n on cpus used= by timerlat to reduce exit from idle latency", " --on-threshold : define action to be executed at latency = threshold, multiple are allowed", " --on-end: define action to be executed at measurement end, multip= le are allowed", + " --bpf-action : load and execute BPF program when latency= threshold is exceeded", NULL, }; =20 @@ -603,6 +604,7 @@ static struct common_params {"deepest-idle-state", required_argument, 0, '8'}, {"on-threshold", required_argument, 0, '9'}, {"on-end", required_argument, 0, '\1'}, + {"bpf-action", required_argument, 0, '\2'}, {0, 0, 0, 0} }; =20 @@ -798,6 +800,9 @@ static struct common_params exit(EXIT_FAILURE); } break; + case '\2': + params->bpf_action_program =3D optarg; + break; default: timerlat_top_usage("Invalid option"); } --=20 2.51.0 From nobody Sat Feb 7 18:20:18 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 8D0412D8795 for ; Fri, 17 Oct 2025 14:47:28 +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=1760712450; cv=none; b=S699t4cMnidBgddab9vZDo/Y45JA3iAJ/oz0ItQP/FvLGefMe/xVTWAEfEy+DdUmhmmcbhZMbnemc7n+LOGj4q8/s9ITscvWZ6VETGFl3ieCo30ZBCETOmq2T9+7I4WDbdxGWbDGbuFntm7w1Dvqsfge1IxQbwno5IfEx4OejkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760712450; c=relaxed/simple; bh=Srk+Fr4TqyjLD7nJUa5pnoyjK2m8oW4zuu6Kvh8HhdE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hWLS0fawxSEtxM4sOcCXafvQ4p6qyrCaKNSQryUMMbw73l5T9/d9wKQyLXfU+n9w07fT2o6/ubyWQNoBKwoHx4E4zkd583YIKtllarPUiXSiiiZSJlDcbTVSQNtaBFqK7xe/Jv7OuYO0sv7F4IPS178EE7DHbzxzxk1tPjONwXI= 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=hwwn5hFQ; 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="hwwn5hFQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760712447; 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=y+g39942jtLGJd3OsDmw3XB6JSqklKuGB9oYb6LS2jo=; b=hwwn5hFQy6puOGuxkvIhyIuq9et7Yja0Pvu8lPQ2rxj998ZGqdq1ToT+4vr6a1qzo4zGxC w7z1bOcpzBKuKoiFtlEO0o22K2H6ffhGo/SlTpwx8p3Pu2Ih9wOZ9hUuMlKRxbEwuSya/X 4TFfMeKfrTLa4D64nsrrD3oAY1YgkPQ= Received: from mx-prod-mc-04.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-93-v_DwCMsAPQeD3eKnXiuP3w-1; Fri, 17 Oct 2025 10:47:22 -0400 X-MC-Unique: v_DwCMsAPQeD3eKnXiuP3w-1 X-Mimecast-MFC-AGG-ID: v_DwCMsAPQeD3eKnXiuP3w_1760712441 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C1CBB1954210; Fri, 17 Oct 2025 14:47:21 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.32.24]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9D5601800452; Fri, 17 Oct 2025 14:47:18 +0000 (UTC) From: Tomas Glozar To: Steven Rostedt Cc: LKML , Linux Trace Kernel , John Kacur , Luis Goncalves , Costa Shulyupin , Crystal Wood , Wander Lairson Costa , Arnaldo Carvalho de Melo , Tomas Glozar Subject: [PATCH 3/4] rtla/timerlat: Add example for BPF action program Date: Fri, 17 Oct 2025 16:46:49 +0200 Message-ID: <20251017144650.663238-4-tglozar@redhat.com> In-Reply-To: <20251017144650.663238-1-tglozar@redhat.com> References: <20251017144650.663238-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.111 Content-Type: text/plain; charset="utf-8" Add an example BPF action program that prints the measured latency to the tracefs buffer via bpf_printk(). Signed-off-by: Tomas Glozar --- tools/tracing/rtla/sample/timerlat_bpf_action.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tools/tracing/rtla/sample/timerlat_bpf_action.c diff --git a/tools/tracing/rtla/sample/timerlat_bpf_action.c b/tools/tracin= g/rtla/sample/timerlat_bpf_action.c new file mode 100644 index 000000000000..ac1be049a848 --- /dev/null +++ b/tools/tracing/rtla/sample/timerlat_bpf_action.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include + +char LICENSE[] SEC("license") =3D "GPL"; + +struct trace_event_raw_timerlat_sample { + unsigned long long timer_latency; +} __attribute__((preserve_access_index)); + +SEC("tp/timerlat_action") +int action_handler(struct trace_event_raw_timerlat_sample *tp_args) +{ + bpf_printk("Latency: %lld\n", tp_args->timer_latency); + return 0; +} --=20 2.51.0 From nobody Sat Feb 7 18:20:18 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 5A07132C930 for ; Fri, 17 Oct 2025 14:47:29 +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=1760712450; cv=none; b=RhRAf/fifHl+sR/UpWfbH/F59MEuJKkNfllAJO4sTDcaetGqAxnLoEdAqujRZeokTp7UKE51YNZzNxmLDQ6Mueg8xcBe4Cg3u3zhKv6kwzpLXCHqAjCn3i0ZdQCnxJknw6+ICFQymbhX/hk+rpMsyCnPCMrgwjbR0Wt7M6O/Dq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760712450; c=relaxed/simple; bh=NwrBGbwiurA2rZyhLXqF+CXHY6SUzDcJCl6Zcy5y4pg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tgoDnpDc4MwgSWlsHJkeQrgeeiWkISG2WTHJhwV0vdGaWNf9OkkUKPNQm2eHhsJNGq8pzMZ74klowqXOQr7/9rsQUtR/TyaKPYBj885n0so/HdsENuQXrGB3iuXyugbHYO8ggb1O9oQ5rfcegMkrIHqpwbuCTTsStABUY9pxZL0= 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=WEV2F0HU; 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="WEV2F0HU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760712448; 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=0PTwm4egHkSEItopN4T5WsSS2MglJFP6Z4suby+DafY=; b=WEV2F0HUxlgJNogondJ5BJSvcnL/xmhYPlrYrrQAlJAPmjMPF1fw7b03vGe9kzxGhkJr6g 0rw7G7jAT+fceItmW1GlOKG4vdI/C1iQvlZ8xu6Ujo1XFGMsgFZcIYoOsLx+qfS5XwZCZZ EjtWQBVMvW6NZ/B+GIcnHQxMWRzklis= 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-441-Nq-NJnGhNa6jIMjQaMxiiQ-1; Fri, 17 Oct 2025 10:47:26 -0400 X-MC-Unique: Nq-NJnGhNa6jIMjQaMxiiQ-1 X-Mimecast-MFC-AGG-ID: Nq-NJnGhNa6jIMjQaMxiiQ_1760712445 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 42E451956054; Fri, 17 Oct 2025 14:47:25 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.32.24]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 665C31800452; Fri, 17 Oct 2025 14:47:21 +0000 (UTC) From: Tomas Glozar To: Steven Rostedt Cc: LKML , Linux Trace Kernel , John Kacur , Luis Goncalves , Costa Shulyupin , Crystal Wood , Wander Lairson Costa , Arnaldo Carvalho de Melo , Tomas Glozar Subject: [PATCH 4/4] Documentation/rtla: Document --bpf-action option Date: Fri, 17 Oct 2025 16:46:50 +0200 Message-ID: <20251017144650.663238-5-tglozar@redhat.com> In-Reply-To: <20251017144650.663238-1-tglozar@redhat.com> References: <20251017144650.663238-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.111 Content-Type: text/plain; charset="utf-8" Add new option --bpf-action into common_timerlat_options.txt, including the format in which it takes the BPF program, and a reference to an example. Signed-off-by: Tomas Glozar --- .../tools/rtla/common_timerlat_options.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Documentation/tools/rtla/common_timerlat_options.rst b/Documen= tation/tools/rtla/common_timerlat_options.rst index 1f5d024b53aa..1b7293ebc897 100644 --- a/Documentation/tools/rtla/common_timerlat_options.rst +++ b/Documentation/tools/rtla/common_timerlat_options.rst @@ -65,3 +65,21 @@ Set timerlat to run without workload, waiting for the user to disp= atch a per-cpu task that waits for a new period on the tracing/osnoise/per_cpu/cp= u$ID/timerlat_fd. See linux/tools/rtla/sample/timerlat_load.py for an example of use= r-load code. + +**--bpf-action** *bpf-program* + + Loads a BPF program from an ELF file and executes it when a latenc= y threshold is exceeded. + + The BPF program must be a valid ELF file loadable with libbpf. The= program must contain + a function named ``action_handler``, declared with ``SEC("tp/timer= lat_action")`` for libbpf + to correctly detect the program type. + + The program receives a ``struct trace_event_raw_timerlat_sample`` = parameter + containing timerlat sample data. + + A sample BPF action program is provided in ``tools/tracing/rtla/sa= mple/timerlat_bpf_action.c``. + This example demonstrates how to create a BPF program that prints = latency information when + thresholds are exceeded. + + **Note**: BPF actions require BPF support to be available. If BPF = is not available or disabled, + the tool will fall back to tracefs mode and BPF actions will not b= e supported. --=20 2.51.0