clock_gettime01: avoid zero exec runtime due to irq and steal time accounting
PATCH 1/1 clock_gettime01: avoid zero exec runtime due to irq and steal time accounting
Test is sporadically failing on KVM guests with zero-ed timespec returned by CLOCK_{PROCESS,THREAD}_CPUTIME_ID. This can be reproduced on kernels v4.18 and v5.13-rc3 which have IRQ and PARAVIRT TIME ACCOUNTING enabled.
Task exectime is usually updated on call of clock_gettime(). But update_rq_clock_task() may not update clock_task if there's more unaccounted irq or steal time than rq->clock delta since last call. In this instance rq->clock_task does not advance and it is left for next update to account rest. Because LTP test is quick and checks only once, it sometimes sees zero timespec and treats it as failure.
Add a small warm-up to setup() in form of busy loop, to make sure that clock_task advanced. In case of bug we would either hit a timeout or still report zeroed timespec.
--- .../kernel/syscalls/clock_gettime/clock_gettime01.c | 9 +++++++++ 1 file changed, 9 insertions(+)
testcases/kernel/syscalls/clock_gettime/clock_gettime01.c +9 -0
@@ -73,7 +73,15 @@ static struct time64_variants variants[] = {static void setup (void ) { +long unsigned utime; +tst_res (TINFO ,"Testing variant: %s" , variants[tst_variant].desc); + +do { +SAFE_FILE_SCANF ("/proc/self/stat" , +"%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %lu" , + &utime); + }while (utime ==0 ); }static void verify_clock_gettime (unsigned int i)
@@ -118,4 +126,5 @@ static struct tst_test test = { .test_variants = ARRAY_SIZE(variants), .setup = setup, .needs_root = 1, + .timeout = 10, };
Signature · 1 line
2.27.0
PATCH 1/1 clock_gettime01: avoid zero exec runtime due to irq and steal time accounting
Hi!
Looks good: Reviewed-by: Cyril Hrubis <[email protected]>
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 clock_gettime01: avoid zero exec runtime due to irq and steal time accounting
Quoted 3 lines · Cyril Hrubis
Hi!
Looks good: Reviewed-by: Cyril Hrubis <[email protected]>
Thanks for review, pushed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210728/6e8cc8a8/attachment.htm>