The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Chris Down <chris@chrisdown.name>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Frederic Weisbecker <frederic@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>,
	kernel-team@meta.com
Subject: [PATCH v2 0/2] timerfd: Support CLOCK_TAI
Date: Sat, 28 Nov 2026 01:36:56 -0800	[thread overview]
Message-ID: <cover.1795855037.git.chris@chrisdown.name> (raw)

Both hrtimers and POSIX timers accept CLOCK_TAI, but timerfd_create()
rejects it. An application with TAI deadlines and an epoll based event
loop is left with two options. It can convert the deadlines to
CLOCK_REALTIME, which brings back the exposure to wall clock jumps it
was trying to avoid, or it can stop using timerfd.

Patch 1 makes timerfd_create() accept CLOCK_TAI and makes
TFD_TIMER_CANCEL_ON_SET work for it. A CLOCK_TAI timer is cancelled when
CLOCK_REALTIME is set and when adjtimex(ADJ_TAI) changes the TAI offset.
Nothing changes for CLOCK_REALTIME timers.

Patch 2 adds a selftest for this.

There are two existing limitations I noticed which I have not fixed here:

- Relative CLOCK_TAI timers stay on the TAI base, but hrtimer_setup()
  moves relative CLOCK_REALTIME timers to CLOCK_MONOTONIC. That makes a
  relative CLOCK_TAI timerfd expire early if the clock is stepped
  forwards. The same happens with timer_settime() and clock_nanosleep()
  on CLOCK_TAI today. TFD_TIMER_CANCEL_ON_SET does not report it because
  it only applies to absolute timers.
- The offset which cancel on set compares against is first recorded in
  timerfd_create() rather than when the timer is armed. If the clock is
  stepped between the two, the next clock_was_set() cancels the timer
  even if nothing moved, and a later step back by the same amount is not
  reported. This happens with CLOCK_REALTIME timers today.

I can send patches for these separately if you think they are worth
fixing.

v2:

- Make TFD_TIMER_CANCEL_ON_SET work for CLOCK_TAI timers (tglx)
- Add a selftest
- Rebase onto tip timers/core

v1: https://lore.kernel.org/r/abuTTv9FC__H_8RC@chrisdown.name

Chris Down (2):
  timerfd: Support CLOCK_TAI
  selftests: timers: Add a test for CLOCK_TAI timerfds

 fs/timerfd.c                                 |  20 +-
 tools/testing/selftests/timers/.gitignore    |   1 +
 tools/testing/selftests/timers/Makefile      |   2 +-
 tools/testing/selftests/timers/timerfd-tai.c | 183 +++++++++++++++++++
 4 files changed, 201 insertions(+), 5 deletions(-)
 create mode 100644 tools/testing/selftests/timers/timerfd-tai.c


base-commit: 0359ecff58853a491dd0f09792fea8e87235ae06
-- 
2.56.1


             reply	other threads:[~2026-11-28  9:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28  9:36 Chris Down [this message]
2026-11-28  9:36 ` [PATCH v2 1/2] timerfd: Support CLOCK_TAI Chris Down
2026-11-28  9:37 ` [PATCH v2 2/2] selftests: timers: Add a test for CLOCK_TAI timerfds Chris Down

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=cover.1795855037.git.chris@chrisdown.name \
    --to=chris@chrisdown.name \
    --cc=anna-maria@linutronix.de \
    --cc=brauner@kernel.org \
    --cc=frederic@kernel.org \
    --cc=jack@suse.cz \
    --cc=kernel-team@meta.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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