linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org
Subject: Missing CLOCK_BOOTTIME_RAW?
Date: Fri, 8 May 2020 22:18:59 +0200	[thread overview]
Message-ID: <20200508201859.vlffp4fomw2fr4qc@pali> (raw)

Hello Thomas!

I'm looking at clocks which are provided by kernel for userspace
applications via clock_gettime() syscall and I think that there is
missing clock variant CLOCK_BOOTTIME_RAW.

If userspace application wants to measure time difference between two
events then I think all of available clocks CLOCK_REALTIME,
CLOCK_MONOTONIC, CLOCK_MONOTONIC_RAW and CLOCK_BOOTTIME have some issues
for such task.

CLOCK_REALTIME may be changed but userspace and therefore time
difference between two events may be also negative.

CLOCK_MONOTONIC does not have to precise as there may be incremental
jumps caused by NTP or measured time difference may be smaller as
elapsed when system is suspended. During system suspend is clock
CLOCK_MONOTONIC stopped.

CLOCK_MONOTONIC_RAW is not affected by NTP jumps but still is not
suitable for measuring time differences when system is suspended.

CLOCK_BOOTTIME is affected by NTP jumps but provides correct time
difference when system was suspended during measurement.

So for me it looks like that there is missing CLOCK_BOOTTIME_RAW clock
which would not be affected by NTP jumps (like CLOCK_MONOTONIC_RAW) and
also would not be affected by system suspend (like CLOCK_BOOTTIME).

Please correct me if I'm wrong in some of my above assumptions. It is
how I understood documentation for clock_gettime() function from Linux
manpage.

Is there any reason why kernel does not provide such CLOCK_BOOTTIME_RAW
clock for userspace applications which would be interested in measuring
time difference which occurred between two events?

             reply	other threads:[~2020-05-08 20:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08 20:18 Pali Rohár [this message]
2020-05-08 20:59 ` Missing CLOCK_BOOTTIME_RAW? Thomas Gleixner
2020-05-08 21:31   ` Pali Rohár
2020-05-09  9:49     ` Thomas Gleixner
2020-05-18 11:11       ` Pali Rohár
2020-05-18 11:26         ` Thomas Gleixner
2020-05-18 11:35           ` Pali Rohár
2020-05-18 12:13             ` Thomas Gleixner
2020-05-18 12:49               ` Pali Rohár
2020-05-18 13:01                 ` 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=20200508201859.vlffp4fomw2fr4qc@pali \
    --to=pali@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).