From: Cyrill Gorcunov <gorcunov@gmail.com>
To: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
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>
Subject: Re: timer_settime() and ECANCELED
Date: Wed, 1 Apr 2020 14:16:22 +0300 [thread overview]
Message-ID: <20200401111622.GQ3197@uranus> (raw)
In-Reply-To: <CAKgNAkgiZna0yQzkdZQ92CJzjBcxX6eEu1cg24Oeu2pXRcSv8A@mail.gmail.com>
On Wed, Apr 01, 2020 at 11:01:18AM +0200, Michael Kerrisk (man-pages) wrote:
> Hello Thomas, et al,
>
> 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).
>
> The relevant kernel code (I think, from your commit [3]) seems to be
> the following in timerfd_setup():
>
> if (texp != 0) {
> if (flags & TFD_TIMER_ABSTIME)
> texp = timens_ktime_to_host(clockid, texp);
> if (isalarm(ctx)) {
> if (flags & TFD_TIMER_ABSTIME)
> alarm_start(&ctx->t.alarm, texp);
> else
> alarm_start_relative(&ctx->t.alarm, texp);
> } else {
> hrtimer_start(&ctx->t.tmr, texp, htmode);
> }
>
> if (timerfd_canceled(ctx))
> return -ECANCELED;
> }
>
> Using a small test program [4] shows the behavior. The program loops,
> repeatedly calling timerfd_settime() (with a delay of a few seconds
> before each call). In another terminal window, enter the following
> command a few times:
>
> $ sudo date -s "5 seconds" # Add 5 secs to wall-clock time
>
> I see behavior as follows (the /sudo date -s "5 seconds"/ command was
> executed before loop iterations 0, 2, and 4):
Hi Michael, I can be wrong (since I didn't look into timerfd code
for long time) but I guess if we wanna preserve the timer value
we will have to lock timekeeper which is inacceptable. Thus looks
like this is a tradeoff in a sake of speed (not sure though, better
wait for Thomas reply)
next prev parent reply other threads:[~2020-04-01 11:16 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 [this message]
2020-04-01 17:42 ` Thomas Gleixner
2020-04-02 5:34 ` Michael Kerrisk (man-pages)
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=20200401111622.GQ3197@uranus \
--to=gorcunov@gmail.com \
--cc=arul.jeniston@gmail.com \
--cc=avagin@gmail.com \
--cc=debian-reportbug@plan9.de \
--cc=devi.feb27@gmail.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
--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