[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACAVd4hS1i--fxWaarXP2psagW-JmBoLAJRrfu9gkRc49Ja4pg@mail.gmail.com>
Date: Fri, 6 Sep 2019 22:06:39 +0530
From: Arul Jeniston <arul.jeniston@...il.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: viro@...iv.linux.org.uk, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, arul_mc@...l.com
Subject: Re: [PATCH] FS: timerfd: Fix unexpected return value of timerfd_read function.
Hi tglx,
>Changing the return value to 1 would be just a cosmetic workaround.
Agreed. Returning 1 is incorrect as It causes the next read() to
return before the interval time passed.
>So I rather change the documentation (this applies only to CLOCK_REALTIME
>and CLOCK_REALTIME_ALARM) and explain the rationale.
When timerfd_read() returns 0, hrtimer_forward() doesn't change expiry
time, So, instead of modifying the man page, can we call
timerfd_read() functionality once again from kernel.
For example:-
timerfd_read_wrapper()
{
do {
ret = timerfd_read(...);
} while (ret == 0);
}
Let us know whether you see any problem in handling this race in kernel.
Regards,
Arul
On Thu, Sep 5, 2019 at 9:04 PM Thomas Gleixner <tglx@...utronix.de> wrote:
>
> Arul,
>
> 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:
>
> armtimer(T1)
>
> settime(T1 + X) --> causes timer to fire
>
> wakeup reader
> settime(T0)
>
> 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
>
> armtimer(T1)
>
> settime(T1 + X) --> causes timer to fire
>
> wakeup reader
>
> read number of intervals: 1
> settime(T0)
>
> 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.
>
> Thanks,
>
> tglx
Powered by blists - more mailing lists