All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] rt-utils: Add option to avoid stopping tracing in tracemark()
@ 2021-07-14 11:07 Nicolas Saenz Julienne
  2021-07-14 11:07 ` [PATCH v2 2/2] oslat: Add trace maker prior starting main thread Nicolas Saenz Julienne
  2021-07-30 20:28 ` [PATCH v2 1/2] rt-utils: Add option to avoid stopping tracing in tracemark() John Kacur
  0 siblings, 2 replies; 3+ messages in thread
From: Nicolas Saenz Julienne @ 2021-07-14 11:07 UTC (permalink / raw)
  To: linux-rt-users, peterx; +Cc: williams, jkacur, nsaenzju

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>
---

Changes since v1:
 - Add stdbool.h include in rt-utils.h

 src/cyclictest/cyclictest.c | 3 ++-
 src/include/rt-utils.h      | 3 ++-
 src/lib/rt-utils.c          | 6 ++++--
 src/oslat/oslat.c           | 2 +-
 4 files changed, 9 insertions(+), 5 deletions(-)

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..5b3d34d 100644
--- a/src/include/rt-utils.h
+++ b/src/include/rt-utils.h
@@ -3,6 +3,7 @@
 #define __RT_UTILS_H
 
 #include <stdint.h>
+#include <stdbool.h>
 
 #define _STR(x) #x
 #define STR(x) _STR(x)
@@ -31,7 +32,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);
 	}
 
-- 
2.31.1


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

* [PATCH v2 2/2] oslat: Add trace maker prior starting main thread
  2021-07-14 11:07 [PATCH v2 1/2] rt-utils: Add option to avoid stopping tracing in tracemark() Nicolas Saenz Julienne
@ 2021-07-14 11:07 ` Nicolas Saenz Julienne
  2021-07-30 20:28 ` [PATCH v2 1/2] rt-utils: Add option to avoid stopping tracing in tracemark() John Kacur
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Saenz Julienne @ 2021-07-14 11:07 UTC (permalink / raw)
  To: linux-rt-users, peterx; +Cc: williams, jkacur, nsaenzju

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>
Acked-by: Peter Xu <peterx@redhat.com>
---

Changes since v1:
 - none

 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


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

* Re: [PATCH v2 1/2] rt-utils: Add option to avoid stopping tracing in tracemark()
  2021-07-14 11:07 [PATCH v2 1/2] rt-utils: Add option to avoid stopping tracing in tracemark() Nicolas Saenz Julienne
  2021-07-14 11:07 ` [PATCH v2 2/2] oslat: Add trace maker prior starting main thread Nicolas Saenz Julienne
@ 2021-07-30 20:28 ` John Kacur
  1 sibling, 0 replies; 3+ messages in thread
From: John Kacur @ 2021-07-30 20:28 UTC (permalink / raw)
  To: Nicolas Saenz Julienne; +Cc: linux-rt-users, peterx, williams



On Wed, 14 Jul 2021, Nicolas Saenz Julienne wrote:

> 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>
> ---
> 
> Changes since v1:
>  - Add stdbool.h include in rt-utils.h
> 
>  src/cyclictest/cyclictest.c | 3 ++-
>  src/include/rt-utils.h      | 3 ++-
>  src/lib/rt-utils.c          | 6 ++++--
>  src/oslat/oslat.c           | 2 +-
>  4 files changed, 9 insertions(+), 5 deletions(-)
> 
> 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..5b3d34d 100644
> --- a/src/include/rt-utils.h
> +++ b/src/include/rt-utils.h
> @@ -3,6 +3,7 @@
>  #define __RT_UTILS_H
>  
>  #include <stdint.h>
> +#include <stdbool.h>
>  
>  #define _STR(x) #x
>  #define STR(x) _STR(x)
> @@ -31,7 +32,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);
>  	}
>  
> -- 
> 2.31.1
> 
> 

I'm curious as to how you are running this?
What I would do is, something like this
trace-cmd record -p function ./oslat -T100
I have no end to the amount of data it generates.

John


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

end of thread, other threads:[~2021-07-30 20:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14 11:07 [PATCH v2 1/2] rt-utils: Add option to avoid stopping tracing in tracemark() Nicolas Saenz Julienne
2021-07-14 11:07 ` [PATCH v2 2/2] oslat: Add trace maker prior starting main thread Nicolas Saenz Julienne
2021-07-30 20:28 ` [PATCH v2 1/2] rt-utils: Add option to avoid stopping tracing in tracemark() John Kacur

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.