All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] timerfd: Support CLOCK_TAI
@ 2026-11-28  9:36 Chris Down
  2026-11-28  9:36 ` [PATCH v2 1/2] " Chris Down
  2026-11-28  9:37 ` [PATCH v2 2/2] selftests: timers: Add a test for CLOCK_TAI timerfds Chris Down
  0 siblings, 2 replies; 3+ messages in thread
From: Chris Down @ 2026-11-28  9:36 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: linux-kernel, Alexander Viro, Christian Brauner, Jan Kara,
	Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	kernel-team

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-28  9:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28  9:36 [PATCH v2 0/2] timerfd: Support CLOCK_TAI Chris Down
2026-11-28  9:36 ` [PATCH v2 1/2] " Chris Down
2026-11-28  9:37 ` [PATCH v2 2/2] selftests: timers: Add a test for CLOCK_TAI timerfds Chris Down

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.