[lkml]   [2019]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] FS: timerfd: Fix unexpected return value of timerfd_read function.

On Thu, 5 Sep 2019, Arul Jeniston wrote:
> When we adjust the date setting using date command we observed
> 'timerfd_read()' on CLOCK_REALTIME (TFD_TIMER_ABSTIME flag is set)
> returns 0.
> we don't see any hardware influence here and we are able to recreate
> it consistently. Is it expected? if yes, isn't it something to be
> documented in timerfd read() man page?

It's expected, yes. Simply because it hits the following condition:


settime(T1 + X) --> causes timer to fire

wakeup reader

read number of intervals: 0

i.e. timer did not expire

Changing the return value to 1 would be just a cosmetic workaround. We
could also jump back and wait again. But that's all not consistent because


settime(T1 + X) --> causes timer to fire

wakeup reader

read number of intervals: 1

user space reads time and figures that
the returned tick is bogus.

So I rather change the documentation (this applies only to CLOCK_REALTIME
and CLOCK_REALTIME_ALARM) and explain the rationale.

For applications which care about notifications when the time was set,
timerfd_settime() provides TFD_TIMER_CANCEL_ON_SET which causes the timer
to be canceled when time is set and returns -ECANCELED from the
read. That's unambiguous.



 \ /
  Last update: 2019-09-05 17:35    [W:0.100 / U:5.724 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site