All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH] nanosleep: Use CLOCK_MONOTONIC for elapsed time measurement
Date: Tue, 31 Mar 2026 14:14:25 +0200	[thread overview]
Message-ID: <acu6odZhugXeNM_C@yuki.lan> (raw)
In-Reply-To: <20260331-nanosleep_posix_fix-v1-1-7a707f871582@suse.com>

Hi!
> All nanosleep POSIX conformance tests used CLOCK_REALTIME to measure
> elapsed sleep duration. CLOCK_REALTIME can jump due to NTP corrections,
> VM time sync, or other wall-clock adjustments, causing sporadic test
> failures where measured time far exceeds expected sleep duration.
> 
> Switch to CLOCK_MONOTONIC which is immune to wall-clock changes and is
> the correct clock for measuring elapsed durations.

Unfortunately CLOCK_MONOTONIC is optional in POSIX so we have to check
if it's present at least at compile time with something as:

#if _POSIX_MONOTONIC_CLOCK
# define TEST_CLOCK CLOCK_MONOTONIC
#else
# define TEST_CLOCK CLOCK_REALTIME
#endif

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-03-31 12:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 11:48 [LTP] [PATCH] nanosleep: Use CLOCK_MONOTONIC for elapsed time measurement Andrea Cervesato
2026-03-31 12:14 ` Cyril Hrubis [this message]
2026-03-31 12:20   ` Andrea Cervesato via ltp
2026-03-31 12:23     ` Cyril Hrubis
2026-03-31 12:28       ` Andrea Cervesato via ltp

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=acu6odZhugXeNM_C@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=andrea.cervesato@suse.de \
    --cc=ltp@lists.linux.it \
    /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.