tst_timer fixes
PATCH 1/1 tst_timer fixes
Hello LTP community,
As requested, I've split my previous patch into two and resigned from third change (hardening).
Please review these patches and add them to main stream.
Kind regards,
Piotr
Piotr Gawel (2):
tst_timer: fix qsort comparison function
tst_timer: fix verification of execution time
lib/tst_timer_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/1 tst_timer: fix qsort comparison function
From qsort() manual:
The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. If two members compare as equal, their order in the sorted array is undefined.
We need it in descending order so the logic is reverted.
--- lib/tst_timer_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tst_timer_test.c +1 -1
@@ -159,7 +159,7 @@ static int cmp(const void *a, const void *b) {const long long *aa = a, *bb = b; -return *aa < *bb; +return (*bb - *aa); }/*
Signature · 1 line
2.7.4
PATCH 1/1 tst_timer: fix qsort comparison function
Hi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 tst_timer: fix verification of execution time
In reply to Piotr GawelEach sample needs to be in range:
t < s[i] < t + threshold
Thus for i from the interval [d...n]:
(n-d)*t < sum(s[d...n]) < (n-d)*(t + threshold)
This patch fixes that check.
--- lib/tst_timer_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tst_timer_test.c +1 -1
@@ -306,7 +306,7 @@ void do_timer_test(long long usec, unsigned int nsamples) samples[nsamples-1 ], samples[0 ], median, 1.00 * trunc_mean / keep_samples, discard); -if (trunc_mean > (nsamples - discard) * usec + threshold) { +if (trunc_mean > keep_samples * (usec + threshold)) {tst_res (TFAIL ,"%s slept for too long" , scall);if (!print_frequency_plot)
Signature · 1 line
2.7.4
PATCH 1/1 tst_timer: fix verification of execution time
Hi!
Quoted 5 lines
Each sample needs to be in range:
t < s[i] < t + threshold
Thus for i from the interval [d...n]:(n-d)*t < sum(s[d...n]) < (n-d)*(t + threshold)This patch fixes that check.
As far as I can tell the function compute_treshold() multiplies the threshold per call by keep_samples already, so it's a threashold per run not a treshold per call, or do I miss something?
Quoted 23 lines
Signed-off-by Piotr Gawel <[email protected]>--- lib/tst_timer_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/tst_timer_test.c +1
-1@@ -306,7 +306,7 @@ void do_timer_test(long long usec, unsigned int nsamples) samples[nsamples-1 ], samples[0 ], median, 1.00 * trunc_mean / keep_samples, discard); -if (trunc_mean > (nsamples - discard) * usec + threshold) { +if (trunc_mean > keep_samples * (usec + threshold)) {tst_res (TFAIL ,"%s slept for too long" , scall);if (!print_frequency_plot)Signature · 5 lines
2.7.4 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 tst_timer: fix verification of execution time
Hi,Oops. I missed that. Please reject this patch.BR, PiotrWys?ano z mojego smartfona Samsung Galaxy.
-------- Oryginalna wiadomo?? --------Od: Cyril Hrubis <[email protected]> Data: 25.07.2019 16:45 (GMT+01:00) Do: Piotr Gawel <[email protected]> DW: [email protected] Temat: Re: [LTP] [PATCH] tst_timer: fix verification of execution time Hi!> Each sample needs to be in range:>???? t < s[i] < t + threshold> Thus for i from the interval [d...n]:>???? (n-d)*t < sum(s[d...n]) < (n-d)*(t + threshold)> This patch fixes that check.As far as I can tell the function compute_treshold() multiplies thethreshold per call by keep_samples already, so it's a threashold per runnot a treshold per call, or do I miss something?> Signed-off-by: Piotr Gawel <[email protected]>> --->? lib/tst_timer_test.c | 2 +->? 1 file changed, 1 insertion(+), 1 deletion(-)> > diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c> index f6459e5..4508e29 100644> --- a/lib/tst_timer_test.c> +++ b/lib/tst_timer_test.c> @@ -306,7 +306,7 @@ void do_timer_test(long long usec, unsigned int nsamples)>? samples[nsamples-1], samples[0], median,>? 1.00 * trunc_mean / keep_samples, discard);>? > - if (trunc_mean > (nsamples - discard) * usec + threshold) {> + if (trunc_mean > keep_samples * (usec + threshold)) {>? tst_res(TFAIL, "%s slept for too long", scall);>? if (!print_frequency_plot)> -- > 2.7.4> > > -- > Mailing list info: https://lists.linux.it/listinfo/ltp-- Cyril [email protected]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190725/2c4d35e6/attachment.htm>