From: Thomas Gleixner <tglx@linutronix.de>
To: Colin Walters <walters@verbum.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: TFD_CANCEL_ON_SET race when making a wall clock
Date: Fri, 2 Sep 2011 17:00:30 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.02.1109021655140.2723@ionos> (raw)
In-Reply-To: <1314974233.30505.9.camel@lenny>
On Fri, 2 Sep 2011, Colin Walters wrote:
> Hi,
>
> So I was recently making GNOME use the new timerfd TFD_CANCEL_ON_SET so
> we get woken up when the system clock changes. It works generally well,
> except Ryan Lortie pointed out a race condition in my use of
> timerfd_settime() that I think anyone using it to make a wall clock
> display might not realize at first:
>
> https://bugzilla.gnome.org/show_bug.cgi?id=655129#c36
>
> For the link-averse, basically the system clock can move backwards
> between when the process gets the current time, and computes the wakeup
> (typically for the next minute).
>
> I was able to work around it in userspace with this patch:
> http://bugzilla-attachments.gnome.org/attachment.cgi?id=195252
> But it's clearly not what I'd call beautiful.
>
> I don't see a nice way to handle this in the kernel given the current
> API, but maybe someone else does?
>
> TFD_CANCEL_ON_SET isn't documented in man-pages at all right now...maybe
> this is just a useful note for a future patch to
> man-pages/man2/timerfd_create.2.
Well, the kernel can only handle the time was set scenario from the
point when timerfd_create() is called.
There is no way to handle:
clock_gettime(a);
clock_settime();
timerfd_create();
timerfd_settime(a + x);
And there wont be one ever. The guarantee is that _after_
timerfd_create() any modification to CLOCK_REALTIME in either
direction is causing a cancelation of the timer.
Thanks,
tglx
next prev parent reply other threads:[~2011-09-02 15:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-02 14:37 Colin Walters
2011-09-02 15:00 ` Thomas Gleixner [this message]
2011-09-02 15:07 ` Colin Walters
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=alpine.LFD.2.02.1109021655140.2723@ionos \
--to=tglx@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=walters@verbum.org \
/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
all inboxes | Powered by JetHome®