* [LTP] [PATCH] tst_timer fixes
@ 2019-07-24 18:23 Piotr Gawel
2019-07-24 18:23 ` [LTP] [PATCH] tst_timer: fix qsort comparison function Piotr Gawel
2019-07-24 18:23 ` [LTP] [PATCH] tst_timer: fix verification of execution time Piotr Gawel
0 siblings, 2 replies; 6+ messages in thread
From: Piotr Gawel @ 2019-07-24 18:23 UTC (permalink / raw)
To: ltp
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(-)
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH] tst_timer: fix qsort comparison function
2019-07-24 18:23 [LTP] [PATCH] tst_timer fixes Piotr Gawel
@ 2019-07-24 18:23 ` Piotr Gawel
2019-07-25 14:39 ` Cyril Hrubis
2019-07-24 18:23 ` [LTP] [PATCH] tst_timer: fix verification of execution time Piotr Gawel
1 sibling, 1 reply; 6+ messages in thread
From: Piotr Gawel @ 2019-07-24 18:23 UTC (permalink / raw)
To: ltp
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.
Signed-off-by: Piotr Gawel <piotr.krzysztof.gawel@gmail.com>
---
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 4c16b59..f6459e5 100644
--- a/lib/tst_timer_test.c
+++ b/lib/tst_timer_test.c
@@ -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);
}
/*
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH] tst_timer: fix verification of execution time
2019-07-24 18:23 [LTP] [PATCH] tst_timer fixes Piotr Gawel
2019-07-24 18:23 ` [LTP] [PATCH] tst_timer: fix qsort comparison function Piotr Gawel
@ 2019-07-24 18:23 ` Piotr Gawel
2019-07-25 14:45 ` Cyril Hrubis
1 sibling, 1 reply; 6+ messages in thread
From: Piotr Gawel @ 2019-07-24 18:23 UTC (permalink / raw)
To: ltp
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.
Signed-off-by: Piotr Gawel <piotr.krzysztof.gawel@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH] tst_timer: fix qsort comparison function
2019-07-24 18:23 ` [LTP] [PATCH] tst_timer: fix qsort comparison function Piotr Gawel
@ 2019-07-25 14:39 ` Cyril Hrubis
0 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2019-07-25 14:39 UTC (permalink / raw)
To: ltp
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH] tst_timer: fix verification of execution time
2019-07-24 18:23 ` [LTP] [PATCH] tst_timer: fix verification of execution time Piotr Gawel
@ 2019-07-25 14:45 ` Cyril Hrubis
2019-07-25 18:04 ` piotr.krzysztof.gawel
0 siblings, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2019-07-25 14:45 UTC (permalink / raw)
To: ltp
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 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?
> Signed-off-by: Piotr Gawel <piotr.krzysztof.gawel@gmail.com>
> ---
> 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 Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH] tst_timer: fix verification of execution time
2019-07-25 14:45 ` Cyril Hrubis
@ 2019-07-25 18:04 ` piotr.krzysztof.gawel
0 siblings, 0 replies; 6+ messages in thread
From: piotr.krzysztof.gawel @ 2019-07-25 18:04 UTC (permalink / raw)
To: ltp
Hi,Oops. I missed that. Please reject this patch.BR, PiotrWys?ano z mojego smartfona Samsung Galaxy.
-------- Oryginalna wiadomo?? --------Od: Cyril Hrubis <chrubis@suse.cz> Data: 25.07.2019 16:45 (GMT+01:00) Do: Piotr Gawel <piotr.krzysztof.gawel@gmail.com> DW: ltp@lists.linux.it 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 <piotr.krzysztof.gawel@gmail.com>> --->? 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 Hrubischrubis@suse.cz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190725/2c4d35e6/attachment.htm>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-07-25 18:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-24 18:23 [LTP] [PATCH] tst_timer fixes Piotr Gawel
2019-07-24 18:23 ` [LTP] [PATCH] tst_timer: fix qsort comparison function Piotr Gawel
2019-07-25 14:39 ` Cyril Hrubis
2019-07-24 18:23 ` [LTP] [PATCH] tst_timer: fix verification of execution time Piotr Gawel
2019-07-25 14:45 ` Cyril Hrubis
2019-07-25 18:04 ` piotr.krzysztof.gawel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox