<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Andrea,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Andrea Cervesato via ltp <<a href="mailto:ltp@lists.linux.it" target="_blank">ltp@lists.linux.it</a>> wrote:<br></div><div dir="ltr" class="gmail_attr"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Last test rewrite didn't consider the right expected boundaries when<br>
setitimer syscall was tested. We also introduced counter times as<br>
multiple of clock resolution, to avoid kernel rounding during setitimer<br>
counter increase.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Good catch, but I'm afraid this can not solve the problem thoroughly.</div><div class="gmail_default" style="font-size:small">According failure log on "ITIMER_VIRTUAL/PROF" with running this patch.:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">setitimer01.c:64: TINFO: tc->which = ITIMER_VIRTUAL<br>setitimer01.c:69: TPASS: sys_setitimer(tc->which, value, NULL) passed<br>setitimer01.c:72: TPASS: sys_setitimer(tc->which, value, ovalue) passed<br>setitimer01.c:76: TINFO: tv_sec=0, tv_usec=31000<br>setitimer01.c:79: TFAIL: Ending counters are out of range</div><div class="gmail_default" style="font-size:small">setitimer01.c:88: TPASS: Child received signal: SIGVTALRM</div><div class="gmail_default" style="font-size:small"><br>setitimer01.c:64: TINFO: tc->which = ITIMER_PROF<br>setitimer01.c:69: TPASS: sys_setitimer(tc->which, value, NULL) passed<br>setitimer01.c:72: TPASS: sys_setitimer(tc->which, value, ovalue) passed<br>setitimer01.c:76: TINFO: tv_sec=0, tv_usec=31000<br>setitimer01.c:79: TFAIL: Ending counters are out of range</div><div class="gmail_default" style="font-size:small">setitimer01.c:88: TPASS: Child received signal: SIGPROF<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">It seems the tv_usec always increase 1000us, I highly suspect</div><div class="gmail_default" style="font-size:small">this increase comes from kernel function set_cpu_itimer() that</div><div class="gmail_default" style="font-size:small">explicitly add TICK_NSEC when 'nval' is larger than zero:</div><br></div><div><div class="gmail_default" style="font-size:small">$ cat kernel/time/itimer.c -n</div><div class="gmail_default" style="font-size:small"> ...</div><div class="gmail_default" style="font-size:small"> 168 static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id,<br> 169 const struct itimerspec64 *const value,<br> 170 struct itimerspec64 *const ovalue)<br> 171 {<br> ...<br> 182 if (oval || nval) {<br> 183 if (nval > 0)<br> 184 nval += TICK_NSEC;<br> 185 set_process_cpu_timer(tsk, clock_id, &nval, &oval);<br> 186 }<br> 187 ...<br> 198 }<br></div><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_default" style="font-size:small">To verify my guess, I do a modification based on your patch and</div><div class="gmail_default" style="font-size:small">then easily get the result in pass.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--- a/testcases/kernel/syscalls/setitimer/setitimer01.c<br>+++ b/testcases/kernel/syscalls/setitimer/setitimer01.c<br>@@ -76,7 +76,7 @@ static void verify_setitimer(unsigned int i)<br> ovalue->it_value.tv_sec,<br> ovalue->it_value.tv_usec);<br> <br>- if (ovalue->it_value.tv_sec != 0 || ovalue->it_value.tv_usec > usec)<br>+ if (ovalue->it_value.tv_sec != 0 || ovalue->it_value.tv_usec - time_step > usec)<br> tst_res(TFAIL, "Ending counters are out of range");<br> <br> for (;;)<br>@@ -98,8 +98,8 @@ static void setup(void)<br> SAFE_CLOCK_GETRES(CLOCK_MONOTONIC, &res);<br> <br> time_step = res.tv_nsec / 1000;<br>- if (time_step < 10000)<br>- time_step = 10000;<br>+ if (time_step < 1000)<br>+ time_step = 1000;<br> <br> tst_res(TINFO, "clock resolution: %luns, time step: %luus",<br> res.tv_nsec,<br></div><div> </div></div><div><br></div><div><div class="gmail_default" style="font-size:small">But after trying this with my RasberryPi4, it fails again with an increase</div><div class="gmail_default" style="font-size:small">4000us each time. So it might related to the system use different time</div><div class="gmail_default" style="font-size:small">resolutions. When I shift to use `CLOCK_MONOTONIC_COARSE`</div></div><div class="gmail_default" style="font-size:small">then test gets passed on all my platforms.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Any comments?</div><div class="gmail_default" style="font-size:small"><br></div><div><br></div><div><div class="gmail_default" style="font-size:small">----------CLOCK_MONOTONIC-------------</div></div><div><div class="gmail_default" style="font-size:small">setitimer01.c:65: TINFO: tc->which = ITIMER_VIRTUAL<br>setitimer01.c:70: TPASS: sys_setitimer(tc->which, value, NULL) passed<br>setitimer01.c:73: TPASS: sys_setitimer(tc->which, value, ovalue) passed<br>setitimer01.c:77: TINFO: tv_sec=0, tv_usec=7000<br>setitimer01.c:80: TFAIL: Ending counters are out of range</div><br><div class="gmail_default" style="font-size:small">-----------CLOCK_MONOTONIC_COARSE-------</div></div><div><div class="gmail_default" style="font-size:small">setitimer01.c:65: TINFO: tc->which = ITIMER_VIRTUAL<br>setitimer01.c:70: TPASS: sys_setitimer(tc->which, value, NULL) passed<br>setitimer01.c:73: TPASS: sys_setitimer(tc->which, value, ovalue) passed<br>setitimer01.c:77: TINFO: tv_sec=0, tv_usec=16000<br>setitimer01.c:89: TPASS: Child received signal: SIGVTALRM<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"># lscpu <br>Architecture: aarch64<br>Byte Order: Little Endian<br>CPU(s): 4<br>On-line CPU(s) list: 0-3<br>Thread(s) per core: 1<br>Core(s) per cluster: 4<br>Socket(s): -<br>Cluster(s): 1<br>Vendor ID: ARM<br>Model: 3<br>Model name: Cortex-A72<br>Stepping: r0p3<br>CPU max MHz: 1500.0000<br>CPU min MHz: 600.0000<br>BogoMIPS: 108.00<br>Flags: fp asimd evtstrm crc32 cpuid<br></div><div class="gmail_default" style="font-size:small"></div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>