From: John Ogness <john.ogness@linutronix.de>
To: Marc Gonzalez <marc.w.gonzalez@free.fr>, Daniel Wagner <dwagner@suse.de>
Cc: linux-rt-users@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Daniel Wagner <daniel.wagner@suse.com>,
Clark Williams <williams@redhat.com>,
Pavel Machek <pavel@denx.de>,
Luis Goncalves <lgoncalv@redhat.com>,
John McCalpin <mccalpin@tacc.utexas.edu>
Subject: Re: Large(ish) variance induced by SCHED_FIFO
Date: Mon, 08 Sep 2025 11:42:00 +0206 [thread overview]
Message-ID: <84ldmp8ewv.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <3f1d4229-a95c-4d99-a98f-249d9e488b32@free.fr>
On 2025-09-05, Marc Gonzalez <marc.w.gonzalez@free.fr> wrote:
>>> Could you provide some insight as to why CLOCK_MONOTONIC is preferable?
>>
>> CLOCK_MONOTONIC is tracking in time units as defined by humans.
>> CLOCK_MONOTONIC_RAW is tracking in time units defined by some hardware.
>
> I'm not sure I understand what that implies.
>
> Eventually, clock_gettime stores whatever it measured in struct timespec,
> with tv_sec & tv_nsec, right?
I would phrase it differently, but generally speaking, correct.
> Are you saying that if I have 2 identical timespecs,
> one from CLOCK_MONOTONIC, one from CLOCK_MONOTONIC_RAW,
> they might not measure the same time interval?
I assume you mean 2 _sets_ of timespecs (so that you have 2 intervals to
compare). Correct.
> Are you perhaps saying that NTP can (ever so slightly) tweak
> a clock to bring its frequency closer to "reality", but if
> CLOCK_MONOTONIC_RAW ignores such tweaks, it might count time
> slightly too fast or too slow?
Correct.
This is also valid for other clocks. For example, the kernel logs
(printk) and ftrace default to the CPU local clock. These timestamps
cannot be compared to CLOCK_MONOTONIC timestamps... just as
CLOCK_MONOTONIC_RAW timestamps cannot be compared to CLOCK_MONOTONIC
timestamps.
There are still reasons why CLOCK_MONOTONIC_RAW might be
interesting. For example, if you want a very stable timesource to
compare intervals, but do not care so much about the real world time
lengths of those intervals (i.e. where is the greatest latency vs. what
is the value of the greatest latency). Although even here, I doubt
CLOCK_MONOTONIC_RAW has a practical advantage over CLOCK_MONOTONIC.
John
next prev parent reply other threads:[~2025-09-08 9:36 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 23:45 Large(ish) variance induced by SCHED_FIFO Marc Gonzalez
2025-09-05 8:25 ` Daniel Wagner
2025-09-05 13:23 ` Marc Gonzalez
2025-09-05 14:03 ` John Ogness
2025-09-05 15:34 ` Marc Gonzalez
2025-09-05 16:07 ` John Ogness
2025-09-05 17:40 ` Marc Gonzalez
2025-09-08 9:36 ` John Ogness [this message]
2025-09-08 15:42 ` Marc Gonzalez
2025-09-08 16:02 ` Daniel Wagner
2025-09-08 18:40 ` Marc Gonzalez
2025-09-09 11:08 ` Unexplained variance in run-time of trivial program Marc Gonzalez
2025-09-09 11:21 ` Daniel Wagner
2025-09-09 12:42 ` Marc Gonzalez
2025-09-09 14:23 ` Steven Rostedt
2025-09-09 12:34 ` John Ogness
2025-09-09 14:08 ` Marc Gonzalez
2025-09-09 18:33 ` Marc Gonzalez
[not found] ` <CAMjhiJjMOQN-nWd+KP4JBBNHf20M+J2fXAuTTvowXctJgvGOcQ@mail.gmail.com>
2025-09-09 20:30 ` Marc Gonzalez
2025-09-10 7:59 ` Daniel Wagner
2025-09-11 21:29 ` Marc Gonzalez
2025-09-11 22:15 ` Marc Gonzalez
2025-09-12 7:44 ` Daniel Wagner
2025-09-13 10:09 ` Marc Gonzalez
2025-09-15 16:30 ` Marc Gonzalez
2025-09-16 7:50 ` Ahmed S. Darwish
2025-09-25 11:38 ` Marc Gonzalez
2025-09-08 16:52 ` [EXT] Re: Large(ish) variance induced by SCHED_FIFO Rui Sousa
2025-09-08 17:03 ` Marc Gonzalez
[not found] ` <CAMjhiJiVDmnx+pgpvtAy=KarHexjsYs+T9tSkpGvppjqFdtmiw@mail.gmail.com>
2025-09-05 21:05 ` Marc Gonzalez
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=84ldmp8ewv.fsf@jogness.linutronix.de \
--to=john.ogness@linutronix.de \
--cc=bigeasy@linutronix.de \
--cc=daniel.wagner@suse.com \
--cc=dwagner@suse.de \
--cc=lgoncalv@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=marc.w.gonzalez@free.fr \
--cc=mccalpin@tacc.utexas.edu \
--cc=pavel@denx.de \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.com \
/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