From: Gabriele Monaco <gmonaco@redhat.com>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
bpf@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
Steven Rostedt <rostedt@goodmis.org>,
Gabriele Monaco <gmonaco@redhat.com>,
linux-doc@vger.kernel.org
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Nam Cao <namcao@linutronix.de>, Wen Yang <wen.yang@linux.dev>,
Tobias Schaffner <tobias.schaffner@siemens.com>,
Viktor Malik <vmalik@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
John Ogness <john.ogness@linutronix.de>
Subject: [PATCH v3 15/18] tools/rv: Add -E/--errors-only option
Date: Thu, 26 Nov 2026 14:00:01 +0100 [thread overview]
Message-ID: <20261126130004.127155-16-gmonaco@redhat.com> (raw)
In-Reply-To: <20261126130004.127155-1-gmonaco@redhat.com>
Currently the rv tool enables tracing when running with -t and that
allows to see tracepoints generated from both in-kernel and BPF
monitors.
In-kernel monitors can be controlled also by other tools but BPF ones
cannot, so if a user is only interested in seeing errors, they need to
bear the performance overhead of other events too.
Add the -E/--errors-only flag. If it's passed with -t, only enable error
tracepoints. On BPF monitors, if -E is passed but -t isn't, still load
the monitor with error tracing enabled, so the user can enable the error
events in other tools.
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
---
Documentation/tools/rv/common_ikm.rst | 6 ++++++
tools/verification/rv/include/utils.h | 1 +
tools/verification/rv/src/bpf_monitor.c | 4 +++-
tools/verification/rv/src/trace.c | 11 +++++++----
tools/verification/rv/src/utils.c | 9 +++++++--
5 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/Documentation/tools/rv/common_ikm.rst b/Documentation/tools/rv/common_ikm.rst
index e50a5f8a7142..b2594f9c35e8 100644
--- a/Documentation/tools/rv/common_ikm.rst
+++ b/Documentation/tools/rv/common_ikm.rst
@@ -19,3 +19,9 @@
**-v**, **--verbose**
Print debug messages.
+
+**-E**, **--errors-only**
+
+ When tracing (**-t**), trace only error events, skipping the monitor's
+ state transitions. Specifying this without tracing is meaningful only
+ for BPF monitors.
diff --git a/tools/verification/rv/include/utils.h b/tools/verification/rv/include/utils.h
index 397a37981932..2fec9ef7c0b3 100644
--- a/tools/verification/rv/include/utils.h
+++ b/tools/verification/rv/include/utils.h
@@ -16,6 +16,7 @@ struct config {
bool debug;
bool is_container;
bool trace;
+ bool trace_errors_only;
bool is_bpf;
int my_pid;
char *initial_reactor;
diff --git a/tools/verification/rv/src/bpf_monitor.c b/tools/verification/rv/src/bpf_monitor.c
index 1ff76a4ffb68..12cb407c55bc 100644
--- a/tools/verification/rv/src/bpf_monitor.c
+++ b/tools/verification/rv/src/bpf_monitor.c
@@ -411,7 +411,9 @@ static int bpf_enable_tracing(struct bpf_object *obj, struct bpf_monitor_ctx *ct
if (!trace_level || data_size != sizeof(*trace_level))
return -1;
- *trace_level = ctx->trace_types[TRACE_TYPE_EVENT];
+ *trace_level = config.trace_errors_only ?
+ ctx->trace_types[TRACE_TYPE_ERROR] :
+ ctx->trace_types[TRACE_TYPE_EVENT];
return 0;
}
diff --git a/tools/verification/rv/src/trace.c b/tools/verification/rv/src/trace.c
index 6fdbff2c28d4..629b4f63e147 100644
--- a/tools/verification/rv/src/trace.c
+++ b/tools/verification/rv/src/trace.c
@@ -213,7 +213,7 @@ static int enable_generic_event(struct trace_instance *inst, const char *event_n
*/
static int enable_bpf_events(struct trace_instance *inst, char *name)
{
- if (enable_generic_event(inst, "event_monitor", name))
+ if (!config.trace_errors_only && enable_generic_event(inst, "event_monitor", name))
return -1;
if (enable_generic_event(inst, "error_monitor", name))
@@ -228,6 +228,7 @@ static int enable_bpf_events(struct trace_instance *inst, char *name)
* Enable the rv:event_"monitor" and rv:error_"monitor" events in the
* given trace instance, and register the filters for these events.
* If enabled, the filter for self pid (-s) is applied here.
+ * Skip the "event" events if errors only (-E) is specified.
*
* Returns 0 on success, -1 otherwise.
*/
@@ -238,9 +239,11 @@ static int trace_enable_monitor_events(struct trace_instance *inst, char *name)
if (config.is_bpf)
return enable_bpf_events(inst, name);
- snprintf(event, sizeof(event), "event_%s", name);
- if (enable_specific_event(inst, event))
- return -1;
+ if (!config.trace_errors_only) {
+ snprintf(event, sizeof(event), "event_%s", name);
+ if (enable_specific_event(inst, event))
+ return -1;
+ }
snprintf(event, sizeof(event), "error_%s", name);
if (enable_specific_event(inst, event))
diff --git a/tools/verification/rv/src/utils.c b/tools/verification/rv/src/utils.c
index 1b1ad7a3ca32..854028324325 100644
--- a/tools/verification/rv/src/utils.c
+++ b/tools/verification/rv/src/utils.c
@@ -65,6 +65,7 @@ void mon_usage(int exit_val, char *monitor_name, const char *fmt, ...)
" -r/--reactor 'reactor': enables the 'reactor'",
" -s/--self: when tracing (-t), also trace rv command",
" -t/--trace: trace monitor's event",
+ " -E/--errors-only: when tracing (-t), trace only errors",
" -v/--verbose: print debug messages",
"",
NULL,
@@ -76,7 +77,7 @@ void mon_usage(int exit_val, char *monitor_name, const char *fmt, ...)
fprintf(stderr, " %s\n", message);
- fprintf(stderr, "\n usage: rv mon %s [-h] [-q] [-r reactor] [-s] [-v]", monitor_name);
+ fprintf(stderr, "\n usage: rv mon %s [-E] [-h] [-r reactor] [-s] [-t] [-v]", monitor_name);
for (i = 0; usage[i]; i++)
fprintf(stderr, "%s\n", usage[i]);
@@ -103,6 +104,7 @@ int parse_arguments(char *monitor_name, int argc, char **argv)
{"reactor", required_argument, 0, 'r'},
{"self", no_argument, 0, 's'},
{"trace", no_argument, 0, 't'},
+ {"errors-only", no_argument, 0, 'E'},
{"verbose", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
@@ -110,7 +112,7 @@ int parse_arguments(char *monitor_name, int argc, char **argv)
/* getopt_long stores the option index here. */
int option_index = 0;
- c = getopt_long(argc, argv, "hr:stv", long_options, &option_index);
+ c = getopt_long(argc, argv, "hr:stvE", long_options, &option_index);
/* detect the end of the options. */
if (c == -1)
@@ -132,6 +134,9 @@ int parse_arguments(char *monitor_name, int argc, char **argv)
case 'v':
config.debug = 1;
break;
+ case 'E':
+ config.trace_errors_only = 1;
+ break;
}
}
--
2.56.1
next prev parent reply other threads:[~2026-11-26 13:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 12:59 [PATCH v3 00/18] rv: Add support for BPF monitors Gabriele Monaco
2026-11-26 12:59 ` [PATCH v3 01/18] sched: Add task enqueue/dequeue trace points Gabriele Monaco
2026-11-26 12:59 ` [PATCH v3 02/18] tools/rv: Skip empty pid error in selftest if command failed Gabriele Monaco
2026-11-26 12:59 ` [PATCH v3 03/18] rv: Add wrapper macros for monitor tracepoint definitions Gabriele Monaco
2026-11-26 12:59 ` [PATCH v3 04/18] rv: Propagate const to model strings and tracepoints Gabriele Monaco
2026-11-26 12:59 ` [PATCH v3 05/18] rv: Add generic monitor event tracepoints and BPF kfuncs Gabriele Monaco
2026-11-26 22:09 ` kernel test robot
2026-11-26 12:59 ` [PATCH v3 06/18] tools/build: Add a feature test for bpftool-btf Gabriele Monaco
2026-11-26 12:59 ` [PATCH v3 07/18] tools/rv: Move argument parsing from in_kernel to utils Gabriele Monaco
2026-11-26 12:59 ` [PATCH v3 08/18] tools/rv: Move monitor trace handling to trace.c Gabriele Monaco
2026-11-26 12:59 ` [PATCH v3 09/18] tools/rv: Implement BPF monitor discovery and listing Gabriele Monaco
2026-11-26 12:59 ` [PATCH v3 10/18] tools/rv: Implement BPF monitor loading and tracing Gabriele Monaco
2026-11-26 12:59 ` [PATCH v3 11/18] tools/rv: Rework tracing to support generic events Gabriele Monaco
2026-11-26 12:59 ` [PATCH v3 12/18] tools/rv: Copy stripped bpf_atomic.h from libarena Gabriele Monaco
2026-11-26 12:59 ` [PATCH v3 13/18] tools/rv: Add BPF monitors Gabriele Monaco
2026-11-26 13:00 ` [PATCH v3 14/18] tools/rv: Define CONFIG_X86_64 statically for " Gabriele Monaco
2026-11-26 13:00 ` Gabriele Monaco [this message]
2026-11-26 13:00 ` [PATCH v3 16/18] verification/rvgen: Add support " Gabriele Monaco
2026-11-26 13:00 ` [PATCH v3 17/18] tools/rv: Add selftest for rv bpf monitors Gabriele Monaco
2026-11-26 13:00 ` [PATCH v3 18/18] verification/rvgen: Add selftest for rvgen -b Gabriele Monaco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126130004.127155-16-gmonaco@redhat.com \
--to=gmonaco@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=john.ogness@linutronix.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=namcao@linutronix.de \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tobias.schaffner@siemens.com \
--cc=vmalik@redhat.com \
--cc=wen.yang@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®