From nobody Mon Dec 1 22:35:40 2025 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 C44643043A2 for ; Wed, 26 Nov 2025 14:42:29 +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=1764168151; cv=none; b=NuwzVA/nvGRLc95Icu63huPqsCP0QWxRffGyhvXJ/89WIW5TNWlNzeeC2hljCpn3InJuqWyyWzcF2XFzWOV7PBFE29XBNj08mSlLTP8bfkmqmAK8rR0sUkaQCLvsJ2D1clVTQ3Kws7ckdgqwTHi+NXEQQ01dD3pj5xry9TwLcEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764168151; c=relaxed/simple; bh=qwsnhEptLby+7TajVZhrz/vQSlJcCTOENAdkdJOseOk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ocKYPkVpvRGiddKZwdoMU8vRGtZLWWtTYJ6yOtNgUn2jegpuyOxP23GH7hI32lsA2fEHu2nSpD40pfeIvorPaeDV6WuQHXQT964NKp1IvB6FzeEpulsuipG2Si+FuVvelOAyjxDXo6JP2XMkDhUyLLaZPRQ08redj9A9kuNQPZM= 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=LBkjybi5; 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="LBkjybi5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764168148; 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=O29KQZdercKxM8Mac3ccF7Zfk/IAXvI2AhGZPuaVO9E=; b=LBkjybi5fkqlWOx/WLg/rjO+CYi5D5t1fcCpzo5rjTdJplwkP17IKWENIB1xmbOGLkW1qR AlkS7WpsTldlqNFPM51dG+nY+gtgJyz8Gdl4Qv2vtkp7akBpIRX5GRn8NJIaKL9lYuX4K0 Df82iW1owhvJrqa3mijYzj7AiCGX2ck= Received: from mx-prod-mc-01.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-682-yHiiIs6GOGSy0j79Q0CyBA-1; Wed, 26 Nov 2025 09:42:25 -0500 X-MC-Unique: yHiiIs6GOGSy0j79Q0CyBA-1 X-Mimecast-MFC-AGG-ID: yHiiIs6GOGSy0j79Q0CyBA_1764168144 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1D4B919541A7; Wed, 26 Nov 2025 14:42:24 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.141]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D858A30044DD; Wed, 26 Nov 2025 14:42:20 +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 v4 1/7] rtla/timerlat: Support tail call from BPF program Date: Wed, 26 Nov 2025 15:41:59 +0100 Message-ID: <20251126144205.331954-2-tglozar@redhat.com> In-Reply-To: <20251126144205.331954-1-tglozar@redhat.com> References: <20251126144205.331954-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.4 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 | 25 +++++++++++++++++++++---- tools/tracing/rtla/src/timerlat_bpf.c | 13 +++++++++++++ tools/tracing/rtla/src/timerlat_bpf.h | 1 + 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat.bpf.c b/tools/tracing/rtla/src= /timerlat.bpf.c index e2265b5d6491..549d2d2191d2 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,19 +155,19 @@ 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); =20 if (thread_threshold !=3D 0 && latency_us >=3D thread_threshold) - set_stop_tracing(); + set_stop_tracing(tp_args); } =20 return 0; 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.1 From nobody Mon Dec 1 22:35:40 2025 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 F3FB8305E19 for ; Wed, 26 Nov 2025 14:42:33 +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=1764168155; cv=none; b=gLsstNGJNdKHZTP3u7ajB4nqQLe0VLI4hRR3XyR9sWcWYDOGD/7hpsO5ScLNmiJikBJzmiJcuLlm6bKIzctAY5Z74QL+f0Xxhuvd+Qjv6n0XWW84slJP5NrNTiMXKiq9/Z1fa4fIqXkUmSY7QqDFH1Q121znREnNNV92LnP7Ip4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764168155; c=relaxed/simple; bh=t7/GlfB5RjmxI0Eh9DvXg/5lltUD0Z85NktjdO7C3j8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IgIM4pOvMTJXGzibWtFKLv45PJxC6tBDrV2bvdnzH6iUqpWIKg3oJC4DmrH263RngGybIcEAV1b4b2KyooVwvLT+btMJibKtW9AYdnOzzjYHTuOud5zF4LN1ljg/3uNQJpA1e8CAjyrLGlVrqqkfzfIxDZQNM98CFIvwJ/e+eRA= 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=dUpbTPA/; 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="dUpbTPA/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764168153; 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=vox3Hvn7Vbza5K8BeWQiNTOH0yOX/HWBB67A574ATkk=; b=dUpbTPA/j5HZjUkuvX6g24P0J8NaioU8TwXglLHu6NjpBeXFPltHmIiPIn6V7HhY88+dcf ylSOQYmGbMTDyzsUu0TiCnWjDuqbD3bi0ntcJejKUERdzTUMiisDho0uPf8LnwQjujypHN RpLnK7k6/cxWNa0Je5v4rtLPzKsDUPg= Received: from mx-prod-mc-01.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-680-J7FLAN53Ptms8oFNKcXWlQ-1; Wed, 26 Nov 2025 09:42:28 -0500 X-MC-Unique: J7FLAN53Ptms8oFNKcXWlQ-1 X-Mimecast-MFC-AGG-ID: J7FLAN53Ptms8oFNKcXWlQ_1764168147 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AAF4319541AF; Wed, 26 Nov 2025 14:42:27 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.141]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C1E7030044E0; Wed, 26 Nov 2025 14:42:24 +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 v4 2/7] rtla/timerlat: Add --bpf-action option Date: Wed, 26 Nov 2025 15:42:00 +0100 Message-ID: <20251126144205.331954-3-tglozar@redhat.com> In-Reply-To: <20251126144205.331954-1-tglozar@redhat.com> References: <20251126144205.331954-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.4 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 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 assign 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 | 53 ++++++++++++++++++++++++++ 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, 80 insertions(+), 2 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat.c b/tools/tracing/rtla/src/tim= erlat.c index df4f9bfe3433..991136fffe6b 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..05adf18303df 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 */ @@ -96,6 +100,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 +199,48 @@ 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); + goto out_err; + } + + err =3D bpf_object__load(obj); + if (err) { + err_msg("Failed to load BPF action program: %s\n", program_path); + goto out_obj_err; + } + + 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); + goto out_obj_err; + } + + err =3D timerlat_bpf_set_action(prog); + if (err) { + err_msg("Failed to register BPF action program: %s\n", program_path); + goto out_prog_err; + } + + return 0; + +out_prog_err: + prog =3D NULL; +out_obj_err: + bpf_object__close(obj); + obj =3D NULL; +out_err: + return 1; +} + #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 1fb471a787b7..9d5f1f2a07c7 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -747,6 +747,7 @@ static void timerlat_hist_usage(void) " --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 @@ -831,6 +832,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 @@ -1012,6 +1014,9 @@ static struct common_params if (retval) fatal("Invalid action %s", optarg); break; + case '\7': + params->bpf_action_program =3D optarg; + break; default: fatal("Invalid option"); } diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index 29c2c1f717ed..ad5eb7cfff93 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -519,6 +519,7 @@ static void timerlat_top_usage(void) " --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 @@ -595,6 +596,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 @@ -762,6 +764,9 @@ static struct common_params if (retval) fatal("Invalid action %s", optarg); break; + case '\2': + params->bpf_action_program =3D optarg; + break; default: fatal("Invalid option"); } --=20 2.51.1 From nobody Mon Dec 1 22:35:40 2025 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 D846F305969 for ; Wed, 26 Nov 2025 14:42:37 +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=1764168159; cv=none; b=bLJGhZ9+RJCl/JKLpJC8iJ7z8RHtePXb9Poorjg1BEB7zbe52DW04kdXu4H4N84tHE3OzlMH9MpJY5xHuWzBXVnDTbNKr5VQs7i+MuuvIHa98WqtT+0ZuyljNY/7670hRpf5HK4h5Ekz2VjX2YjQ0kiXopJ4+bSbo+JQRntJXSk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764168159; c=relaxed/simple; bh=dbFvGLyIeVEicx/vLCln8WylCwQ3fSZK5YvDmlwVJ+g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jPRFhMMaZxENTP6dz14xcOZULbvZqItIK6htrq+kEW/oW5JR6kwk867UeS/Zp0p4B9WC74KiwFiAROsmFOxidLRcnOfrTJY6hE96sRrl4DO2D+NUsqC3WNN1UYHDTJ9mQirSJUuZetgKhn6+FQ226nmT57CSwOAyojsuDVvQj3s= 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=Xmms+c3l; 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="Xmms+c3l" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764168156; 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=2zdTrZJ6e1+3ErgoegEEu9PfM4To0rBlVIY+g6vLATw=; b=Xmms+c3lCvnA6RHpLb03fmWgmHf3Uxr1UerKSfP/+xM4VgguNPkQdrdXYCHXmJLDuoeS9j KOqnjHhPhbqznEhNW0VaO6SYMrUQj1o7zdz3aUXhgwt4AT2v2FR147kul9dv7YPOiqDG8G eXHRPdfXRXl0Fml+M1T2HOuCaRc3myo= 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-68-usj36g0fMEKC5Z4E7Mlbmw-1; Wed, 26 Nov 2025 09:42:32 -0500 X-MC-Unique: usj36g0fMEKC5Z4E7Mlbmw-1 X-Mimecast-MFC-AGG-ID: usj36g0fMEKC5Z4E7Mlbmw_1764168152 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 DAC67180057A; Wed, 26 Nov 2025 14:42:31 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.141]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7970B30044DC; Wed, 26 Nov 2025 14:42:27 +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 v4 3/7] rtla/timerlat: Add example for BPF action program Date: Wed, 26 Nov 2025 15:42:01 +0100 Message-ID: <20251126144205.331954-4-tglozar@redhat.com> In-Reply-To: <20251126144205.331954-1-tglozar@redhat.com> References: <20251126144205.331954-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.4 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(). A new Makefile target, "examples", is added to build the example. In addition, "sample/" subfolder is renamed to "example". If BPF skeleton support is unavailable or disabled, a warning will be displayed when building the BPF action program example. Signed-off-by: Tomas Glozar --- tools/tracing/rtla/Makefile | 9 ++++++++- tools/tracing/rtla/example/timerlat_bpf_action.c | 16 ++++++++++++++++ .../rtla/{sample =3D> example}/timerlat_load.py | 0 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tools/tracing/rtla/example/timerlat_bpf_action.c rename tools/tracing/rtla/{sample =3D> example}/timerlat_load.py (100%) diff --git a/tools/tracing/rtla/Makefile b/tools/tracing/rtla/Makefile index 746ccf2f5808..5f1529ce3693 100644 --- a/tools/tracing/rtla/Makefile +++ b/tools/tracing/rtla/Makefile @@ -73,9 +73,15 @@ src/timerlat.bpf.o: src/timerlat.bpf.c =20 src/timerlat.skel.h: src/timerlat.bpf.o $(QUIET_GENSKEL)$(SYSTEM_BPFTOOL) gen skeleton $< > $@ + +example/timerlat_bpf_action.o: example/timerlat_bpf_action.c + $(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -c $(filter %.c,$^) -o $@ else src/timerlat.skel.h: $(Q)echo '/* BPF skeleton is disabled */' > src/timerlat.skel.h + +example/timerlat_bpf_action.o: example/timerlat_bpf_action.c + $(Q)echo "BPF skeleton support is disabled, skipping example/timerlat_bpf= _action.o" endif =20 $(RTLA): $(RTLA_IN) @@ -96,7 +102,8 @@ clean: doc_clean fixdep-clean $(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d= ' -delete $(Q)rm -f rtla rtla-static fixdep FEATURE-DUMP rtla-* $(Q)rm -rf feature - $(Q)rm -f src/timerlat.bpf.o src/timerlat.skel.h + $(Q)rm -f src/timerlat.bpf.o src/timerlat.skel.h example/timerlat_bpf_act= ion.o check: $(RTLA) RTLA=3D$(RTLA) prove -o -f tests/ +examples: example/timerlat_bpf_action.o .PHONY: FORCE clean check diff --git a/tools/tracing/rtla/example/timerlat_bpf_action.c b/tools/traci= ng/rtla/example/timerlat_bpf_action.c new file mode 100644 index 000000000000..ac1be049a848 --- /dev/null +++ b/tools/tracing/rtla/example/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; +} diff --git a/tools/tracing/rtla/sample/timerlat_load.py b/tools/tracing/rtl= a/example/timerlat_load.py similarity index 100% rename from tools/tracing/rtla/sample/timerlat_load.py rename to tools/tracing/rtla/example/timerlat_load.py --=20 2.51.1 From nobody Mon Dec 1 22:35:40 2025 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 169CB307ADE for ; Wed, 26 Nov 2025 14:42:41 +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=1764168163; cv=none; b=s3OxWZjtNvDaU9oX2pdS9So/cZkcCYta3c1COrva0Y9utavBUssZBRbcS65ea2h0g9ObXzY6H/D7K8h0JgaupeRnz9PQ5WR/UaJprp/yrO/w6Z4IHhnXvhc1W6h21mAJhpXGipDdwRnJeM9TxV0YrMTYvsfUQBEwTf108kL7kyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764168163; c=relaxed/simple; bh=U6aeKU2yU9MP6txLmWMFAeuRteXaQ4ZMg2CsjVXNZko=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tQ+SoBiPf5XozuZEIQ2Q5gMWbS9/Fy1zG95fweSfdl1Hz5TD+q66YQfDStSlbTopAN8fihIA1jVwSKcECfLyHN8DGd1NIr/v/92ho8wIb0F8s2RoeRw7oMymEQIidPFK77kAw20g/1NyERy2NKyOLVk2Wlw08RzwljKdR9//xmw= 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=IhUd79JJ; 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="IhUd79JJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764168161; 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=7VbMVMHPsP3L/xPG4xVr2CBVZ+uFJi6CXeeR99O3ckw=; b=IhUd79JJOrPYMpGDBLCKIvP1NQythqbPIiL7DkPyCxU7+F6JhPXGd+aFzMhoN59gAgvVuV /5sWPJkiOiDSnybpu4FACmn4L4+3QPvQQY6qd80Cg0D7SrvqsmnvYiDHaIOIOF6qCTgThh oErNGdy+NxfR7z20u7luba55j+d+p04= 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-LF9LfFMqPGKRTSqncxt8Gw-1; Wed, 26 Nov 2025 09:42:36 -0500 X-MC-Unique: LF9LfFMqPGKRTSqncxt8Gw-1 X-Mimecast-MFC-AGG-ID: LF9LfFMqPGKRTSqncxt8Gw_1764168155 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 A81331956060; Wed, 26 Nov 2025 14:42:35 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.141]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5D53030044DC; Wed, 26 Nov 2025 14:42:32 +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 v4 4/7] rtla/tests: Test BPF action program Date: Wed, 26 Nov 2025 15:42:02 +0100 Message-ID: <20251126144205.331954-5-tglozar@redhat.com> In-Reply-To: <20251126144205.331954-1-tglozar@redhat.com> References: <20251126144205.331954-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.4 Content-Type: text/plain; charset="utf-8" Add a test that implements a BPF program writing to a test map, which is attached to RTLA via --bpf-action to be executed on theshold overflow. A combination of --on-threshold shell with bpftool (which is always present if BPF support is enabled) is used to check whether the BPF program has executed successfully. Suggested-by: Crystal Wood Signed-off-by: Tomas Glozar --- tools/tracing/rtla/Makefile | 10 ++++++-- tools/tracing/rtla/tests/bpf/bpf_action_map.c | 25 +++++++++++++++++++ tools/tracing/rtla/tests/timerlat.t | 15 +++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 tools/tracing/rtla/tests/bpf/bpf_action_map.c diff --git a/tools/tracing/rtla/Makefile b/tools/tracing/rtla/Makefile index 5f1529ce3693..aef814b639b7 100644 --- a/tools/tracing/rtla/Makefile +++ b/tools/tracing/rtla/Makefile @@ -76,12 +76,18 @@ src/timerlat.skel.h: src/timerlat.bpf.o =20 example/timerlat_bpf_action.o: example/timerlat_bpf_action.c $(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -c $(filter %.c,$^) -o $@ + +tests/bpf/bpf_action_map.o: tests/bpf/bpf_action_map.c + $(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -c $(filter %.c,$^) -o $@ else src/timerlat.skel.h: $(Q)echo '/* BPF skeleton is disabled */' > src/timerlat.skel.h =20 example/timerlat_bpf_action.o: example/timerlat_bpf_action.c $(Q)echo "BPF skeleton support is disabled, skipping example/timerlat_bpf= _action.o" + +tests/bpf/bpf_action_map.o: tests/bpf/bpf_action_map.c + $(Q)echo "BPF skeleton support is disabled, skipping tests/bpf/bpf_action= _map.o" endif =20 $(RTLA): $(RTLA_IN) @@ -103,7 +109,7 @@ clean: doc_clean fixdep-clean $(Q)rm -f rtla rtla-static fixdep FEATURE-DUMP rtla-* $(Q)rm -rf feature $(Q)rm -f src/timerlat.bpf.o src/timerlat.skel.h example/timerlat_bpf_act= ion.o -check: $(RTLA) - RTLA=3D$(RTLA) prove -o -f tests/ +check: $(RTLA) tests/bpf/bpf_action_map.o + RTLA=3D$(RTLA) BPFTOOL=3D$(SYSTEM_BPFTOOL) prove -o -f tests/ examples: example/timerlat_bpf_action.o .PHONY: FORCE clean check diff --git a/tools/tracing/rtla/tests/bpf/bpf_action_map.c b/tools/tracing/= rtla/tests/bpf/bpf_action_map.c new file mode 100644 index 000000000000..1686e0b858e6 --- /dev/null +++ b/tools/tracing/rtla/tests/bpf/bpf_action_map.c @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include + +char LICENSE[] SEC("license") =3D "GPL"; + +struct { + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(max_entries, 1); + __type(key, unsigned int); + __type(value, unsigned long long); +} rtla_test_map SEC(".maps"); + +struct trace_event_raw_timerlat_sample; + +SEC("tp/timerlat_action") +int action_handler(struct trace_event_raw_timerlat_sample *tp_args) +{ + unsigned int key =3D 0; + unsigned long long value =3D 42; + + bpf_map_update_elem(&rtla_test_map, &key, &value, BPF_ANY); + + return 0; +} diff --git a/tools/tracing/rtla/tests/timerlat.t b/tools/tracing/rtla/tests= /timerlat.t index bbaa1897d8a8..fd4935fd7b49 100644 --- a/tools/tracing/rtla/tests/timerlat.t +++ b/tools/tracing/rtla/tests/timerlat.t @@ -67,6 +67,21 @@ check "hist with trace output at end" \ "timerlat hist -d 1s --on-end trace" 0 "^ Saving trace to timerlat_trace= .txt$" check "top with trace output at end" \ "timerlat top -d 1s --on-end trace" 0 "^ Saving trace to timerlat_trace.= txt$" + +# BPF action program tests +if [ "$option" -eq 0 ] +then + # Test BPF action program properly in BPF mode + [ -z "$BPFTOOL" ] && BPFTOOL=3Dbpftool + check "hist with BPF action program (BPF mode)" \ + "timerlat hist -T 2 --bpf-action tests/bpf/bpf_action_map.o --on-thresho= ld shell,command=3D'$BPFTOOL map dump name rtla_test_map'" \ + 2 '"value": 42' +else + # Test BPF action program failure in non-BPF mode + check "hist with BPF action program (non-BPF mode)" \ + "timerlat hist -T 2 --bpf-action tests/bpf/bpf_action_map.o" \ + 1 "BPF actions are not supported in tracefs-only mode" +fi done =20 test_end --=20 2.51.1 From nobody Mon Dec 1 22:35:40 2025 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 BEB9E308F11 for ; Wed, 26 Nov 2025 14:42:46 +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=1764168168; cv=none; b=rUS3ArHzNpMTDbd2B03itgNyPqWv5pYZ9b1dWgzhD7KjiI4PuUYkBFNXiVR2utmQ1m2P4AHarWTSkzV4Zqzlpz5R6aw6pmPzWjeegoSaMXmdQ+PEGKrLVLrTI9pj3r2sPOdCNn4Q0eK4QpDEtUkDZmvZvGL6VPUNjQameeY0BKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764168168; c=relaxed/simple; bh=ZKUirnE+FdztIlMmCkueMs0Stkl49w0k12IORjr//HQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WooUJxFhvFJj3Sslvy7A1YaeCBOClpaUn5/DJua9ergJXz5cZQ/0X95N2gNbklnlKJZqQsVzCxwRW/WGnKwI+KrDgzEhpO7Ya/hpE5pm2ya/+QW00k+qPYE5k2IGoKv3iRRUz2gRDIC8qXMYuVhlp1T/IfuWjDCd2vvEUCvAEWk= 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=dCavdOUD; 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="dCavdOUD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764168165; 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=KvzjNIyZOh7C1mDpRJpCLf4ka/AuEmYqm5zggI1KnzA=; b=dCavdOUDSHx4xnVaMBZBt05+xzX7cD5ZBlfu8al98EfkBY77Zu3nHOCLJNn2scE8Bk0hkR GNTOhSz6SSZvacsf+y7A3My4bjivz+uUYrL9/+nFT/RY8m5Ww1fQ/N2G6cdn7NxH/19SNi NjF3IZzslMKB8erGjbM86l/TUogh9aQ= 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-528-CrcYHruxPwu2oGc7vq-xcQ-1; Wed, 26 Nov 2025 09:42:40 -0500 X-MC-Unique: CrcYHruxPwu2oGc7vq-xcQ-1 X-Mimecast-MFC-AGG-ID: CrcYHruxPwu2oGc7vq-xcQ_1764168159 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 7364E19560A1; Wed, 26 Nov 2025 14:42:39 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.141]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 48F0230044DC; Wed, 26 Nov 2025 14:42:35 +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 v4 5/7] rtla/tests: Run Test::Harness in verbose mode Date: Wed, 26 Nov 2025 15:42:03 +0100 Message-ID: <20251126144205.331954-6-tglozar@redhat.com> In-Reply-To: <20251126144205.331954-1-tglozar@redhat.com> References: <20251126144205.331954-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.4 Content-Type: text/plain; charset="utf-8" Add -v flag to prove command to also print the names of tests that succeeded, not only those that failed, to allow easier debugging of the test suite. Also, drop printing the option and value to stdout in check_with_osnoise_options, which was a debugging print that was accidentally left in the final commit, and which would be otherwise now visible in make check output, as stdout is no longer suppressed. Suggested-by: Crystal Wood Signed-off-by: Tomas Glozar Reviewed-by: Wander Lairson Costa --- tools/tracing/rtla/Makefile | 2 +- tools/tracing/rtla/tests/engine.sh | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/tracing/rtla/Makefile b/tools/tracing/rtla/Makefile index aef814b639b7..2701256abaf3 100644 --- a/tools/tracing/rtla/Makefile +++ b/tools/tracing/rtla/Makefile @@ -110,6 +110,6 @@ clean: doc_clean fixdep-clean $(Q)rm -rf feature $(Q)rm -f src/timerlat.bpf.o src/timerlat.skel.h example/timerlat_bpf_act= ion.o check: $(RTLA) tests/bpf/bpf_action_map.o - RTLA=3D$(RTLA) BPFTOOL=3D$(SYSTEM_BPFTOOL) prove -o -f tests/ + RTLA=3D$(RTLA) BPFTOOL=3D$(SYSTEM_BPFTOOL) prove -o -f -v tests/ examples: example/timerlat_bpf_action.o .PHONY: FORCE clean check diff --git a/tools/tracing/rtla/tests/engine.sh b/tools/tracing/rtla/tests/= engine.sh index c7de3d6ed6a8..ed261e07c6d9 100644 --- a/tools/tracing/rtla/tests/engine.sh +++ b/tools/tracing/rtla/tests/engine.sh @@ -105,7 +105,6 @@ check_with_osnoise_options() { [ "$1" =3D=3D "" ] && continue option=3D$(echo $1 | cut -d '=3D' -f 1) value=3D$(echo $1 | cut -d '=3D' -f 2) - echo "option: $option, value: $value" echo "$value" > "/sys/kernel/tracing/osnoise/$option" || return 1 done fi --=20 2.51.1 From nobody Mon Dec 1 22:35:40 2025 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 0EF19308F2E for ; Wed, 26 Nov 2025 14:42:49 +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=1764168171; cv=none; b=AA4J0dQcmVXjnsmhh1xt2e9G0eqDLatK+Z3netI8wwA+mpCo6AUaELdGWYNB2TWWiyN8vvbJ46zPHfpqwIvT5PlVYsmsHGBkyo4NVLoP0/XR6WRzMiHgu3UTaDoGqIcbtlX8kYpyMTtXRdk1Ee2EeigDfhX6YLhDD2t5tNf5Q4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764168171; c=relaxed/simple; bh=eD1PWDaHGsgjL84lRbHENXkGOB17roHnhotuHZoVJLk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h2sHLcgr/Jjq6LqdKIdsuK6xs0wXvcuDZ/mosD/DuvxXfm2wuxlWZHeaHGUEQBvm74CtkoTKbEJcP6P7ax4mMVJaMApVzlXn0ov0iWCa/bB94OkXc2FUQIIUEyQVSbKvqYDXsrJGXrFM83gcFNRpQqGybLnd3BIyUz3h111XN9c= 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=gtqXEhyC; 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="gtqXEhyC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764168169; 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=dY22nWp5keVSnEHuBJ8H55WEBcTJdpzMuvZ42aGcmhY=; b=gtqXEhyCpS63+kX/VQjX7SOdEHf6hIOteIljEOBz+D2iOEHrm8cGK9RCAxTjaSaiSWgvsD WLy6jzdutMgRycbt070xn7STPCALqmLudO7OhrebOFbR6TcMNKP0YoMhOT9RWYHWhj+OXC TZeHJDggwH0BxKyWqZvOrAQ8S9oDQZY= Received: from mx-prod-mc-01.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-171-ZyTEHPYRNf-NhVvBRNpBNw-1; Wed, 26 Nov 2025 09:42:45 -0500 X-MC-Unique: ZyTEHPYRNf-NhVvBRNpBNw-1 X-Mimecast-MFC-AGG-ID: ZyTEHPYRNf-NhVvBRNpBNw_1764168163 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3FA7319541A7; Wed, 26 Nov 2025 14:42:43 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.141]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 25CBC30044EE; Wed, 26 Nov 2025 14:42:39 +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 v4 6/7] Documentation/rtla: Rename sample/ to example/ Date: Wed, 26 Nov 2025 15:42:04 +0100 Message-ID: <20251126144205.331954-7-tglozar@redhat.com> In-Reply-To: <20251126144205.331954-1-tglozar@redhat.com> References: <20251126144205.331954-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.4 Content-Type: text/plain; charset="utf-8" The sample/ directory in tools/tracing/rtla was renamed to example/ in an earlier commit. Rename it also in the documentation. Signed-off-by: Tomas Glozar Reviewed-by: Wander Lairson Costa --- Documentation/tools/rtla/common_timerlat_options.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/tools/rtla/common_timerlat_options.txt b/Documen= tation/tools/rtla/common_timerlat_options.txt index 33070b264cae..0cf7eca1f7b6 100644 --- a/Documentation/tools/rtla/common_timerlat_options.txt +++ b/Documentation/tools/rtla/common_timerlat_options.txt @@ -64,4 +64,4 @@ =20 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. + See linux/tools/rtla/example/timerlat_load.py for an example of us= er-load code. --=20 2.51.1 From nobody Mon Dec 1 22:35:40 2025 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 589B71DE3DB for ; Wed, 26 Nov 2025 14:42:52 +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=1764168173; cv=none; b=TIsdauBdN6ws6YnYmy4K1itCqZw4bNPRAjE10RGU1cuNpdkfpn+L45bGnugPy2DyQfk9+kqYZcd9FBXqJTPNl7GewspF3swVCccA6/OULVgpPBgE7ISblBbGYpPik97EIZxe/AE01Y5x0iqqJJKfXbOUxjVF1zhClrRWxrPrPwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764168173; c=relaxed/simple; bh=kW1gihDDcedEvkXqGdmYsSbrgzNv4svA/+2enVIdvK0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XYahkHDxqpE2WHb/EOD/cOaPwn82rmbF7hfGcLUpKmwkde6nMG7CG9Ju0hVis1NYImnzkS36UswBCrwDIIgcieqSNPni8VjJrZ6+5lvQBV0o029WDkru6S5tXP+mKziCDNK3wV51EKePKl5013hSBAz+HnFIHkPfISpBEXrtzq8= 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=PgIB5sZP; 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="PgIB5sZP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764168171; 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=Hjh7jROV8BsTpArMkOZNoEr6SM0a22WnGJ/uz3xYqvA=; b=PgIB5sZPr/85i+BDkgcN939/AeI5to7jXtG4bdeMrKVRLjBV1FH6hq9wq1TtA9J0zmpbR4 4L4H+LyPP/5QOb8jABCgJ1Jfd36SI2bla2LXJ/+0McmFAriTueensfbXUIKShIQ30suBAm Ih0PwKm4G6I3ghtQ+R2OEhhH9c3lkR8= 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-664-0p5ltYuTPJ--QjL03Qzk-w-1; Wed, 26 Nov 2025 09:42:47 -0500 X-MC-Unique: 0p5ltYuTPJ--QjL03Qzk-w-1 X-Mimecast-MFC-AGG-ID: 0p5ltYuTPJ--QjL03Qzk-w_1764168166 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 D05DC1956058; Wed, 26 Nov 2025 14:42:46 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.141]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CFA1230044DC; Wed, 26 Nov 2025 14:42:43 +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 v4 7/7] Documentation/rtla: Document --bpf-action option Date: Wed, 26 Nov 2025 15:42:05 +0100 Message-ID: <20251126144205.331954-8-tglozar@redhat.com> In-Reply-To: <20251126144205.331954-1-tglozar@redhat.com> References: <20251126144205.331954-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.4 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.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Documentation/tools/rtla/common_timerlat_options.txt b/Documen= tation/tools/rtla/common_timerlat_options.txt index 0cf7eca1f7b6..07a285fcf7cf 100644 --- a/Documentation/tools/rtla/common_timerlat_options.txt +++ b/Documentation/tools/rtla/common_timerlat_options.txt @@ -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/example/timerlat_load.py for an example of us= er-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``, stored in an ELF section with= the ``tp_`` prefix. + The prefix is used by libbpf to set BPF program type to BPF_PROG_T= YPE_TRACEPOINT. + + The program receives a ``struct trace_event_raw_timerlat_sample`` = parameter + containing timerlat sample data. + + An example is provided in ``tools/tracing/rtla/example/timerlat_bp= f_action.c``. + This example demonstrates how to create a BPF program that prints = latency information using + bpf_trace_printk() when a threshold is exceeded. + + **Note**: BPF actions require BPF support to be available. If BPF = is not available + or disabled, the tool falls back to tracefs mode and BPF actions a= re not supported. --=20 2.51.1