Ah, I see now what is happening. The userspace code is dealing with
microseconds, while the syscalls all deal with nanoseconds.

So, when using absolute time, we read the clock (in nanoseconds), add
that to our microseconds value after converting (that is, rounding the
value), then set the timer, and read it back.

Take this run, for example:
[pid 27982] timer_create(CLOCK_MONOTONIC, NULL, [0]) = 0
[pid 27982] clock_gettime(CLOCK_MONOTONIC, {tv_sec=53718, tv_nsec=537178810}) = 0
[pid 27982] timer_settime(0, TIMER_ABSTIME, {it_interval={tv_sec=0, tv_nsec=0}, 
it_value={tv_sec=53718, tv_nsec=587179000}}, {it_interval={tv_sec=0, 
tv_nsec=0}, it_value={tv_sec=0, tv_nsec=0}}) = 0
[pid 27982] timer_gettime(0, {it_interval={tv_sec=0, tv_nsec=0}, 
it_value={tv_sec=0, tv_nsec=49842203}}) = 0

We read the time and set it 587179000 - 537178810 = 50000190 nanoseconds
in the future, which is more than our 50000 microseconds. No surprise
that, if you are fast enough, you are going to read a larger value back.

Not a kernel bug!
Cascardo.

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux-aws in Ubuntu.
https://bugs.launchpad.net/bugs/1898633

Title:
   timer_settime01 from ubuntu_ltp_syscalls failed on bionic /aws-4.15
  on c5.metal

Status in ubuntu-kernel-tests:
  New
Status in linux-aws package in Ubuntu:
  New
Status in linux-aws source package in Bionic:
  New

Bug description:
  21367.        09/25 08:38:06 DEBUG| utils:0153| [stdout] startup='Fri Sep 25 
08:37:00 2020'
  21368.        09/25 08:38:06 DEBUG| utils:0153| [stdout] tst_test.c:1250: 
TINFO: Timeout per run is 0h 05m 00s
  21369.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:85: TINFO: Testing variant: syscall with old kernel spec
  21370.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:96: TINFO: Testing for general initialization:
  21371.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_REALTIME) passed
  21372.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_MONOTONIC) passed
  21373.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_PROCESS_CPUTIME_ID) passed
  21374.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_THREAD_CPUTIME_ID) passed
  21375.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_BOOTTIME) passed
  21376.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_BOOTTIME_ALARM) passed
  21377.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_REALTIME_ALARM) passed
  21378.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_TAI) passed
  21379.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:96: TINFO: Testing for setting old_value:
  21380.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_REALTIME) passed
  21381.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_MONOTONIC) passed
  21382.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_PROCESS_CPUTIME_ID) passed
  21383.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_THREAD_CPUTIME_ID) passed
  21384.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_BOOTTIME) passed
  21385.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_BOOTTIME_ALARM) passed
  21386.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_REALTIME_ALARM) passed
  21387.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_TAI) passed
  21388.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:96: TINFO: Testing for using periodic timer:
  21389.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_REALTIME) passed
  21390.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_MONOTONIC) passed
  21391.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_PROCESS_CPUTIME_ID) passed
  21392.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_THREAD_CPUTIME_ID) passed
  21393.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_BOOTTIME) passed
  21394.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_BOOTTIME_ALARM) passed
  21395.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_REALTIME_ALARM) passed
  21396.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_TAI) passed
  21397.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:96: TINFO: Testing for using absolute time:
  21398.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_REALTIME) passed
  21399.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:160: TFAIL: timer_gettime(CLOCK_MONOTONIC) reported bad 
values (0: 50000034): SUCCESS (0)
  21400.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_MONOTONIC) passed
  21401.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_PROCESS_CPUTIME_ID) passed
  21402.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_THREAD_CPUTIME_ID) passed
  21403.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_BOOTTIME) passed
  21404.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_BOOTTIME_ALARM) passed
  21405.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_REALTIME_ALARM) passed
  21406.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
timer_settime01.c:170: TPASS: timer_settime(CLOCK_TAI) passed
  21407.        09/25 08:38:06 DEBUG| utils:0153| [stdout]
  21408.        09/25 08:38:06 DEBUG| utils:0153| [stdout] HINT: You _MAY_ be 
missing kernel fixes, see:
  21409.        09/25 08:38:06 DEBUG| utils:0153| [stdout]
  21410.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f18ddc13af98
  21411.        09/25 08:38:06 DEBUG| utils:0153| [stdout] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e86fea764991
  21412.        09/25 08:38:06 DEBUG| utils:0153| [stdout]
  21413.        09/25 08:38:06 DEBUG| utils:0153| [stdout] Summary:
  21414.        09/25 08:38:06 DEBUG| utils:0153| [stdout] passed 32
  21415.        09/25 08:38:06 DEBUG| utils:0153| [stdout] failed 1
  21416.        09/25 08:38:06 DEBUG| utils:0153| [stdout] skipped 0
  21417.        09/25 08:38:06 DEBUG| utils:0153| [stdout] warnings 0
  21418.        09/25 08:38:06 DEBUG| utils:0153| [stdout] tag=timer_settime01 
stime=1601023020 dur=2 exit=exited stat=1 core=no cu=202 cs=0

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu-kernel-tests/+bug/1898633/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to     : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to