public inbox for linux-trace-devel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracecmd: --poll option is not passed down to guest
@ 2025-10-24 17:43 Marcelo Tosatti
  2025-12-04 21:23 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Marcelo Tosatti @ 2025-10-24 17:43 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel


commit e7ffcbda9d62855ec30dc36ef5bebcb669321073 added the
--poll option to avoid waking up the trace buffer reader
from an isolated CPU:

    trace-cmd: Add option to poll trace buffers

    Waiting for data to be available on the trace ring-buffers may trigger
    IPIs. This might generate unacceptable trace noise when debugging low
    latency or real time systems. So introduce the poll option. When
    enabled, it forces trace-cmd to use O_NONBLOCK. The drawback to using it
    is that traces will be extracted by busy waiting, which will
    unnecessarily hog the CPUs, so only use when really needed.

    Link: https://lore.kernel.org/linux-trace-devel/20210602090803.12233-1-nsaenzju@redhat.com

    Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

However the --poll option is not passed down to the guest, which can cause
the wakeup (and associated latency) in the guest:

84221.535329: kvm_entry:             vcpu 1 rip 0xfff0
84221.535341: write_msr:            6e0, value 97374f0241f8
84221.535343: sched_switch:         cyclictest:6563 [4] S ==> swapper/1:0 [120]
84221.535343: ipi_send_cpu:         cpu=1 callsite=irq_work_queue+0x2f callback=rb_wake_up_waiters+0x0
84221.535344: write_msr:            83f, value f6
84221.535345: irq_work_entry:       vector=246

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>


diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 4e1157c9..ac42d428 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -6220,9 +6220,16 @@ static void add_arg(struct buffer_instance *instance,
 {
 	char *ptr, *arg;
 	int i, ret;
+	int long_opt;
+
+	long_opt = 0;
+	for (i = 0; long_options[i].name; i++) {
+		if (long_options[i].val == c)
+			long_opt = 1;
+	}
 
 	/* Short or long arg */
-	if (!(c & 0x80)) {
+	if (long_opt == 0) {
 		ptr = strchr(opts, c);
 		if (!ptr)
 			return; /* Not found? */


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tracecmd: --poll option is not passed down to guest
  2025-10-24 17:43 [PATCH] tracecmd: --poll option is not passed down to guest Marcelo Tosatti
@ 2025-12-04 21:23 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2025-12-04 21:23 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: linux-trace-devel

On Fri, 24 Oct 2025 14:43:37 -0300
Marcelo Tosatti <mtosatti@redhat.com> wrote:

Hi Marcelo,

Sorry for the late reply. Unfortunately, trace-cmd updates is usually my
low priority task :-/

> --- a/tracecmd/trace-record.c
> +++ b/tracecmd/trace-record.c
> @@ -6220,9 +6220,16 @@ static void add_arg(struct buffer_instance *instance,
>  {
>  	char *ptr, *arg;
>  	int i, ret;
> +	int long_opt;
> +
> +	long_opt = 0;
> +	for (i = 0; long_options[i].name; i++) {
> +		if (long_options[i].val == c)
> +			long_opt = 1;
> +	}

I hate looking at every long option to determine if this is a long option
or not.

>  
>  	/* Short or long arg */
> -	if (!(c & 0x80)) {
> +	if (long_opt == 0) {
>  		ptr = strchr(opts, c);
>  		if (!ptr)
>  			return; /* Not found? */

What about this patch?

diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 4e1157c99294..29938b1bb701 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -5932,36 +5932,39 @@ void init_top_instance(void)
 	init_instance(&top_instance);
 }
 
+#define LONG_OPT(opt)		(0x80 + ((opt) << 8))
+#define IS_LONG_OPT(opt)	((opt) & 0x80)
+
 enum {
-	OPT_compression		= 237,
-	OPT_file_ver		= 238,
-	OPT_verbose		= 239,
-	OPT_tsc2nsec		= 240,
-	OPT_fork		= 241,
-	OPT_tsyncinterval	= 242,
-	OPT_user		= 243,
-	OPT_procmap		= 244,
-	OPT_quiet		= 245,
-	OPT_debug		= 246,
-	OPT_no_filter		= 247,
-	OPT_max_graph_depth	= 248,
-	OPT_tsoffset		= 249,
-	OPT_bycomm		= 250,
-	OPT_stderr		= 251,
-	OPT_profile		= 252,
-	OPT_nosplice		= 253,
-	OPT_funcstack		= 254,
-	OPT_date		= 255,
-	OPT_module		= 256,
-	OPT_nofifos		= 257,
-	OPT_cmdlines_size	= 258,
-	OPT_poll		= 259,
-	OPT_name		= 260,
-	OPT_proxy		= 261,
-	OPT_temp		= 262,
-	OPT_notimeout		= 264,
-	OPT_daemonize		= 265,
-	OPT_subbuf		= 266,
+	OPT_compression		= LONG_OPT(0),
+	OPT_file_ver		= LONG_OPT(1),
+	OPT_verbose		= LONG_OPT(2),
+	OPT_tsc2nsec		= LONG_OPT(3),
+	OPT_fork		= LONG_OPT(4),
+	OPT_tsyncinterval	= LONG_OPT(5),
+	OPT_user		= LONG_OPT(6),
+	OPT_procmap		= LONG_OPT(7),
+	OPT_quiet		= LONG_OPT(8),
+	OPT_debug		= LONG_OPT(9),
+	OPT_no_filter		= LONG_OPT(10),
+	OPT_max_graph_depth	= LONG_OPT(11),
+	OPT_tsoffset		= LONG_OPT(12),
+	OPT_bycomm		= LONG_OPT(13),
+	OPT_stderr		= LONG_OPT(14),
+	OPT_profile		= LONG_OPT(15),
+	OPT_nosplice		= LONG_OPT(16),
+	OPT_funcstack		= LONG_OPT(17),
+	OPT_date		= LONG_OPT(18),
+	OPT_module		= LONG_OPT(19),
+	OPT_nofifos		= LONG_OPT(20),
+	OPT_cmdlines_size	= LONG_OPT(21),
+	OPT_poll		= LONG_OPT(22),
+	OPT_name		= LONG_OPT(23),
+	OPT_proxy		= LONG_OPT(24),
+	OPT_temp		= LONG_OPT(25),
+	OPT_notimeout		= LONG_OPT(26),
+	OPT_daemonize		= LONG_OPT(27),
+	OPT_subbuf		= LONG_OPT(28),
 };
 
 void trace_stop(int argc, char **argv)
@@ -6222,7 +6225,7 @@ static void add_arg(struct buffer_instance *instance,
 	int i, ret;
 
 	/* Short or long arg */
-	if (!(c & 0x80)) {
+	if (!IS_LONG_OPT(c)) {
 		ptr = strchr(opts, c);
 		if (!ptr)
 			return; /* Not found? */


-- Steve


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-04 21:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-24 17:43 [PATCH] tracecmd: --poll option is not passed down to guest Marcelo Tosatti
2025-12-04 21:23 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox