All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] testsuite/smokey/sched-quote: Make more deterministic and simplify
@ 2021-02-15 17:41 Jan Kiszka
  2021-02-15 18:18 ` Philippe Gerum
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2021-02-15 17:41 UTC (permalink / raw
  To: Xenomai

From: Jan Kiszka <jan.kiszka@siemens.com>

As optimization can shrink __do_work to just two instruction, the
calibration loop needs to run longer.

At this chance, drop the pthread_kill to stop the thread and rely in
both cases on the throttle mechanism.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 testsuite/smokey/sched-quota/sched-quota.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/testsuite/smokey/sched-quota/sched-quota.c b/testsuite/smokey/sched-quota/sched-quota.c
index 5c35b551d8..ff7c584e39 100644
--- a/testsuite/smokey/sched-quota/sched-quota.c
+++ b/testsuite/smokey/sched-quota/sched-quota.c
@@ -199,13 +199,14 @@ static double run_quota(int quota)
 	req.tv_nsec = 0;
 	clock_nanosleep(CLOCK_MONOTONIC, 0, &req, NULL);
 
-	for (n = 0, count = 0; n < nrthreads; n++) {
+	for (n = 0, count = 0; n < nrthreads; n++)
 		count += counts[n];
-		pthread_kill(threads[n], SIGDEMT);
-	}
 
 	percent = ((double)count / TEST_SECS) * 100.0 / loops_per_sec;
 
+	atomic_set(&throttle, 1);
+	smp_wmb();
+
 	for (n = 0; n < nrthreads; n++) {
 		smokey_trace("done quota_thread[%d], count=%lu", n, counts[n]);
 		pthread_cancel(threads[n]);
@@ -224,7 +225,7 @@ static double run_quota(int quota)
 static unsigned long long calibrate(void)
 {
 	struct timespec start, end, delta;
-	const int crunch_loops = 10000;
+	const int crunch_loops = 100000;
 	unsigned long long ns, lps;
 	unsigned long count;
 	struct timespec req;
@@ -255,10 +256,8 @@ static unsigned long long calibrate(void)
 	req.tv_nsec = 0;
 	clock_nanosleep(CLOCK_MONOTONIC, 0, &req, NULL);
 
-	for (n = 0, lps = 0; n < nrthreads; n++) {
+	for (n = 0, lps = 0; n < nrthreads; n++)
 		lps += counts[n];
-		pthread_kill(threads[n], SIGDEMT);
-	}
 
 	atomic_set(&throttle, 1);
 	smp_wmb();
-- 
2.26.2


-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


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

* Re: [PATCH] testsuite/smokey/sched-quote: Make more deterministic and simplify
  2021-02-15 17:41 [PATCH] testsuite/smokey/sched-quote: Make more deterministic and simplify Jan Kiszka
@ 2021-02-15 18:18 ` Philippe Gerum
  2021-02-17 14:27   ` Jan Kiszka
  0 siblings, 1 reply; 3+ messages in thread
From: Philippe Gerum @ 2021-02-15 18:18 UTC (permalink / raw
  To: Jan Kiszka; +Cc: Xenomai


Jan Kiszka <jan.kiszka@siemens.com> writes:

> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> As optimization can shrink __do_work to just two instruction, the
> calibration loop needs to run longer.
>
> At this chance, drop the pthread_kill to stop the thread and rely in
> both cases on the throttle mechanism.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  testsuite/smokey/sched-quota/sched-quota.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/testsuite/smokey/sched-quota/sched-quota.c b/testsuite/smokey/sched-quota/sched-quota.c
> index 5c35b551d8..ff7c584e39 100644
> --- a/testsuite/smokey/sched-quota/sched-quota.c
> +++ b/testsuite/smokey/sched-quota/sched-quota.c
> @@ -199,13 +199,14 @@ static double run_quota(int quota)
>  	req.tv_nsec = 0;
>  	clock_nanosleep(CLOCK_MONOTONIC, 0, &req, NULL);
>  
> -	for (n = 0, count = 0; n < nrthreads; n++) {
> +	for (n = 0, count = 0; n < nrthreads; n++)
>  		count += counts[n];
> -		pthread_kill(threads[n], SIGDEMT);
> -	}
>  
>  	percent = ((double)count / TEST_SECS) * 100.0 / loops_per_sec;
>  
> +	atomic_set(&throttle, 1);
> +	smp_wmb();
> +
>  	for (n = 0; n < nrthreads; n++) {
>  		smokey_trace("done quota_thread[%d], count=%lu", n, counts[n]);
>  		pthread_cancel(threads[n]);
> @@ -224,7 +225,7 @@ static double run_quota(int quota)
>  static unsigned long long calibrate(void)
>  {
>  	struct timespec start, end, delta;
> -	const int crunch_loops = 10000;
> +	const int crunch_loops = 100000;
>  	unsigned long long ns, lps;
>  	unsigned long count;
>  	struct timespec req;
> @@ -255,10 +256,8 @@ static unsigned long long calibrate(void)
>  	req.tv_nsec = 0;
>  	clock_nanosleep(CLOCK_MONOTONIC, 0, &req, NULL);
>  
> -	for (n = 0, lps = 0; n < nrthreads; n++) {
> +	for (n = 0, lps = 0; n < nrthreads; n++)
>  		lps += counts[n];
> -		pthread_kill(threads[n], SIGDEMT);
> -	}
>  
>  	atomic_set(&throttle, 1);
>  	smp_wmb();
> -- 
> 2.26.2

Ack.

PS: another option for do_work() would have been to run hairy fp stuff
instead of a trivial integer increment, but I guess we don't care that
much if extending the loop count is enough.

-- 
Philippe.


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

* Re: [PATCH] testsuite/smokey/sched-quote: Make more deterministic and simplify
  2021-02-15 18:18 ` Philippe Gerum
@ 2021-02-17 14:27   ` Jan Kiszka
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kiszka @ 2021-02-17 14:27 UTC (permalink / raw
  To: Philippe Gerum; +Cc: Xenomai

On 15.02.21 19:18, Philippe Gerum wrote:
> 
> Jan Kiszka <jan.kiszka@siemens.com> writes:
> 
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> As optimization can shrink __do_work to just two instruction, the
>> calibration loop needs to run longer.
>>
>> At this chance, drop the pthread_kill to stop the thread and rely in
>> both cases on the throttle mechanism.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>>  testsuite/smokey/sched-quota/sched-quota.c | 13 ++++++-------
>>  1 file changed, 6 insertions(+), 7 deletions(-)
>>
>> diff --git a/testsuite/smokey/sched-quota/sched-quota.c b/testsuite/smokey/sched-quota/sched-quota.c
>> index 5c35b551d8..ff7c584e39 100644
>> --- a/testsuite/smokey/sched-quota/sched-quota.c
>> +++ b/testsuite/smokey/sched-quota/sched-quota.c
>> @@ -199,13 +199,14 @@ static double run_quota(int quota)
>>  	req.tv_nsec = 0;
>>  	clock_nanosleep(CLOCK_MONOTONIC, 0, &req, NULL);
>>  
>> -	for (n = 0, count = 0; n < nrthreads; n++) {
>> +	for (n = 0, count = 0; n < nrthreads; n++)
>>  		count += counts[n];
>> -		pthread_kill(threads[n], SIGDEMT);
>> -	}
>>  
>>  	percent = ((double)count / TEST_SECS) * 100.0 / loops_per_sec;
>>  
>> +	atomic_set(&throttle, 1);
>> +	smp_wmb();
>> +
>>  	for (n = 0; n < nrthreads; n++) {
>>  		smokey_trace("done quota_thread[%d], count=%lu", n, counts[n]);
>>  		pthread_cancel(threads[n]);
>> @@ -224,7 +225,7 @@ static double run_quota(int quota)
>>  static unsigned long long calibrate(void)
>>  {
>>  	struct timespec start, end, delta;
>> -	const int crunch_loops = 10000;
>> +	const int crunch_loops = 100000;
>>  	unsigned long long ns, lps;
>>  	unsigned long count;
>>  	struct timespec req;
>> @@ -255,10 +256,8 @@ static unsigned long long calibrate(void)
>>  	req.tv_nsec = 0;
>>  	clock_nanosleep(CLOCK_MONOTONIC, 0, &req, NULL);
>>  
>> -	for (n = 0, lps = 0; n < nrthreads; n++) {
>> +	for (n = 0, lps = 0; n < nrthreads; n++)
>>  		lps += counts[n];
>> -		pthread_kill(threads[n], SIGDEMT);
>> -	}
>>  
>>  	atomic_set(&throttle, 1);
>>  	smp_wmb();
>> -- 
>> 2.26.2
> 
> Ack.
> 
> PS: another option for do_work() would have been to run hairy fp stuff
> instead of a trivial integer increment, but I guess we don't care that
> much if extending the loop count is enough.
> 

Some target are stuck now over this test in our lab. So it seems I was
missing some reason other for this way of kicking the worker threads...

It's also confusing for me that the test generates totally off results
in QEMU instances. I would expect some deviations, eventually outlines,
but not now consistently low quota usage - unless I raise the quota to
50% or higher.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


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

end of thread, other threads:[~2021-02-17 14:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-15 17:41 [PATCH] testsuite/smokey/sched-quote: Make more deterministic and simplify Jan Kiszka
2021-02-15 18:18 ` Philippe Gerum
2021-02-17 14:27   ` Jan Kiszka

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.