All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: "François Legal" <devel@thom.fr.eu.org>,
	xenomai <xenomai@lists.linux.dev>
Subject: Re: Getting time in realtime kernel driver
Date: Wed, 13 May 2026 09:19:04 +0200	[thread overview]
Message-ID: <875x4rixp3.fsf@xenomai.org> (raw)
In-Reply-To: <e7e975fa-9879-43d1-9f28-60507e1563be@siemens.com> (Jan Kiszka's message of "Wed, 13 May 2026 07:36:01 +0200")

Jan Kiszka <jan.kiszka@siemens.com> writes:

> On 12.05.26 18:20, François Legal wrote:
>> Hello,
>> 
>> I think I already asked about the same question some time ago, but I think I did not get a working answer, so here I am again.
>> 
>> On xenomai 3.2 + Ipipe (linux 5.4), I need to be able to get in a RT driver the current linux wall clock (impacted from NTP or PTP).
>> I found out I get the correct value with ktime_get_real_ts64. Was willing to use __ktime_get_real_seconds but this one is not precise enought for my application.
>> 
>> So my question is : is it safe to use ktime_get_real_ts64 from within an RT driver ioctl function, and if not, which API in xenomai gives the exact same time as this one ?
>> 
>
> Nope, it's not safe, neither under legacy I-pipe (your kernel is dead
> BTW) nor latest dovetail. Userspace access to the wallclock was hardened
> for out-of-band accesses, but in-kernel had no use case, thus was never
> considered.
>
> For userland, the easiest answer is moving to a dovetail kernel and then
> using CLOCK_REALTIME. Over I-pipe, we had to model this via a separate
> clock named CLOCK_HOST_REALTIME.
>
> Jan

This may help:

"ktime_get_real_fast_ns: - NMI safe and fast access to clock realtime."

Caveat: with this variant, timestamp is not guaranteed to be monotonic
across an update.

-- 
Philippe.

  reply	other threads:[~2026-05-13  7:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 16:20 Getting time in realtime kernel driver François Legal
2026-05-13  5:36 ` Jan Kiszka
2026-05-13  7:19   ` Philippe Gerum [this message]
     [not found] <131e-6a043e00-27-5cd69880@210449648>
2026-05-13  9:23 ` Philippe Gerum

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=875x4rixp3.fsf@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=devel@thom.fr.eu.org \
    --cc=jan.kiszka@siemens.com \
    --cc=xenomai@lists.linux.dev \
    /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 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.