Linux Test Project
 help / color / mirror / Atom feed
From: Wake Liu via ltp <ltp@lists.linux.it>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: Wake Liu <wakel@google.com>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] sys_rtc01: Rewrite the RTC check
Date: Thu, 19 Nov 2026 15:06:19 +0000	[thread overview]
Message-ID: <20261119150619.449861-1-wakel@google.com> (raw)
In-Reply-To: <20261119103711.3002153-1-chrubis@suse.cz>

Hi Cyril,

On Thu, Nov 19, 2026 at 11:37:11AM +0100, Cyril Hrubis wrote:
> Instead of comparing system time against RTC, which proved to be
> unreliable we now sample the RTC since_epoch and compare it with
> CLOCK_MONOTONIC_RAW timer.

Thanks for reworking this! Dropping the system time comparison and timing
since_epoch transitions against CLOCK_MONOTONIC_RAW is much cleaner and
avoids all the STA_UNSYNC / CONFIG_RTC_SYSTOHC corner cases on our
systems.

Two small things I noticed while reviewing and testing the patch:

> +static void poll_rtc(struct rtc_dev *rtc)
> +{
> +	struct timespec start, end;
> +	struct rtc_edge edge;
> +	long long val;
> +
> +	SAFE_CLOCK_GETTIME(CLOCK_MONOTONIC_RAW, &start);
> +	val = TST_SYSFS_READ_LI(PATH_CLASS_RTC "/%s/since_epoch", rtc->name);
> +	SAFE_CLOCK_GETTIME(CLOCK_MONOTONIC_RAW, &end);

The kernel exports since_epoch as time64_t ("%lld") and val is already
long long, so this should use TST_SYSFS_READ_LLI() (and likewise in
read_rtc_snapshot() with a long long since_epoch). Otherwise on 32-bit
userspace an uninitialized or secondary RTC set past 2038 clamps "%ld"
to LONG_MAX on every read, making poll_rtc() see 0 transitions (and
mismatching 64-bit timegm() when _TIME_BITS=64).

>  static struct tst_test test = {
> +	.setup = setup,
>  	.test_all = do_test,
> +	.runtime = 5,
>  };

Since the test requires at least 2 transitions, could we also set
.min_runtime = 3 (or 4)? Without it, running with e.g.
LTP_RUNTIME_MUL=0.2 clamps runtime to 1s and fails with:

  sys_rtc01.c:261: TFAIL: rtc0: since_epoch did not advance (1 transitions seen)

With those two fixed, feel free to add:
Reviewed-by: Wake Liu <wakel@google.com>

Best regards,
Wake

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

  parent reply	other threads:[~2026-11-19 15:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 10:37 [LTP] [PATCH] sys_rtc01: Rewrite the RTC check Cyril Hrubis
2026-11-19 12:13 ` [LTP] " linuxtestproject.agent
2026-11-19 15:06 ` Wake Liu via ltp [this message]
2026-11-20  9:39   ` [LTP] [PATCH] " Cyril Hrubis

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=20261119150619.449861-1-wakel@google.com \
    --to=ltp@lists.linux.it \
    --cc=chrubis@suse.cz \
    --cc=wakel@google.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