Linux userland API discussions
 help / color / mirror / Atom feed
From: Artem Andreenko <miolini@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, Pavel Begunkov <asml.silence@gmail.com>
Cc: io-uring@vger.kernel.org, Artem Andreenko <miolini@gmail.com>,
	linux-api@vger.kernel.org
Subject: [RFC PATCH 2/2] io_uring: add CLOCK_TAI support for waits and timeouts
Date: Fri, 27 Nov 2026 13:20:04 -0800	[thread overview]
Message-ID: <20261127212001.18516-6-miolini@gmail.com> (raw)
In-Reply-To: <20261127212001.18516-4-miolini@gmail.com>

Time-sensitive workloads such as 5G NR gNodeB DU/CU radio-slot loops,
O-RAN 7.2x fronthaul, and TSN applications schedule periodic activations
and packet launchtimes on PTP-synchronized CLOCK_TAI rather than
CLOCK_MONOTONIC (which drifts relative to GNSS/PTP grandmasters).

Allow CLOCK_TAI in IORING_REGISTER_CLOCK (via ktime_get_clocktai() and
HRTIMER_BASE_TAI) and add IORING_TIMEOUT_TAI (bit 8) to
IORING_TIMEOUT_CLOCK_MASK so IORING_OP_TIMEOUT and
IORING_OP_LINK_TIMEOUT can arm CLOCK_TAI deadlines directly.

Tested on arm64 QEMU with PROVE_LOCKING and DEBUG_ATOMIC_SLEEP after
setting a 37-second ADJ_TAI offset, verifying IORING_REGISTER_CLOCK,
future and already-expired absolute io_uring_enter waits,
IORING_OP_TIMEOUT with IORING_TIMEOUT_TAI, and conflicting clock-flag
rejection.

Signed-off-by: Artem Andreenko <miolini@gmail.com>
---
 include/uapi/linux/io_uring.h | 5 ++++-
 io_uring/io_uring.h           | 2 ++
 io_uring/register.c           | 1 +
 io_uring/timeout.c            | 2 ++
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index cf1afd11b..af86553b3 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -357,7 +357,10 @@ enum io_uring_op {
 #define IORING_TIMEOUT_ETIME_SUCCESS	(1U << 5)
 #define IORING_TIMEOUT_MULTISHOT	(1U << 6)
 #define IORING_TIMEOUT_IMMEDIATE_ARG	(1U << 7)
-#define IORING_TIMEOUT_CLOCK_MASK	(IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME)
+#define IORING_TIMEOUT_TAI		(1U << 8)
+#define IORING_TIMEOUT_CLOCK_MASK	(IORING_TIMEOUT_BOOTTIME | \
+					 IORING_TIMEOUT_REALTIME | \
+					 IORING_TIMEOUT_TAI)
 #define IORING_TIMEOUT_UPDATE_MASK	(IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE)
 /*
  * sqe->splice_flags
diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h
index b2808222e..b8c2bee11 100644
--- a/io_uring/io_uring.h
+++ b/io_uring/io_uring.h
@@ -584,6 +584,8 @@ static inline ktime_t io_get_time(clockid_t clockid)
 	switch (clockid) {
 	case CLOCK_BOOTTIME:
 		return ktime_get_boottime();
+	case CLOCK_TAI:
+		return ktime_get_clocktai();
 	default:
 		return ktime_get();
 	}
diff --git a/io_uring/register.c b/io_uring/register.c
index 802cfd6a9..38495369f 100644
--- a/io_uring/register.c
+++ b/io_uring/register.c
@@ -453,6 +453,7 @@ static int io_register_clock(struct io_ring_ctx *ctx,
 	switch (reg.clockid) {
 	case CLOCK_MONOTONIC:
 	case CLOCK_BOOTTIME:
+	case CLOCK_TAI:
 		break;
 	default:
 		return -EINVAL;
diff --git a/io_uring/timeout.c b/io_uring/timeout.c
index db78059cf..43a6afd6d 100644
--- a/io_uring/timeout.c
+++ b/io_uring/timeout.c
@@ -43,6 +43,8 @@ static clockid_t io_flags_to_clock(unsigned flags)
 		return CLOCK_BOOTTIME;
 	case IORING_TIMEOUT_REALTIME:
 		return CLOCK_REALTIME;
+	case IORING_TIMEOUT_TAI:
+		return CLOCK_TAI;
 	default:
 		/* can't happen, vetted at prep time */
 		WARN_ON_ONCE(1);
-- 
2.54.0 (Apple Git-157)


      reply	other threads:[~2026-11-27 21:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 21:20 [RFC PATCH 0/2] io_uring: add CLOCK_TAI support for waits and timeouts Artem Andreenko
2026-11-27 21:20 ` Artem Andreenko [this message]

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=20261127212001.18516-6-miolini@gmail.com \
    --to=miolini@gmail.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-api@vger.kernel.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