All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Peter Hilber <peter.hilber@opensynergy.com>,
	linux-kernel@vger.kernel.org
Cc: Peter Hilber <peter.hilber@opensynergy.com>,
	John Stultz <jstultz@google.com>, Stephen Boyd <sboyd@kernel.org>,
	"Christopher S. Hall" <christopher.s.hall@intel.com>
Subject: Re: [RFC PATCH v2 2/6] timekeeping: Fix cross-timestamp interpolation corner case decision
Date: Fri, 15 Sep 2023 18:10:29 +0200	[thread overview]
Message-ID: <87a5tn1kp6.ffs@tglx> (raw)
In-Reply-To: <20230818012014.212155-3-peter.hilber@opensynergy.com>

On Fri, Aug 18 2023 at 03:20, Peter Hilber wrote:
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -1247,7 +1247,8 @@ int get_device_system_crosststamp(int (*get_time_fn)
>  		 */
>  		now = tk_clock_read(&tk->tkr_mono);
>  		interval_start = tk->tkr_mono.cycle_last;
> -		if (!cycle_between(interval_start, cycles, now)) {
> +		if (!cycle_between(interval_start, cycles, now) &&
> +		    cycles != interval_start) {
>  			clock_was_set_seq = tk->clock_was_set_seq;
>  			cs_was_changed_seq = tk->cs_was_changed_seq;
>  			cycles = interval_start;

So the explanation in the changelog makes some sense, but this code
without any further explanation just makes my brain explode.

This whole thing screams for a change to cycle_between() so it becomes:

     timestamp_in_interval(start, end, ts)

and make start inclusive and not exclusive, no?

That's actually correct for both usage sites because for interpolation
the logic is the same. history_begin->cycles is a valid timestamp, no?

Thanks,

        tglx



  parent reply	other threads:[~2023-09-15 16:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18  1:20 [virtio-dev] [RFC PATCH v2 0/6] Add virtio_rtc module and related changes Peter Hilber
2023-08-18  1:20 ` Peter Hilber
2023-08-18  1:20 ` Peter Hilber
2023-08-18  1:20 ` [RFC PATCH v2 1/6] timekeeping: Fix cross-timestamp interpolation on counter wrap Peter Hilber
2023-08-18  1:20 ` [RFC PATCH v2 2/6] timekeeping: Fix cross-timestamp interpolation corner case decision Peter Hilber
2023-08-25  4:02   ` John Stultz
2023-09-15 16:10   ` Thomas Gleixner [this message]
2023-09-15 17:30     ` Peter Hilber
2023-09-15 19:02       ` Thomas Gleixner
2023-08-18  1:20 ` [RFC PATCH v2 3/6] timekeeping: Fix cross-timestamp interpolation for non-x86 Peter Hilber
2023-08-25  4:04   ` John Stultz
2023-09-13  9:11     ` Peter Hilber
2023-08-18  1:20 ` [virtio-dev] [RFC PATCH v2 4/6] virtio_rtc: Add module and driver core Peter Hilber
2023-08-18  1:20   ` Peter Hilber
2023-08-18  1:20   ` Peter Hilber
2023-08-18  1:20 ` [virtio-dev] [RFC PATCH v2 5/6] virtio_rtc: Add PTP clocks Peter Hilber
2023-08-18  1:20   ` Peter Hilber
2023-08-18  1:20   ` Peter Hilber
2023-08-18  1:20 ` [virtio-dev] [RFC PATCH v2 6/6] virtio_rtc: Add Arm Generic Timer cross-timestamping Peter Hilber
2023-08-18  1:20   ` Peter Hilber
2023-08-18  1:20   ` Peter Hilber

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=87a5tn1kp6.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=christopher.s.hall@intel.com \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.hilber@opensynergy.com \
    --cc=sboyd@kernel.org \
    /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.