diff mbox series

[1/2] rt-utils: Add option to avoid stopping tracing in tracemark()

Message ID 20210709155414.610308-1-nsaenzju@redhat.com
State Superseded
Headers show
Series [1/2] rt-utils: Add option to avoid stopping tracing in tracemark() | expand

Commit Message

Nicolas Saenz Julienne July 9, 2021, 3:54 p.m. UTC
Not all users of tracemark() might want to stop tracing after printing a
mark. For example, if leaving a mark during a test. So add an extra
argument to tracemark() which avoid the stop.

Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
---
 src/cyclictest/cyclictest.c | 3 ++-
 src/include/rt-utils.h      | 2 +-
 src/lib/rt-utils.c          | 6 ++++--
 src/oslat/oslat.c           | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)

Comments

Peter Xu July 9, 2021, 6:39 p.m. UTC | #1
On Fri, Jul 09, 2021 at 05:54:14PM +0200, Nicolas Saenz Julienne wrote:
> After a long tracing session it's sometimes hard to find the moment
> oslat started. So leave a message in the trace buffer just before the
> main thread starts.
> 
> Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
> ---
>  src/oslat/oslat.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
> index d35be57..20bf02b 100644
> --- a/src/oslat/oslat.c
> +++ b/src/oslat/oslat.c
> @@ -400,6 +400,10 @@ static void *thread_main(void *arg)
>  	while (g.n_threads_running != g.n_threads)
>  		relax();
>  
> +	if (!g.preheat)
> +		tracemark(false, "%s: Starting thread on CPU %d.\n",
> +			  g.app_name, t->core_i);
> +
>  	frc(&t->frc_start);
>  	doit(t);
>  	frc(&t->frc_stop);
> -- 
> 2.31.1
> 

Not sure how it would help.. but no objection either. :)

Acked-by: Peter Xu <peterx@redhat.com>
Nicolas Saenz Julienne July 12, 2021, 10:17 a.m. UTC | #2
Hi Peter,

On Fri, 2021-07-09 at 14:39 -0400, Peter Xu wrote:
> On Fri, Jul 09, 2021 at 05:54:14PM +0200, Nicolas Saenz Julienne wrote:

> > After a long tracing session it's sometimes hard to find the moment

> > oslat started. So leave a message in the trace buffer just before the

> > main thread starts.

> > 

> > Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>

> > ---

> >  src/oslat/oslat.c | 4 ++++

> >  1 file changed, 4 insertions(+)

> > 

> > diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c

> > index d35be57..20bf02b 100644

> > --- a/src/oslat/oslat.c

> > +++ b/src/oslat/oslat.c

> > @@ -400,6 +400,10 @@ static void *thread_main(void *arg)

> >  	while (g.n_threads_running != g.n_threads)

> >  		relax();

> >  

> > +	if (!g.preheat)

> > +		tracemark(false, "%s: Starting thread on CPU %d.\n",

> > +			  g.app_name, t->core_i);

> > +

> >  	frc(&t->frc_start);

> >  	doit(t);

> >  	frc(&t->frc_stop);

> > -- 

> > 2.31.1

> > 

> 

> Not sure how it would help.. but no objection either. :)


For example, I tend to enable all trace points on Isolated CPUs. It's
manageable, since once oslat runs you shouldn't be getting much action. But you
get 10s/100s MBs of noise generated while oslat is being initialized. This
makes finding the beginning of the test very annoying and time consuming.

> Acked-by: Peter Xu <peterx@redhat.com>


Thanks!
diff mbox series

Patch

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index a08c91d..1f3c5a2 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -12,6 +12,7 @@ 
 #include <stdlib.h>
 #include <stdint.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <getopt.h>
@@ -722,7 +723,7 @@  static void *timerthread(void *param)
 			pthread_mutex_lock(&break_thread_id_lock);
 			if (break_thread_id == 0) {
 				break_thread_id = stat->tid;
-				tracemark("hit latency threshold (%llu > %d)",
+				tracemark(true, "hit latency threshold (%llu > %d)",
 					  (unsigned long long) diff, tracelimit);
 				break_thread_value = diff;
 			}
diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
index f6b3fed..88d285b 100644
--- a/src/include/rt-utils.h
+++ b/src/include/rt-utils.h
@@ -31,7 +31,7 @@  int parse_time_string(char *val);
 int parse_mem_string(char *str, uint64_t *val);
 
 void enable_trace_mark(void);
-void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));
+void tracemark(bool stop, char *fmt, ...) __attribute__((format(printf, 2, 3)));
 void disable_trace_mark(void);
 
 #define MSEC_PER_SEC		1000
diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c
index 6c0235d..d8d1325 100644
--- a/src/lib/rt-utils.c
+++ b/src/lib/rt-utils.c
@@ -23,6 +23,7 @@ 
 #include <sys/utsname.h>
 #include <time.h>
 #include <sys/time.h>
+#include <stdbool.h>
 
 #include "rt-utils.h"
 #include "rt-sched.h"
@@ -458,7 +459,7 @@  static void debugfs_prepare(void)
 		     "debug fs not mounted");
 }
 
-void tracemark(char *fmt, ...)
+void tracemark(bool stop, char *fmt, ...)
 {
 	va_list ap;
 	int len;
@@ -476,7 +477,8 @@  void tracemark(char *fmt, ...)
 	write(tracemark_fd, tracebuf, len);
 
 	/* now stop any trace */
-	write(trace_fd, "0\n", 2);
+	if (stop)
+		write(trace_fd, "0\n", 2);
 }
 
 void enable_trace_mark(void)
diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
index 6ff5ba8..d35be57 100644
--- a/src/oslat/oslat.c
+++ b/src/oslat/oslat.c
@@ -304,7 +304,7 @@  static void insert_bucket(struct thread *t, stamp_t value)
 	if (!g.preheat && g.trace_threshold && us >= g.trace_threshold) {
 		char *line = "%s: Trace threshold (%d us) triggered with %u us!\n"
 		    "Stopping the test.\n";
-		tracemark(line, g.app_name, g.trace_threshold, us);
+		tracemark(true, line, g.app_name, g.trace_threshold, us);
 		err_quit(line, g.app_name, g.trace_threshold, us);
 	}