From: Peter Hilber <peter.hilber@opensynergy.com>
To: Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org
Cc: 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 19:30:16 +0200 [thread overview]
Message-ID: <36b2f11b-9dfd-b721-c97e-478eabceb4cf@opensynergy.com> (raw)
In-Reply-To: <87a5tn1kp6.ffs@tglx>
On 15.09.23 18:10, Thomas Gleixner wrote:
> 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?
I tried like this in v1 (having 'end' inclusive as well), but didn't like
the effect at the second usage site.
>
> That's actually correct for both usage sites because for interpolation
> the logic is the same. history_begin->cycles is a valid timestamp, no?
AFAIU, with the timestamp_in_interval() change, history_begin->cycles would
become a valid timestamp. To me it looks like
adjust_historical_crosststamp() should then work unmodified for now. But
one would have to be careful with the additional corner case in the future.
So, document the current one-line change, or switch to
timestamp_in_interval()?
Thanks for the review!
Peter
next prev parent reply other threads:[~2023-09-15 17:33 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
2023-09-15 17:30 ` Peter Hilber [this message]
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=36b2f11b-9dfd-b721-c97e-478eabceb4cf@opensynergy.com \
--to=peter.hilber@opensynergy.com \
--cc=christopher.s.hall@intel.com \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sboyd@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 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.