diff mbox series

[v2] cyclicdeadline: removed extra pthread_barrier_wait() calls

Message ID 20230809144855.143778-1-ashelat@redhat.com
State New
Headers show
Series [v2] cyclicdeadline: removed extra pthread_barrier_wait() calls | expand

Commit Message

Anubhav Shelat Aug. 9, 2023, 2:48 p.m. UTC
Before this change, cyclicdeadline was giving abnormally high latencies
and occasionally locking up on start, uncharacteristic of an RT system.
After removing the extra calls, the latencies were more in line with
what we expected and there were no lock-ups on run.

Test runs, courtesy of Clark Williams (aarch64 system running RT kernel):

Cmd Line: $ sudo ./cyclicdeadline -t8 -a8-15 -D 5m

The first three test runs were from the current main branch of realtime-tests:

First run

T: 0 ( 2074) I:1000 C: 300007 Min:      1 Act:   11 Avg:   10 Max:      34
T: 1 ( 2075) I:1500 C: 200005 Min:      1 Act:   12 Avg:   10 Max:      30
T: 2 ( 2076) I:2000 C: 150004 Min:      1 Act:   14 Avg:   11 Max:      36
T: 3 ( 2077) I:2500 C: 120003 Min:      1 Act:   11 Avg:   10 Max:      42
T: 4 ( 2078) I:3000 C: 100003 Min:      1 Act:   13 Avg:    6 Max:      35
T: 5 ( 2079) I:3500 C:  85717 Min:      1 Act:    3 Avg:    8 Max:      28
T: 6 ( 2080) I:4000 C:  75002 Min:      1 Act:   11 Avg:   10 Max:      43
T: 7 ( 2081) I:4500 C:  66669 Min:      1 Act:   13 Avg:   10 Max:      31

Second run

T: 0 ( 2074) I:1000 C: 300007 Min:      1 Act:   11 Avg:   10 Max:      34
T: 1 ( 2075) I:1500 C: 200005 Min:      1 Act:   12 Avg:   10 Max:      30
T: 2 ( 2076) I:2000 C: 150004 Min:      1 Act:   14 Avg:   11 Max:      36
T: 3 ( 2077) I:2500 C: 120003 Min:      1 Act:   11 Avg:   10 Max:      42
T: 4 ( 2078) I:3000 C: 100003 Min:      1 Act:   13 Avg:    6 Max:      35
T: 5 ( 2079) I:3500 C:  85717 Min:      1 Act:    3 Avg:    8 Max:      28
T: 6 ( 2080) I:4000 C:  75002 Min:      1 Act:   11 Avg:   10 Max:      43
T: 7 ( 2081) I:4500 C:  66669 Min:      1 Act:   13 Avg:   10 Max:      31

Third Run

T: 0 ( 2199) I:1000 C: 300007 Min:      1 Act:   12 Avg:   11 Max:      35
T: 1 ( 2200) I:1500 C: 200005 Min:      1 Act:   13 Avg:   12 Max:      36
T: 2 ( 2201) I:2000 C: 150004 Min:      1 Act:   14 Avg:   12 Max:      42
T: 3 ( 2202) I:2500 C: 120003 Min:      2 Act:   16 Avg:   13 Max:      36
T: 4 ( 2203) I:3000 C: 100003 Min:      1 Act:   10 Avg:    7 Max:      31
T: 5 ( 2204) I:3500 C:  85717 Min:      1 Act:   11 Avg:   10 Max:      35
T: 6 ( 2205) I:4000 C:  75002 Min:      1 Act:   11 Avg:   10 Max:      26
T: 7 ( 2206) I:4500 C:  66669 Min:      1 Act:   17 Avg:   12 Max:      35

The second three runs were on the same system but with code that has the pthread_barrier_wait() calls fixed

First run

T: 0 ( 4131) I:1000 C: 300004 Min:      1 Act:    3 Avg:    8 Max:      38
T: 1 ( 4132) I:1500 C: 200003 Min:      1 Act:   13 Avg:    6 Max:      32
T: 2 ( 4133) I:2000 C: 150002 Min:      1 Act:   12 Avg:    8 Max:      31
T: 3 ( 4134) I:2500 C: 120002 Min:      1 Act:   11 Avg:   10 Max:      32
T: 4 ( 4135) I:3000 C: 100002 Min:      1 Act:   11 Avg:   10 Max:      30
T: 5 ( 4136) I:3500 C:  85716 Min:      1 Act:   12 Avg:   10 Max:      35
T: 6 ( 4137) I:4000 C:  75001 Min:      1 Act:   11 Avg:   10 Max:      33
T: 7 ( 4138) I:4500 C:  66668 Min:      1 Act:   10 Avg:    9 Max:      28

Second run
T: 0 ( 4353) I:1000 C: 300006 Min:      1 Act:   13 Avg:   10 Max:      34
T: 1 ( 4354) I:1500 C: 200004 Min:      1 Act:   13 Avg:   11 Max:      28
T: 2 ( 4355) I:2000 C: 150003 Min:      1 Act:   13 Avg:   11 Max:      32
T: 3 ( 4356) I:2500 C: 120003 Min:      1 Act:   13 Avg:   11 Max:      38
T: 4 ( 4357) I:3000 C: 100002 Min:      1 Act:   12 Avg:   11 Max:      29
T: 5 ( 4358) I:3500 C:  85716 Min:      1 Act:   11 Avg:   11 Max:      31
T: 6 ( 4359) I:4000 C:  75002 Min:      1 Act:   11 Avg:   10 Max:      32
T: 7 ( 4360) I:4500 C:  66668 Min:      1 Act:    3 Avg:    2 Max:      19

Third run
T: 0 ( 4426) I:1000 C: 300006 Min:      1 Act:   13 Avg:    8 Max:      43
T: 1 ( 4427) I:1500 C: 200004 Min:      1 Act:    2 Avg:    6 Max:      25
T: 2 ( 4428) I:2000 C: 150003 Min:      1 Act:   11 Avg:    9 Max:      30
T: 3 ( 4429) I:2500 C: 120003 Min:      2 Act:   12 Avg:   11 Max:      31
T: 4 ( 4430) I:3000 C: 100002 Min:      1 Act:   12 Avg:   11 Max:      33
T: 5 ( 4431) I:3500 C:  85716 Min:      1 Act:   12 Avg:   10 Max:      31
T: 6 ( 4432) I:4000 C:  75002 Min:      2 Act:   13 Avg:   12 Max:      36
T: 7 ( 4433) I:4500 C:  66668 Min:      1 Act:   12 Avg:   10 Max:      30

Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
---
 src/sched_deadline/cyclicdeadline.c | 8 --------
 1 file changed, 8 deletions(-)

Comments

John Kacur Aug. 9, 2023, 6:19 p.m. UTC | #1
On Wed, 9 Aug 2023, Anubhav Shelat wrote:

> Before this change, cyclicdeadline was giving abnormally high latencies
> and occasionally locking up on start, uncharacteristic of an RT system.
> After removing the extra calls, the latencies were more in line with
> what we expected and there were no lock-ups on run.
> 
> Test runs, courtesy of Clark Williams (aarch64 system running RT kernel):
> 
> Cmd Line: $ sudo ./cyclicdeadline -t8 -a8-15 -D 5m
> 
> The first three test runs were from the current main branch of realtime-tests:
> 
> First run
> 
> T: 0 ( 2074) I:1000 C: 300007 Min:      1 Act:   11 Avg:   10 Max:      34
> T: 1 ( 2075) I:1500 C: 200005 Min:      1 Act:   12 Avg:   10 Max:      30
> T: 2 ( 2076) I:2000 C: 150004 Min:      1 Act:   14 Avg:   11 Max:      36
> T: 3 ( 2077) I:2500 C: 120003 Min:      1 Act:   11 Avg:   10 Max:      42
> T: 4 ( 2078) I:3000 C: 100003 Min:      1 Act:   13 Avg:    6 Max:      35
> T: 5 ( 2079) I:3500 C:  85717 Min:      1 Act:    3 Avg:    8 Max:      28
> T: 6 ( 2080) I:4000 C:  75002 Min:      1 Act:   11 Avg:   10 Max:      43
> T: 7 ( 2081) I:4500 C:  66669 Min:      1 Act:   13 Avg:   10 Max:      31
> 
> Second run
> 
> T: 0 ( 2074) I:1000 C: 300007 Min:      1 Act:   11 Avg:   10 Max:      34
> T: 1 ( 2075) I:1500 C: 200005 Min:      1 Act:   12 Avg:   10 Max:      30
> T: 2 ( 2076) I:2000 C: 150004 Min:      1 Act:   14 Avg:   11 Max:      36
> T: 3 ( 2077) I:2500 C: 120003 Min:      1 Act:   11 Avg:   10 Max:      42
> T: 4 ( 2078) I:3000 C: 100003 Min:      1 Act:   13 Avg:    6 Max:      35
> T: 5 ( 2079) I:3500 C:  85717 Min:      1 Act:    3 Avg:    8 Max:      28
> T: 6 ( 2080) I:4000 C:  75002 Min:      1 Act:   11 Avg:   10 Max:      43
> T: 7 ( 2081) I:4500 C:  66669 Min:      1 Act:   13 Avg:   10 Max:      31
> 
> Third Run
> 
> T: 0 ( 2199) I:1000 C: 300007 Min:      1 Act:   12 Avg:   11 Max:      35
> T: 1 ( 2200) I:1500 C: 200005 Min:      1 Act:   13 Avg:   12 Max:      36
> T: 2 ( 2201) I:2000 C: 150004 Min:      1 Act:   14 Avg:   12 Max:      42
> T: 3 ( 2202) I:2500 C: 120003 Min:      2 Act:   16 Avg:   13 Max:      36
> T: 4 ( 2203) I:3000 C: 100003 Min:      1 Act:   10 Avg:    7 Max:      31
> T: 5 ( 2204) I:3500 C:  85717 Min:      1 Act:   11 Avg:   10 Max:      35
> T: 6 ( 2205) I:4000 C:  75002 Min:      1 Act:   11 Avg:   10 Max:      26
> T: 7 ( 2206) I:4500 C:  66669 Min:      1 Act:   17 Avg:   12 Max:      35
> 
> The second three runs were on the same system but with code that has the pthread_barrier_wait() calls fixed
> 
> First run
> 
> T: 0 ( 4131) I:1000 C: 300004 Min:      1 Act:    3 Avg:    8 Max:      38
> T: 1 ( 4132) I:1500 C: 200003 Min:      1 Act:   13 Avg:    6 Max:      32
> T: 2 ( 4133) I:2000 C: 150002 Min:      1 Act:   12 Avg:    8 Max:      31
> T: 3 ( 4134) I:2500 C: 120002 Min:      1 Act:   11 Avg:   10 Max:      32
> T: 4 ( 4135) I:3000 C: 100002 Min:      1 Act:   11 Avg:   10 Max:      30
> T: 5 ( 4136) I:3500 C:  85716 Min:      1 Act:   12 Avg:   10 Max:      35
> T: 6 ( 4137) I:4000 C:  75001 Min:      1 Act:   11 Avg:   10 Max:      33
> T: 7 ( 4138) I:4500 C:  66668 Min:      1 Act:   10 Avg:    9 Max:      28
> 
> Second run
> T: 0 ( 4353) I:1000 C: 300006 Min:      1 Act:   13 Avg:   10 Max:      34
> T: 1 ( 4354) I:1500 C: 200004 Min:      1 Act:   13 Avg:   11 Max:      28
> T: 2 ( 4355) I:2000 C: 150003 Min:      1 Act:   13 Avg:   11 Max:      32
> T: 3 ( 4356) I:2500 C: 120003 Min:      1 Act:   13 Avg:   11 Max:      38
> T: 4 ( 4357) I:3000 C: 100002 Min:      1 Act:   12 Avg:   11 Max:      29
> T: 5 ( 4358) I:3500 C:  85716 Min:      1 Act:   11 Avg:   11 Max:      31
> T: 6 ( 4359) I:4000 C:  75002 Min:      1 Act:   11 Avg:   10 Max:      32
> T: 7 ( 4360) I:4500 C:  66668 Min:      1 Act:    3 Avg:    2 Max:      19
> 
> Third run
> T: 0 ( 4426) I:1000 C: 300006 Min:      1 Act:   13 Avg:    8 Max:      43
> T: 1 ( 4427) I:1500 C: 200004 Min:      1 Act:    2 Avg:    6 Max:      25
> T: 2 ( 4428) I:2000 C: 150003 Min:      1 Act:   11 Avg:    9 Max:      30
> T: 3 ( 4429) I:2500 C: 120003 Min:      2 Act:   12 Avg:   11 Max:      31
> T: 4 ( 4430) I:3000 C: 100002 Min:      1 Act:   12 Avg:   11 Max:      33
> T: 5 ( 4431) I:3500 C:  85716 Min:      1 Act:   12 Avg:   10 Max:      31
> T: 6 ( 4432) I:4000 C:  75002 Min:      2 Act:   13 Avg:   12 Max:      36
> T: 7 ( 4433) I:4500 C:  66668 Min:      1 Act:   12 Avg:   10 Max:      30
> 
> Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
> ---
>  src/sched_deadline/cyclicdeadline.c | 8 --------
>  1 file changed, 8 deletions(-)
> 
> diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
> index 48b82e7efb01..39aeeb5d0785 100644
> --- a/src/sched_deadline/cyclicdeadline.c
> +++ b/src/sched_deadline/cyclicdeadline.c
> @@ -807,8 +807,6 @@ void *run_deadline(void *data)
>  		return NULL;
>  	}
>  
> -	pthread_barrier_wait(&barrier);
> -
>  	attr.sched_policy = SCHED_DEADLINE;
>  	attr.sched_runtime = sd->runtime_us * 1000;
>  	attr.sched_deadline = sd->deadline_us * 1000;
> @@ -816,8 +814,6 @@ void *run_deadline(void *data)
>  	printf("thread[%d] runtime=%lldus deadline=%lldus\n",
>  	      gettid(), sd->runtime_us, sd->deadline_us);
>  
> -	pthread_barrier_wait(&barrier);
> -
>  	ret = sched_setattr(0, &attr, 0);
>  	if (ret < 0) {
>  		err_msg_n(errno, "[%ld]", tid);
> @@ -1281,8 +1277,6 @@ int main(int argc, char **argv)
>  
>  	atexit(teardown);
>  
> -	pthread_barrier_wait(&barrier);
> -
>  	if (shutdown)
>  		fatal("failed to setup child threads at step 1\n");
>  
> @@ -1312,8 +1306,6 @@ int main(int argc, char **argv)
>  
>  	printf("main thread %d\n", gettid());
>  
> -	pthread_barrier_wait(&barrier);
> -
>  	if (shutdown)
>  		fatal("failed to setup child threads at step 2");
>  
> -- 
> 2.39.3
> 
> 
Nice
Signed-off-by: John Kacur <jkacur@redhat.com>
diff mbox series

Patch

diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 48b82e7efb01..39aeeb5d0785 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -807,8 +807,6 @@  void *run_deadline(void *data)
 		return NULL;
 	}
 
-	pthread_barrier_wait(&barrier);
-
 	attr.sched_policy = SCHED_DEADLINE;
 	attr.sched_runtime = sd->runtime_us * 1000;
 	attr.sched_deadline = sd->deadline_us * 1000;
@@ -816,8 +814,6 @@  void *run_deadline(void *data)
 	printf("thread[%d] runtime=%lldus deadline=%lldus\n",
 	      gettid(), sd->runtime_us, sd->deadline_us);
 
-	pthread_barrier_wait(&barrier);
-
 	ret = sched_setattr(0, &attr, 0);
 	if (ret < 0) {
 		err_msg_n(errno, "[%ld]", tid);
@@ -1281,8 +1277,6 @@  int main(int argc, char **argv)
 
 	atexit(teardown);
 
-	pthread_barrier_wait(&barrier);
-
 	if (shutdown)
 		fatal("failed to setup child threads at step 1\n");
 
@@ -1312,8 +1306,6 @@  int main(int argc, char **argv)
 
 	printf("main thread %d\n", gettid());
 
-	pthread_barrier_wait(&barrier);
-
 	if (shutdown)
 		fatal("failed to setup child threads at step 2");