linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: mtk.manpages@gmail.com, linux-man <linux-man@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	arul.jeniston@gmail.com, "devi R.K" <devi.feb27@gmail.com>,
	Marc Lehmann <debian-reportbug@plan9.de>,
	John Stultz <john.stultz@linaro.org>,
	Andrei Vagin <avagin@gmail.com>,
	Cyrill Gorcunov <gorcunov@gmail.com>
Subject: Re: timer_settime() and ECANCELED
Date: Thu, 2 Apr 2020 07:34:32 +0200	[thread overview]
Message-ID: <4c557b44-4e4e-a689-a17b-f95e6c5ee4b0@gmail.com> (raw)
In-Reply-To: <87pncrf6gd.fsf@nanos.tec.linutronix.de>

Hi Thomas,

On 4/1/20 7:42 PM, Thomas Gleixner wrote:
> Michael,
> 
> "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> writes:
>> Following on from our discussion of read() on a timerfd [1], I
>> happened to remember a Debian bug report [2] that points out that
>> timer_settime() can fail with the error ECANCELED, which is both
>> surprising and odd (because despite the error, the timer does get
>> updated).
> ...
>> (1) If the wall-clock is changed before the first timerfd_settime()
>> call, the call succeeds. This is of course expected.
>> (2) If the wall-clock is changed after a timerfd_settime() call, then
>> the next timerfd_settime() call fails with ECANCELED.
>> (3) Even if the timerfd_settime() call fails, the timer is still updated(!).
>>
>> Some questions:
>> (a) What is the rationale for timerfd_settime() failing with ECANCELED
>> in this case? (Currently, the manual page says nothing about this.)
>> (b) It seems at the least surprising, but more likely a bug, that
>> timerfd_settime() fails with ECANCELED while at the same time
>> successfully updating the timer value.
> 
> Really good question and TBH I can't remember why this is implemented in
> the way it is, but I have a faint memory that at least (a) is
> intentional.
> 
> After staring at the code for a while I came up with the following
> answers:
> 
> (a): If the clock was set event ("date -s ...") which triggered the
>      cancel was not yet consumed by user space via read(), then that
>      information would get lost because arming the timer to the new
>      value has to reset the state.
> 
> (b): Arming the timer in that case is indeed very questionable, but it
>      could be argued that because the clock was set event happened with
>      the old expiry value that the new expiry value is not affected.
>      
>      I'd be happy to change that and not arm the timer in the case of a
>      pending cancel, but I fear that some user space already depends on
>      that behaviour.

Yes, that's the risk, of course. So, shall we just document all 
this in the manual page?

Thanks,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

  reply	other threads:[~2020-04-02  5:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-01  9:01 timer_settime() and ECANCELED Michael Kerrisk (man-pages)
2020-04-01 11:16 ` Cyrill Gorcunov
2020-04-01 17:42 ` Thomas Gleixner
2020-04-02  5:34   ` Michael Kerrisk (man-pages) [this message]
2020-04-02  8:49     ` Thomas Gleixner
2020-04-02 13:16       ` Michael Kerrisk (man-pages)
2020-04-02 13:35         ` Thomas Gleixner
2020-04-02 19:48           ` Michael Kerrisk (man-pages)
2020-04-02 20:12             ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4c557b44-4e4e-a689-a17b-f95e6c5ee4b0@gmail.com \
    --to=mtk.manpages@gmail.com \
    --cc=arul.jeniston@gmail.com \
    --cc=avagin@gmail.com \
    --cc=debian-reportbug@plan9.de \
    --cc=devi.feb27@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).