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: Re: [PATCH] timerfd: Support CLOCK_TAI
Date: Thu, 19 Mar 2026 17:05:52 +0800 [thread overview]
Message-ID: <abu8cG7g11DP9nkn@chrisdown.name> (raw)
In-Reply-To: <abuTTv9FC__H_8RC@chrisdown.name>
To proactively reply to what Sashiko said in
https://sashiko.dev/#/patchset/abuTTv9FC__H_8RC%40chrisdown.name:
> If a user creates a CLOCK_TAI timer and later calls timerfd_settime with
> the TFD_TIMER_CANCEL_ON_SET flag, does the kernel silently ignore the flag?
>
> Looking at timerfd_setup_cancel in fs/timerfd.c, the cancellation logic
> appears to be explicitly restricted to CLOCK_REALTIME and
> CLOCK_REALTIME_ALARM:
>
> static void timerfd_setup_cancel(struct timerfd_ctx *ctx, int flags)
> {
> ...
> if ((ctx->clockid == CLOCK_REALTIME ||
> ctx->clockid == CLOCK_REALTIME_ALARM) &&
> (flags & TFD_TIMER_ABSTIME) && (flags & TFD_TIMER_CANCEL_ON_SET)) {
> ...
> } else {
> __timerfd_remove_cancel(ctx);
> }
> }
>
> Will this cause a silent API failure where the timer is never added to the
> cancel list for CLOCK_TAI, meaning the timer won't be canceled during
> administrative clock jumps?
>
> Additionally, if it were added, timerfd_clock_was_set and timerfd_canceled
> hardcode the jump-detection check to ktime_mono_to_real(0). Does this miss
> independent jumps in CLOCK_TAI caused by adjtimex(ADJ_TAI)?
So, timerfd_setup_cancel() is currently restricted to CLOCK_REALTIME and
CLOCK_REALTIME_ALARM, so a CLOCK_TAI timerfd created by this patch will behave
like the other non-REALTIME timerfds here. The behaviour is that the flag is
accepted by timerfd_settime(), but no cancel on set tracking is armed and the
timer will not report ECANCELED on clock changes.
So what Sashiko says does not block this patch, because the patch is only
lifting the timerfd_create() allowlist restriction. The underlying
hrtimer/k_clock paths already support basic CLOCK_TAI timerfds, which is what
this patch is enabling.
If we wanted TFD_TIMER_CANCEL_ON_SET support for CLOCK_TAI, that would need
separate work. As Sashiko also said, the current cancel detection is based on
ktime_mono_to_real(0) (that is, REALTIME movement) and would not be sufficient
for standalone TAI offset changes such as adjtimex(ADJ_TAI). So supporting
cancel on set for CLOCK_TAI is not just a matter of adding CLOCK_TAI to
timerfd_setup_cancel() and would require defining the desired semantics and
adding distinct change detection for TAI. That's a much bigger change and
discussion.
So let's leave this patch as is for now.
next prev parent reply other threads:[~2026-03-19 9:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 6:10 [PATCH] timerfd: Support CLOCK_TAI Chris Down
2026-03-19 9:05 ` Chris Down [this message]
2026-03-20 17:36 ` 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=abu8cG7g11DP9nkn@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