[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACAVd4grhGVVSYpwjof5YiS1duZ2_SFjvXtctP+cmR5Actkjyg@mail.gmail.com>
Date: Tue, 5 Nov 2019 10:31:03 +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,
> So I'm going to send a patch to document that in the manpage.
Did you get a chance to make the manpage patch? if yes, please help us
by sharing the link where we can find the patch.
Regards,
Arul
On Sat, Sep 7, 2019 at 8:08 PM Thomas Gleixner <tglx@...utronix.de> wrote:
>
> Arul,
>
> On Fri, 6 Sep 2019, Arul Jeniston wrote:
> > >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.
>
> There is no race. It's defined behaviour and I explained it to you in great
> length why it is correct to return 0 and document that in the man page.
>
> Any CLOCK_REALTIME ABSTIME based interface of the kernel is affected by
> this and no, we are not papering over it in one particular place just
> because.
>
> If clock REALTIME gets set then all bets are off. The syscalls can return
> either early or userspace cam observe that the return value is bogus when
> it actually reads the time. You cannot handle this by any means.
>
> The only way to handle this gracefully is by using the
> TFD_TIMER_CANCEL_ON_SET flag and reevaluate the situation in user space.
>
> So I'm going to send a patch to document that in the manpage.
>
> Thanks,
>
> tglx
>
>
>
>
Powered by blists - more mailing lists