Skip to contentSkip to conversation

tests: sched-quota: Synchronize all threads before readings stats

PATCH Applied Jan Kiszka 2 participants 2 messages Aug 31 – Sep 4

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 tests: sched-quota: Synchronize all threads before readings stats

From: Jan Kiszka <[email protected]>

The quota threads may complete their work in a random order. Wait for them all first before starting to read out their stats. This avoids inconsistencies.

---
 tests/sched-quota-accuracy.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tests/sched-quota-accuracy.c +4 -2
index 2a2dc38..1bf5eb9 100644
@@ -275,8 +275,9 @@ static struct accuracy_results run_quota(void)
 	 * number of loops we should be able to run during the
 	 * allotted quota, even in case of runtime disruption.
 	 */
-	for (n = 0, loops_at_calibration = 0; n < nrthreads; n++) {
+	for (n = 0; n < nrthreads; n++)
 		__Tcall_assert(ret, evl_get_sem(&ready));
+	for (n = 0, loops_at_calibration = 0; n < nrthreads; n++) {
 		do_trace("CPU%d: calibration: quota_thread[%d]: %llu loops",
 			test_cpu, n, threads[n].loops);
 		loops_at_calibration += threads[n].loops;
@@ -292,8 +293,9 @@ static struct accuracy_results run_quota(void)
 	 * Wait for the accuracy measurement to end, then collect the
 	 * numbers.
 	 */
-	for (n = 0, loops_at_accuracy = 0; n < nrthreads; n++) {
+	for (n = 0; n < nrthreads; n++)
 		__Tcall_assert(ret, evl_get_sem(&ready));
+	for (n = 0, loops_at_accuracy = 0; n < nrthreads; n++) {
 		do_trace("CPU%d: accuracy: quota_thread[%d]: %llu loops",
 			test_cpu, n, threads[n].loops);
 		loops_at_accuracy += threads[n].loops;
Signature · 1 line
2.47.3
#1 lore raw
Quoted 27 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

The quota threads may complete their work in a random order. Wait for them all first before starting to read out their stats. This avoids inconsistencies.

---
 tests/sched-quota-accuracy.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tests/sched-quota-accuracy.c +2 -1
index 2a2dc38..1bf5eb9 100644
@@ -275,8 +275,9 @@ static struct accuracy_results run_quota(void)
 	 * number of loops we should be able to run during the
 	 * allotted quota, even in case of runtime disruption.
 	 */
-	for (n = 0, loops_at_calibration = 0; n < nrthreads; n++) {
+	for (n = 0; n < nrthreads; n++)
 		__Tcall_assert(ret, evl_get_sem(&ready));
+	for (n = 0, loops_at_calibration = 0; n < nrthreads; n++) {
 		do_trace("CPU%d: calibration: quota_thread[%d]: %llu loops",
 			test_cpu, n, threads[n].loops);
 		loops_at_calibration += threads[n].loops;

tests/sched-quota-accuracy.c static struct accuracy_results run_quota(void) · line 301

Quoted 10 lines
tests/sched-quota-accuracy.c +2 -1
@@ -292,8 +293,9 @@ static struct accuracy_results run_quota(void)
 	 * Wait for the accuracy measurement to end, then collect the
 	 * numbers.
 	 */
-	for (n = 0, loops_at_accuracy = 0; n < nrthreads; n++) {
+	for (n = 0; n < nrthreads; n++)
 		__Tcall_assert(ret, evl_get_sem(&ready));
+	for (n = 0, loops_at_accuracy = 0; n < nrthreads; n++) {
 		do_trace("CPU%d: accuracy: quota_thread[%d]: %llu loops",
 			test_cpu, n, threads[n].loops);
 		loops_at_accuracy += threads[n].loops;

Merged, thanks.

Signature · 1 line
Philippe.