linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [rt-tests 0/4] Fix signaltest output when quiet
@ 2020-09-01 15:46 Daniel Wagner
  2020-09-01 15:46 ` [rt-tests 1/4] rt-utils: Move timestamp calc helper to common header Daniel Wagner
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Daniel Wagner @ 2020-09-01 15:46 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

When the quiet option is used don't print all threads stats. The first
thread will pause every 16 cycles for 10000us. This will show up in
the max values for all other threads when the final results are
printed:

 # signaltest -q  -D 2s
 T: 0 ( 4517) P: 0 C:   3121 Min:      5 Act:    8 Avg:    8 Max:      19
 T: 1 ( 4518) P: 0 C:   3121 Min:      5 Act:10065 Avg:  639 Max:   10073

We could also remove the sleep but then the system gets fully loaded
by the test. Furthermore, we would keep the path pretty hot and that's
not ideal if one wants to test the eratic signal behavior. So only
consider the first thread for the stats.

Daniel Wagner (4):
  rt-utils: Move timestamp calc helper to common header
  rt-utils: Move time defininitions to common header
  rt-utils: Move ARRAY_SIZE to common header
  signaltest: Only print from the first thread stats when quiet

 src/backfire/sendme.c         |  3 ---
 src/cyclictest/cyclictest.c   | 42 ------------------------------
 src/include/rt-utils.h        | 48 +++++++++++++++++++++++++++++++++++
 src/pi_tests/pi_stress.c      | 17 -------------
 src/pmqtest/pmqtest.c         |  4 ---
 src/ptsematest/ptsematest.c   |  2 --
 src/queuelat/queuelat.c       |  2 +-
 src/signaltest/signaltest.c   | 22 +---------------
 src/sigwaittest/sigwaittest.c |  2 --
 src/svsematest/svsematest.c   |  2 --
 10 files changed, 50 insertions(+), 94 deletions(-)

-- 
2.28.0


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

* [rt-tests 1/4] rt-utils: Move timestamp calc helper to common header
  2020-09-01 15:46 [rt-tests 0/4] Fix signaltest output when quiet Daniel Wagner
@ 2020-09-01 15:46 ` Daniel Wagner
  2020-09-03 16:36   ` John Kacur
  2020-09-01 15:46 ` [rt-tests 2/4] rt-utils: Move time defininitions " Daniel Wagner
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Daniel Wagner @ 2020-09-01 15:46 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Several test implement the same helpers. Move it to a
common header to avoid code duplication.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/cyclictest/cyclictest.c | 40 -------------------------------------
 src/include/rt-utils.h      | 40 +++++++++++++++++++++++++++++++++++++
 src/pi_tests/pi_stress.c    |  8 --------
 src/signaltest/signaltest.c | 15 --------------
 4 files changed, 40 insertions(+), 63 deletions(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index dd418939a0c2..ae1d64a46b21 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -86,9 +86,6 @@ extern int clock_nanosleep(clockid_t __clock_id, int __flags,
 			   struct timespec *__rem);
 #endif	/* __UCLIBC__ */
 
-#define USEC_PER_SEC		1000000
-#define NSEC_PER_SEC		1000000000
-
 #define HIST_MAX		1000000
 
 #define MODE_CYCLIC		0
@@ -291,43 +288,6 @@ enum {
 static int trace_fd     = -1;
 static int tracemark_fd = -1;
 
-static inline void tsnorm(struct timespec *ts)
-{
-	while (ts->tv_nsec >= NSEC_PER_SEC) {
-		ts->tv_nsec -= NSEC_PER_SEC;
-		ts->tv_sec++;
-	}
-}
-
-static inline int tsgreater(struct timespec *a, struct timespec *b)
-{
-	return ((a->tv_sec > b->tv_sec) ||
-		(a->tv_sec == b->tv_sec && a->tv_nsec > b->tv_nsec));
-}
-
-static inline int64_t calcdiff(struct timespec t1, struct timespec t2)
-{
-	int64_t diff = USEC_PER_SEC * (long long)((int) t1.tv_sec - (int) t2.tv_sec);
-	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
-	return diff;
-}
-
-static inline int64_t calcdiff_ns(struct timespec t1, struct timespec t2)
-{
-	int64_t diff;
-	diff = NSEC_PER_SEC * (int64_t)((int) t1.tv_sec - (int) t2.tv_sec);
-	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec);
-	return diff;
-}
-
-static inline int64_t calctime(struct timespec t)
-{
-	int64_t time;
-	time = USEC_PER_SEC * t.tv_sec;
-	time += ((int) t.tv_nsec) / 1000;
-	return time;
-}
-
 /*
  * Raise the soft priority limit up to prio, if that is less than or equal
  * to the hard limit
diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
index 51489b408e6c..fdd790600d68 100644
--- a/src/include/rt-utils.h
+++ b/src/include/rt-utils.h
@@ -30,4 +30,44 @@ int parse_time_string(char *val);
 void enable_trace_mark(void);
 void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));
 
+#define USEC_PER_SEC		1000000
+#define NSEC_PER_SEC		1000000000
+
+static inline void tsnorm(struct timespec *ts)
+{
+	while (ts->tv_nsec >= NSEC_PER_SEC) {
+		ts->tv_nsec -= NSEC_PER_SEC;
+		ts->tv_sec++;
+	}
+}
+
+static inline int tsgreater(struct timespec *a, struct timespec *b)
+{
+	return ((a->tv_sec > b->tv_sec) ||
+		(a->tv_sec == b->tv_sec && a->tv_nsec > b->tv_nsec));
+}
+
+static inline int64_t calcdiff(struct timespec t1, struct timespec t2)
+{
+	int64_t diff = USEC_PER_SEC * (long long)((int) t1.tv_sec - (int) t2.tv_sec);
+	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
+	return diff;
+}
+
+static inline int64_t calcdiff_ns(struct timespec t1, struct timespec t2)
+{
+	int64_t diff;
+	diff = NSEC_PER_SEC * (int64_t)((int) t1.tv_sec - (int) t2.tv_sec);
+	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec);
+	return diff;
+}
+
+static inline int64_t calctime(struct timespec t)
+{
+	int64_t time;
+	time = USEC_PER_SEC * t.tv_sec;
+	time += ((int) t.tv_nsec) / 1000;
+	return time;
+}
+
 #endif	/* __RT_UTILS.H */
diff --git a/src/pi_tests/pi_stress.c b/src/pi_tests/pi_stress.c
index eba21d7727bc..93d7044c9f22 100644
--- a/src/pi_tests/pi_stress.c
+++ b/src/pi_tests/pi_stress.c
@@ -519,14 +519,6 @@ int pending_interrupt(void)
 	return interrupted = sigismember(&pending, SIGINT);
 }
 
-static inline void tsnorm(struct timespec *ts)
-{
-	while (ts->tv_nsec >= NSEC_PER_SEC) {
-		ts->tv_nsec -= NSEC_PER_SEC;
-		ts->tv_sec++;
-	}
-}
-
 /*
  * this routine serves two purposes:
  *   1. report progress
diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
index b5c86c5635cb..42a70facc6b3 100644
--- a/src/signaltest/signaltest.c
+++ b/src/signaltest/signaltest.c
@@ -69,21 +69,6 @@ static int shutdown;
 static int tracelimit = 0;
 static int oldtrace = 0;
 
-static inline void tsnorm(struct timespec *ts)
-{
-	while (ts->tv_nsec >= NSEC_PER_SEC) {
-		ts->tv_nsec -= NSEC_PER_SEC;
-		ts->tv_sec++;
-	}
-}
-
-static inline long calcdiff(struct timespec t1, struct timespec t2)
-{
-	long diff;
-	diff = USEC_PER_SEC * ((int) t1.tv_sec - (int) t2.tv_sec);
-	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
-	return diff;
-}
 
 /*
  * signal thread
-- 
2.28.0


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

* [rt-tests 2/4] rt-utils: Move time defininitions to common header
  2020-09-01 15:46 [rt-tests 0/4] Fix signaltest output when quiet Daniel Wagner
  2020-09-01 15:46 ` [rt-tests 1/4] rt-utils: Move timestamp calc helper to common header Daniel Wagner
@ 2020-09-01 15:46 ` Daniel Wagner
  2020-09-03 16:37   ` John Kacur
  2020-09-01 15:46 ` [rt-tests 3/4] rt-utils: Move ARRAY_SIZE " Daniel Wagner
  2020-09-01 15:46 ` [rt-tests 4/4] signaltest: Only print from the first thread stats when quiet Daniel Wagner
  3 siblings, 1 reply; 9+ messages in thread
From: Daniel Wagner @ 2020-09-01 15:46 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Several tests define the same time values. Move them all to
common header to avoid code duplication.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/backfire/sendme.c         | 3 ---
 src/include/rt-utils.h        | 6 ++++++
 src/pi_tests/pi_stress.c      | 9 ---------
 src/pmqtest/pmqtest.c         | 4 ----
 src/ptsematest/ptsematest.c   | 2 --
 src/queuelat/queuelat.c       | 2 +-
 src/signaltest/signaltest.c   | 3 ---
 src/sigwaittest/sigwaittest.c | 2 --
 src/svsematest/svsematest.c   | 2 --
 9 files changed, 7 insertions(+), 26 deletions(-)

diff --git a/src/backfire/sendme.c b/src/backfire/sendme.c
index c1854d9660cb..d963723b1c93 100644
--- a/src/backfire/sendme.c
+++ b/src/backfire/sendme.c
@@ -38,9 +38,6 @@
 #include <sys/time.h>
 #include <sys/mman.h>
 
-#define USEC_PER_SEC		1000000
-#define NSEC_PER_SEC		1000000000
-
 #define SIGTEST SIGHUP
 
 enum {
diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
index fdd790600d68..f7b98d9605a0 100644
--- a/src/include/rt-utils.h
+++ b/src/include/rt-utils.h
@@ -30,8 +30,14 @@ int parse_time_string(char *val);
 void enable_trace_mark(void);
 void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));
 
+#define MSEC_PER_SEC		1000
 #define USEC_PER_SEC		1000000
 #define NSEC_PER_SEC		1000000000
+#define USEC_TO_NSEC(u)		((u) * 1000)
+#define USEC_TO_SEC(u)		(u) / USEC_PER_SEC)
+#define NSEC_TO_USEC(n)		((n) / 1000)
+#define SEC_TO_NSEC(s)		((s) * NSEC_PER_SEC)
+#define SEC_TO_USEC(s)		((s) * USEC_PER_SEC)
 
 static inline void tsnorm(struct timespec *ts)
 {
diff --git a/src/pi_tests/pi_stress.c b/src/pi_tests/pi_stress.c
index 93d7044c9f22..e03cca25b933 100644
--- a/src/pi_tests/pi_stress.c
+++ b/src/pi_tests/pi_stress.c
@@ -50,15 +50,6 @@
 
 #include "error.h"
 
-/* conversions */
-#define USEC_PER_SEC 	1000000
-#define NSEC_PER_SEC 	1000000000
-#define USEC_TO_NSEC(u) ((u) * 1000)
-#define USEC_TO_SEC(u) 	((u) / USEC_PER_SEC)
-#define NSEC_TO_USEC(n) ((n) / 1000)
-#define SEC_TO_NSEC(s) 	((s) * NSEC_PER_SEC)
-#define SEC_TO_USEC(s) 	((s) * USEC_PER_SEC)
-
 /* test timeout */
 #define TIMEOUT 2
 
diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c
index 3ce29252b9a2..5db8d348cdf8 100644
--- a/src/pmqtest/pmqtest.c
+++ b/src/pmqtest/pmqtest.c
@@ -27,13 +27,9 @@
 
 #include <pthread.h>
 
-#define USEC_PER_SEC 1000000
-
 #define SYNCMQ_NAME "/syncmsg%d"
 #define TESTMQ_NAME "/testmsg%d"
 #define MSG_SIZE 8
-#define MSEC_PER_SEC 1000
-#define NSEC_PER_SEC 1000000000
 
 char *syncmsg = "Syncing";
 char *testmsg = "Testing";
diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c
index 485c991ec173..de8ea2fe1b0c 100644
--- a/src/ptsematest/ptsematest.c
+++ b/src/ptsematest/ptsematest.c
@@ -25,8 +25,6 @@
 
 #include <pthread.h>
 
-#define USEC_PER_SEC 1000000
-
 enum {
 	AFFINITY_UNSPECIFIED,
 	AFFINITY_SPECIFIED,
diff --git a/src/queuelat/queuelat.c b/src/queuelat/queuelat.c
index 22b68a84d6ae..2b9118d8a8a5 100644
--- a/src/queuelat/queuelat.c
+++ b/src/queuelat/queuelat.c
@@ -17,7 +17,7 @@
 #include <signal.h>
 #include <time.h>
 
-#define NSEC_PER_SEC 1000000000
+#include "rt-utils.h"
 
 /* Program parameters:
  * max_queue_len: maximum latency allowed, in nanoseconds (int).
diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
index 42a70facc6b3..49d42ff20b6f 100644
--- a/src/signaltest/signaltest.c
+++ b/src/signaltest/signaltest.c
@@ -34,9 +34,6 @@
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
-#define USEC_PER_SEC		1000000
-#define NSEC_PER_SEC		1000000000
-
 /* Must be power of 2 ! */
 #define VALBUF_SIZE		16384
 
diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c
index 4678b68675b2..e7393f791519 100644
--- a/src/sigwaittest/sigwaittest.c
+++ b/src/sigwaittest/sigwaittest.c
@@ -43,8 +43,6 @@
 
 #include <pthread.h>
 
-#define USEC_PER_SEC 1000000
-
 enum {
 	AFFINITY_UNSPECIFIED,
 	AFFINITY_SPECIFIED,
diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c
index 023a303fd7df..607b397bf39e 100644
--- a/src/svsematest/svsematest.c
+++ b/src/svsematest/svsematest.c
@@ -32,8 +32,6 @@
 #include "rt-get_cpu.h"
 #include "error.h"
 
-#define USEC_PER_SEC 1000000
-
 #define SEM_WAIT_FOR_RECEIVER 0
 #define SEM_WAIT_FOR_SENDER 1
 
-- 
2.28.0


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

* [rt-tests 3/4] rt-utils: Move ARRAY_SIZE to common header
  2020-09-01 15:46 [rt-tests 0/4] Fix signaltest output when quiet Daniel Wagner
  2020-09-01 15:46 ` [rt-tests 1/4] rt-utils: Move timestamp calc helper to common header Daniel Wagner
  2020-09-01 15:46 ` [rt-tests 2/4] rt-utils: Move time defininitions " Daniel Wagner
@ 2020-09-01 15:46 ` Daniel Wagner
  2020-09-03 16:38   ` John Kacur
  2020-09-01 15:46 ` [rt-tests 4/4] signaltest: Only print from the first thread stats when quiet Daniel Wagner
  3 siblings, 1 reply; 9+ messages in thread
From: Daniel Wagner @ 2020-09-01 15:46 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Move the ARRAY_SIZE macro to a common header to avoid code
duplication.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/cyclictest/cyclictest.c | 2 --
 src/include/rt-utils.h      | 2 ++
 src/signaltest/signaltest.c | 2 --
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index ae1d64a46b21..b41d42f13f24 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -49,8 +49,6 @@
 #define SCHED_NORMAL SCHED_OTHER
 #endif
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
 #define sigev_notify_thread_id _sigev_un._tid
 
 #ifdef __UCLIBC__
diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
index f7b98d9605a0..4ed1cbc53ece 100644
--- a/src/include/rt-utils.h
+++ b/src/include/rt-utils.h
@@ -8,6 +8,8 @@
 #define STR(x) _STR(x)
 #define MAX_PATH 256
 
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
 int check_privs(void);
 char *get_debugfileprefix(void);
 int mount_debugfs(char *);
diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
index 49d42ff20b6f..0bf075456ab6 100644
--- a/src/signaltest/signaltest.c
+++ b/src/signaltest/signaltest.c
@@ -32,8 +32,6 @@
 #include "error.h"
 #include "rt-utils.h"
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
 /* Must be power of 2 ! */
 #define VALBUF_SIZE		16384
 
-- 
2.28.0


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

* [rt-tests 4/4] signaltest: Only print from the first thread stats when quiet
  2020-09-01 15:46 [rt-tests 0/4] Fix signaltest output when quiet Daniel Wagner
                   ` (2 preceding siblings ...)
  2020-09-01 15:46 ` [rt-tests 3/4] rt-utils: Move ARRAY_SIZE " Daniel Wagner
@ 2020-09-01 15:46 ` Daniel Wagner
  2020-09-03 16:43   ` John Kacur
  3 siblings, 1 reply; 9+ messages in thread
From: Daniel Wagner @ 2020-09-01 15:46 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

When the quiet option is used don't print all threads stats. The first
thread will pause every 16 cycles for 10000us. This will show up in
the max values for all other threads when the final results are
printed:

 # signaltest -q  -D 2s
 T: 0 ( 4517) P: 0 C:   3121 Min:      5 Act:    8 Avg:    8 Max:      19
 T: 1 ( 4518) P: 0 C:   3121 Min:      5 Act:10065 Avg:  639 Max:   10073

We could also remove the sleep but then the system gets fully loaded
by the test. Furthermore, we would keep the path pretty hot and that's
not ideal if one wants to test the eratic signal behavior. So only
consider the first thread for the stats.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/signaltest/signaltest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
index 0bf075456ab6..679cb9792777 100644
--- a/src/signaltest/signaltest.c
+++ b/src/signaltest/signaltest.c
@@ -417,7 +417,7 @@ int main(int argc, char **argv)
 			pthread_kill(stat[i].thread, SIGTERM);
 		if (stat[i].threadstarted) {
 			pthread_join(stat[i].thread, NULL);
-			if (quiet)
+			if (quiet && i == 0)
 				print_stat(&par[i], i, 0);
 		}
 		if (stat[i].values)
-- 
2.28.0


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

* Re: [rt-tests 1/4] rt-utils: Move timestamp calc helper to common header
  2020-09-01 15:46 ` [rt-tests 1/4] rt-utils: Move timestamp calc helper to common header Daniel Wagner
@ 2020-09-03 16:36   ` John Kacur
  0 siblings, 0 replies; 9+ messages in thread
From: John Kacur @ 2020-09-03 16:36 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Tue, 1 Sep 2020, Daniel Wagner wrote:

> Several test implement the same helpers. Move it to a
> common header to avoid code duplication.
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/cyclictest/cyclictest.c | 40 -------------------------------------
>  src/include/rt-utils.h      | 40 +++++++++++++++++++++++++++++++++++++
>  src/pi_tests/pi_stress.c    |  8 --------
>  src/signaltest/signaltest.c | 15 --------------
>  4 files changed, 40 insertions(+), 63 deletions(-)
> 
> diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
> index dd418939a0c2..ae1d64a46b21 100644
> --- a/src/cyclictest/cyclictest.c
> +++ b/src/cyclictest/cyclictest.c
> @@ -86,9 +86,6 @@ extern int clock_nanosleep(clockid_t __clock_id, int __flags,
>  			   struct timespec *__rem);
>  #endif	/* __UCLIBC__ */
>  
> -#define USEC_PER_SEC		1000000
> -#define NSEC_PER_SEC		1000000000
> -
>  #define HIST_MAX		1000000
>  
>  #define MODE_CYCLIC		0
> @@ -291,43 +288,6 @@ enum {
>  static int trace_fd     = -1;
>  static int tracemark_fd = -1;
>  
> -static inline void tsnorm(struct timespec *ts)
> -{
> -	while (ts->tv_nsec >= NSEC_PER_SEC) {
> -		ts->tv_nsec -= NSEC_PER_SEC;
> -		ts->tv_sec++;
> -	}
> -}
> -
> -static inline int tsgreater(struct timespec *a, struct timespec *b)
> -{
> -	return ((a->tv_sec > b->tv_sec) ||
> -		(a->tv_sec == b->tv_sec && a->tv_nsec > b->tv_nsec));
> -}
> -
> -static inline int64_t calcdiff(struct timespec t1, struct timespec t2)
> -{
> -	int64_t diff = USEC_PER_SEC * (long long)((int) t1.tv_sec - (int) t2.tv_sec);
> -	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
> -	return diff;
> -}
> -
> -static inline int64_t calcdiff_ns(struct timespec t1, struct timespec t2)
> -{
> -	int64_t diff;
> -	diff = NSEC_PER_SEC * (int64_t)((int) t1.tv_sec - (int) t2.tv_sec);
> -	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec);
> -	return diff;
> -}
> -
> -static inline int64_t calctime(struct timespec t)
> -{
> -	int64_t time;
> -	time = USEC_PER_SEC * t.tv_sec;
> -	time += ((int) t.tv_nsec) / 1000;
> -	return time;
> -}
> -
>  /*
>   * Raise the soft priority limit up to prio, if that is less than or equal
>   * to the hard limit
> diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
> index 51489b408e6c..fdd790600d68 100644
> --- a/src/include/rt-utils.h
> +++ b/src/include/rt-utils.h
> @@ -30,4 +30,44 @@ int parse_time_string(char *val);
>  void enable_trace_mark(void);
>  void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));
>  
> +#define USEC_PER_SEC		1000000
> +#define NSEC_PER_SEC		1000000000
> +
> +static inline void tsnorm(struct timespec *ts)
> +{
> +	while (ts->tv_nsec >= NSEC_PER_SEC) {
> +		ts->tv_nsec -= NSEC_PER_SEC;
> +		ts->tv_sec++;
> +	}
> +}
> +
> +static inline int tsgreater(struct timespec *a, struct timespec *b)
> +{
> +	return ((a->tv_sec > b->tv_sec) ||
> +		(a->tv_sec == b->tv_sec && a->tv_nsec > b->tv_nsec));
> +}
> +
> +static inline int64_t calcdiff(struct timespec t1, struct timespec t2)
> +{
> +	int64_t diff = USEC_PER_SEC * (long long)((int) t1.tv_sec - (int) t2.tv_sec);
> +	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
> +	return diff;
> +}
> +
> +static inline int64_t calcdiff_ns(struct timespec t1, struct timespec t2)
> +{
> +	int64_t diff;
> +	diff = NSEC_PER_SEC * (int64_t)((int) t1.tv_sec - (int) t2.tv_sec);
> +	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec);
> +	return diff;
> +}
> +
> +static inline int64_t calctime(struct timespec t)
> +{
> +	int64_t time;
> +	time = USEC_PER_SEC * t.tv_sec;
> +	time += ((int) t.tv_nsec) / 1000;
> +	return time;
> +}
> +
>  #endif	/* __RT_UTILS.H */
> diff --git a/src/pi_tests/pi_stress.c b/src/pi_tests/pi_stress.c
> index eba21d7727bc..93d7044c9f22 100644
> --- a/src/pi_tests/pi_stress.c
> +++ b/src/pi_tests/pi_stress.c
> @@ -519,14 +519,6 @@ int pending_interrupt(void)
>  	return interrupted = sigismember(&pending, SIGINT);
>  }
>  
> -static inline void tsnorm(struct timespec *ts)
> -{
> -	while (ts->tv_nsec >= NSEC_PER_SEC) {
> -		ts->tv_nsec -= NSEC_PER_SEC;
> -		ts->tv_sec++;
> -	}
> -}
> -
>  /*
>   * this routine serves two purposes:
>   *   1. report progress
> diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
> index b5c86c5635cb..42a70facc6b3 100644
> --- a/src/signaltest/signaltest.c
> +++ b/src/signaltest/signaltest.c
> @@ -69,21 +69,6 @@ static int shutdown;
>  static int tracelimit = 0;
>  static int oldtrace = 0;
>  
> -static inline void tsnorm(struct timespec *ts)
> -{
> -	while (ts->tv_nsec >= NSEC_PER_SEC) {
> -		ts->tv_nsec -= NSEC_PER_SEC;
> -		ts->tv_sec++;
> -	}
> -}
> -
> -static inline long calcdiff(struct timespec t1, struct timespec t2)
> -{
> -	long diff;
> -	diff = USEC_PER_SEC * ((int) t1.tv_sec - (int) t2.tv_sec);
> -	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
> -	return diff;
> -}
>  
>  /*
>   * signal thread
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

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

* Re: [rt-tests 2/4] rt-utils: Move time defininitions to common header
  2020-09-01 15:46 ` [rt-tests 2/4] rt-utils: Move time defininitions " Daniel Wagner
@ 2020-09-03 16:37   ` John Kacur
  0 siblings, 0 replies; 9+ messages in thread
From: John Kacur @ 2020-09-03 16:37 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Tue, 1 Sep 2020, Daniel Wagner wrote:

> Several tests define the same time values. Move them all to
> common header to avoid code duplication.
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/backfire/sendme.c         | 3 ---
>  src/include/rt-utils.h        | 6 ++++++
>  src/pi_tests/pi_stress.c      | 9 ---------
>  src/pmqtest/pmqtest.c         | 4 ----
>  src/ptsematest/ptsematest.c   | 2 --
>  src/queuelat/queuelat.c       | 2 +-
>  src/signaltest/signaltest.c   | 3 ---
>  src/sigwaittest/sigwaittest.c | 2 --
>  src/svsematest/svsematest.c   | 2 --
>  9 files changed, 7 insertions(+), 26 deletions(-)
> 
> diff --git a/src/backfire/sendme.c b/src/backfire/sendme.c
> index c1854d9660cb..d963723b1c93 100644
> --- a/src/backfire/sendme.c
> +++ b/src/backfire/sendme.c
> @@ -38,9 +38,6 @@
>  #include <sys/time.h>
>  #include <sys/mman.h>
>  
> -#define USEC_PER_SEC		1000000
> -#define NSEC_PER_SEC		1000000000
> -
>  #define SIGTEST SIGHUP
>  
>  enum {
> diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
> index fdd790600d68..f7b98d9605a0 100644
> --- a/src/include/rt-utils.h
> +++ b/src/include/rt-utils.h
> @@ -30,8 +30,14 @@ int parse_time_string(char *val);
>  void enable_trace_mark(void);
>  void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));
>  
> +#define MSEC_PER_SEC		1000
>  #define USEC_PER_SEC		1000000
>  #define NSEC_PER_SEC		1000000000
> +#define USEC_TO_NSEC(u)		((u) * 1000)
> +#define USEC_TO_SEC(u)		(u) / USEC_PER_SEC)
> +#define NSEC_TO_USEC(n)		((n) / 1000)
> +#define SEC_TO_NSEC(s)		((s) * NSEC_PER_SEC)
> +#define SEC_TO_USEC(s)		((s) * USEC_PER_SEC)
>  
>  static inline void tsnorm(struct timespec *ts)
>  {
> diff --git a/src/pi_tests/pi_stress.c b/src/pi_tests/pi_stress.c
> index 93d7044c9f22..e03cca25b933 100644
> --- a/src/pi_tests/pi_stress.c
> +++ b/src/pi_tests/pi_stress.c
> @@ -50,15 +50,6 @@
>  
>  #include "error.h"
>  
> -/* conversions */
> -#define USEC_PER_SEC 	1000000
> -#define NSEC_PER_SEC 	1000000000
> -#define USEC_TO_NSEC(u) ((u) * 1000)
> -#define USEC_TO_SEC(u) 	((u) / USEC_PER_SEC)
> -#define NSEC_TO_USEC(n) ((n) / 1000)
> -#define SEC_TO_NSEC(s) 	((s) * NSEC_PER_SEC)
> -#define SEC_TO_USEC(s) 	((s) * USEC_PER_SEC)
> -
>  /* test timeout */
>  #define TIMEOUT 2
>  
> diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c
> index 3ce29252b9a2..5db8d348cdf8 100644
> --- a/src/pmqtest/pmqtest.c
> +++ b/src/pmqtest/pmqtest.c
> @@ -27,13 +27,9 @@
>  
>  #include <pthread.h>
>  
> -#define USEC_PER_SEC 1000000
> -
>  #define SYNCMQ_NAME "/syncmsg%d"
>  #define TESTMQ_NAME "/testmsg%d"
>  #define MSG_SIZE 8
> -#define MSEC_PER_SEC 1000
> -#define NSEC_PER_SEC 1000000000
>  
>  char *syncmsg = "Syncing";
>  char *testmsg = "Testing";
> diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c
> index 485c991ec173..de8ea2fe1b0c 100644
> --- a/src/ptsematest/ptsematest.c
> +++ b/src/ptsematest/ptsematest.c
> @@ -25,8 +25,6 @@
>  
>  #include <pthread.h>
>  
> -#define USEC_PER_SEC 1000000
> -
>  enum {
>  	AFFINITY_UNSPECIFIED,
>  	AFFINITY_SPECIFIED,
> diff --git a/src/queuelat/queuelat.c b/src/queuelat/queuelat.c
> index 22b68a84d6ae..2b9118d8a8a5 100644
> --- a/src/queuelat/queuelat.c
> +++ b/src/queuelat/queuelat.c
> @@ -17,7 +17,7 @@
>  #include <signal.h>
>  #include <time.h>
>  
> -#define NSEC_PER_SEC 1000000000
> +#include "rt-utils.h"
>  
>  /* Program parameters:
>   * max_queue_len: maximum latency allowed, in nanoseconds (int).
> diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
> index 42a70facc6b3..49d42ff20b6f 100644
> --- a/src/signaltest/signaltest.c
> +++ b/src/signaltest/signaltest.c
> @@ -34,9 +34,6 @@
>  
>  #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
>  
> -#define USEC_PER_SEC		1000000
> -#define NSEC_PER_SEC		1000000000
> -
>  /* Must be power of 2 ! */
>  #define VALBUF_SIZE		16384
>  
> diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c
> index 4678b68675b2..e7393f791519 100644
> --- a/src/sigwaittest/sigwaittest.c
> +++ b/src/sigwaittest/sigwaittest.c
> @@ -43,8 +43,6 @@
>  
>  #include <pthread.h>
>  
> -#define USEC_PER_SEC 1000000
> -
>  enum {
>  	AFFINITY_UNSPECIFIED,
>  	AFFINITY_SPECIFIED,
> diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c
> index 023a303fd7df..607b397bf39e 100644
> --- a/src/svsematest/svsematest.c
> +++ b/src/svsematest/svsematest.c
> @@ -32,8 +32,6 @@
>  #include "rt-get_cpu.h"
>  #include "error.h"
>  
> -#define USEC_PER_SEC 1000000
> -
>  #define SEM_WAIT_FOR_RECEIVER 0
>  #define SEM_WAIT_FOR_SENDER 1
>  
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

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

* Re: [rt-tests 3/4] rt-utils: Move ARRAY_SIZE to common header
  2020-09-01 15:46 ` [rt-tests 3/4] rt-utils: Move ARRAY_SIZE " Daniel Wagner
@ 2020-09-03 16:38   ` John Kacur
  0 siblings, 0 replies; 9+ messages in thread
From: John Kacur @ 2020-09-03 16:38 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Tue, 1 Sep 2020, Daniel Wagner wrote:

> Move the ARRAY_SIZE macro to a common header to avoid code
> duplication.
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/cyclictest/cyclictest.c | 2 --
>  src/include/rt-utils.h      | 2 ++
>  src/signaltest/signaltest.c | 2 --
>  3 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
> index ae1d64a46b21..b41d42f13f24 100644
> --- a/src/cyclictest/cyclictest.c
> +++ b/src/cyclictest/cyclictest.c
> @@ -49,8 +49,6 @@
>  #define SCHED_NORMAL SCHED_OTHER
>  #endif
>  
> -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> -
>  #define sigev_notify_thread_id _sigev_un._tid
>  
>  #ifdef __UCLIBC__
> diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
> index f7b98d9605a0..4ed1cbc53ece 100644
> --- a/src/include/rt-utils.h
> +++ b/src/include/rt-utils.h
> @@ -8,6 +8,8 @@
>  #define STR(x) _STR(x)
>  #define MAX_PATH 256
>  
> +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> +
>  int check_privs(void);
>  char *get_debugfileprefix(void);
>  int mount_debugfs(char *);
> diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
> index 49d42ff20b6f..0bf075456ab6 100644
> --- a/src/signaltest/signaltest.c
> +++ b/src/signaltest/signaltest.c
> @@ -32,8 +32,6 @@
>  #include "error.h"
>  #include "rt-utils.h"
>  
> -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> -
>  /* Must be power of 2 ! */
>  #define VALBUF_SIZE		16384
>  
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

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

* Re: [rt-tests 4/4] signaltest: Only print from the first thread stats when quiet
  2020-09-01 15:46 ` [rt-tests 4/4] signaltest: Only print from the first thread stats when quiet Daniel Wagner
@ 2020-09-03 16:43   ` John Kacur
  0 siblings, 0 replies; 9+ messages in thread
From: John Kacur @ 2020-09-03 16:43 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Tue, 1 Sep 2020, Daniel Wagner wrote:

> When the quiet option is used don't print all threads stats. The first
> thread will pause every 16 cycles for 10000us. This will show up in
> the max values for all other threads when the final results are
> printed:
> 
>  # signaltest -q  -D 2s
>  T: 0 ( 4517) P: 0 C:   3121 Min:      5 Act:    8 Avg:    8 Max:      19
>  T: 1 ( 4518) P: 0 C:   3121 Min:      5 Act:10065 Avg:  639 Max:   10073
> 
> We could also remove the sleep but then the system gets fully loaded
> by the test. Furthermore, we would keep the path pretty hot and that's
> not ideal if one wants to test the eratic signal behavior. So only
> consider the first thread for the stats.
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/signaltest/signaltest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
> index 0bf075456ab6..679cb9792777 100644
> --- a/src/signaltest/signaltest.c
> +++ b/src/signaltest/signaltest.c
> @@ -417,7 +417,7 @@ int main(int argc, char **argv)
>  			pthread_kill(stat[i].thread, SIGTERM);
>  		if (stat[i].threadstarted) {
>  			pthread_join(stat[i].thread, NULL);
> -			if (quiet)
> +			if (quiet && i == 0)
>  				print_stat(&par[i], i, 0);
>  		}
>  		if (stat[i].values)
> -- 
> 2.28.0
> 
> 

Because of c operator precedence,
something like

if (quiet && i == 0)

is almost always wrong.

Most people mean

if ((quiet && i) == 0)

However, in your case, the first one actually does the right thing.

Just to make things clear, I think you should write

if (quiet && (i == 0)

Then the code is much clearer.

If that's what you intended, then please resubmit the patch and I'll apply 
it.

thanks

John


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

end of thread, other threads:[~2020-09-03 16:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 15:46 [rt-tests 0/4] Fix signaltest output when quiet Daniel Wagner
2020-09-01 15:46 ` [rt-tests 1/4] rt-utils: Move timestamp calc helper to common header Daniel Wagner
2020-09-03 16:36   ` John Kacur
2020-09-01 15:46 ` [rt-tests 2/4] rt-utils: Move time defininitions " Daniel Wagner
2020-09-03 16:37   ` John Kacur
2020-09-01 15:46 ` [rt-tests 3/4] rt-utils: Move ARRAY_SIZE " Daniel Wagner
2020-09-03 16:38   ` John Kacur
2020-09-01 15:46 ` [rt-tests 4/4] signaltest: Only print from the first thread stats when quiet Daniel Wagner
2020-09-03 16:43   ` John Kacur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).