[LTP] [PATCH 1/2] setitimer01: add interval timer test

Richard Palethorpe rpalethorpe@suse.de
Tue Nov 15 12:04:36 CET 2022


Hello,

Li Wang <liwang@redhat.com> writes:

> On Tue, Nov 15, 2022 at 6:00 PM Li Wang <liwang@redhat.com> wrote:
>
>  Richard Palethorpe <rpalethorpe@suse.de> wrote:
>   
>  >  
>  >  Practically speaking we have to assume a large amount of time has passed
>  >  when using ITIMER_REAL. It has to be *much* larger than a VM is likely
>  >  to be paused for and then successfully resumed. Or the amount of time a
>  >  clock may be corrected by (for e.g. with NTP).
>  >
>  > Hmm, not sure if I understand correctly above, will that
>  > timer value be out of the range but reasonable?
>  >
>  > Or is there any additional situation we should cover?
>
>  Sorry that is confusing.
>
>  The question is what happens if the clock jumps backwards?
>
>  I don't see anything which says it_value.tv_sec can't go out of
>  range. OTOH I would expect it to compensate for large jumps in time.
>
>  If the test randomly fails because it_value.tv_sec > time_sec then what
>  action will we take?
>
> Or, we do nothing on this, just let the test report TFAIL, because that
> is not what this test can control.
>
>  
>  
>  How about increasing the time_sec on virtual machine?

It could happen on bare metal as well.

>
>  Seems no perfect way to completely resolve but only reducing
>  the odds of happening. 
>
>  Or do you have another better suggestion?

TBH I don't know if it will happen. An acceptable outcome for me is to
print the time at the beginning and end of the test. Then if the test
fails we can see if it was due to a time jump and start investigating
what the kernel is supposed to do in this case.

The alternative is to find out now what the kernel should do. We could
also write a test which deliberately changes the system time during an
interval. Depending how motivated you are.

>
>  --- a/testcases/kernel/syscalls/setitimer/setitimer01.c
>  +++ b/testcases/kernel/syscalls/setitimer/setitimer01.c
>  @@ -142,6 +142,11 @@ static void setup(void)
>   
>          time_sec  = 9 + time_step / 1000;
>          time_usec = 3 * time_step;
>  +
>  +       if (tst_is_virt(VIRT_ANY)) {
>  +               tst_res(TINFO, "Running in a VM, multiply the time_sec by 10.");
>  +               time_sec *= 10;
>  +       }
>   }
>
>   
>  -- 
>  Regards,
>  Li Wang


-- 
Thank you,
Richard.


More information about the ltp mailing list