From: Paolo Bonzini <pbonzini@redhat.com>
To: Jianyong Wu <jianyong.wu@arm.com>,
netdev@vger.kernel.org, yangbo.lu@nxp.com,
john.stultz@linaro.org, tglx@linutronix.de,
sean.j.christopherson@intel.com, maz@kernel.org,
richardcochran@gmail.com, Mark.Rutland@arm.com, will@kernel.org,
suzuki.poulose@arm.com
Cc: justin.he@arm.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, nd@arm.com,
kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v5 3/6] timekeeping: Add clocksource to system_time_snapshot
Date: Tue, 15 Oct 2019 18:37:39 +0200 [thread overview]
Message-ID: <9274d21c-2c43-2e0d-f086-6aaba3863603@redhat.com> (raw)
In-Reply-To: <20191015104822.13890-4-jianyong.wu@arm.com>
On 15/10/19 12:48, Jianyong Wu wrote:
> Sometimes, we need check current clocksource outside of
> timekeeping area. Add clocksource to system_time_snapshot then
> we can get clocksource as well as system time.
>
> Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> include/linux/timekeeping.h | 35 ++++++++++++++++++-----------------
> kernel/time/timekeeping.c | 7 ++++---
> 2 files changed, 22 insertions(+), 20 deletions(-)
>
> diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
> index a8ab0f143ac4..964c14fbbf69 100644
> --- a/include/linux/timekeeping.h
> +++ b/include/linux/timekeeping.h
> @@ -194,23 +194,6 @@ extern bool timekeeping_rtc_skipresume(void);
>
> extern void timekeeping_inject_sleeptime64(const struct timespec64 *delta);
>
> -/*
> - * struct system_time_snapshot - simultaneous raw/real time capture with
> - * counter value
> - * @cycles: Clocksource counter value to produce the system times
> - * @real: Realtime system time
> - * @raw: Monotonic raw system time
> - * @clock_was_set_seq: The sequence number of clock was set events
> - * @cs_was_changed_seq: The sequence number of clocksource change events
> - */
> -struct system_time_snapshot {
> - u64 cycles;
> - ktime_t real;
> - ktime_t raw;
> - unsigned int clock_was_set_seq;
> - u8 cs_was_changed_seq;
> -};
> -
> /*
> * struct system_device_crosststamp - system/device cross-timestamp
> * (syncronized capture)
> @@ -236,6 +219,24 @@ struct system_counterval_t {
> struct clocksource *cs;
> };
>
> +/*
> + * struct system_time_snapshot - simultaneous raw/real time capture with
> + * counter value
> + * @sc: Contains clocksource and clocksource counter value to produce
> + * the system times
> + * @real: Realtime system time
> + * @raw: Monotonic raw system time
> + * @clock_was_set_seq: The sequence number of clock was set events
> + * @cs_was_changed_seq: The sequence number of clocksource change events
> + */
> +struct system_time_snapshot {
> + struct system_counterval_t sc;
> + ktime_t real;
> + ktime_t raw;
> + unsigned int clock_was_set_seq;
> + u8 cs_was_changed_seq;
> +};
> +
> /*
> * Get cross timestamp between system clock and device clock
> */
> diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
> index 44b726bab4bd..66ff089605b3 100644
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -983,7 +983,8 @@ void ktime_get_snapshot(struct system_time_snapshot *systime_snapshot)
> nsec_raw = timekeeping_cycles_to_ns(&tk->tkr_raw, now);
> } while (read_seqcount_retry(&tk_core.seq, seq));
>
> - systime_snapshot->cycles = now;
> + systime_snapshot->sc.cycles = now;
> + systime_snapshot->sc.cs = tk->tkr_mono.clock;
> systime_snapshot->real = ktime_add_ns(base_real, nsec_real);
> systime_snapshot->raw = ktime_add_ns(base_raw, nsec_raw);
> }
> @@ -1189,12 +1190,12 @@ int get_device_system_crosststamp(int (*get_time_fn)
> * clocksource change
> */
> if (!history_begin ||
> - !cycle_between(history_begin->cycles,
> + !cycle_between(history_begin->sc.cycles,
> system_counterval.cycles, cycles) ||
> history_begin->cs_was_changed_seq != cs_was_changed_seq)
> return -EINVAL;
> partial_history_cycles = cycles - system_counterval.cycles;
> - total_history_cycles = cycles - history_begin->cycles;
> + total_history_cycles = cycles - history_begin->sc.cycles;
> discontinuity =
> history_begin->clock_was_set_seq != clock_was_set_seq;
>
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
next prev parent reply other threads:[~2019-10-15 16:37 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-15 10:48 [RFC PATCH v5 0/6] Enable ptp_kvm for arm64 Jianyong Wu
2019-10-15 10:48 ` [PATCH v5 1/6] psci: Export psci_ops.conduit symbol as modules will use it Jianyong Wu
2019-10-15 17:24 ` Mark Rutland
2019-10-16 3:54 ` Jianyong Wu (Arm Technology China)
2019-10-15 10:48 ` [PATCH v5 2/6] ptp: Reorganize ptp_kvm modules to make it arch-independent Jianyong Wu
2019-10-16 7:10 ` Paolo Bonzini
2019-10-16 10:04 ` Jianyong Wu (Arm Technology China)
2019-10-15 10:48 ` [PATCH v5 3/6] timekeeping: Add clocksource to system_time_snapshot Jianyong Wu
2019-10-15 16:37 ` Paolo Bonzini [this message]
2019-10-15 20:13 ` Thomas Gleixner
2019-10-15 22:36 ` Paolo Bonzini
2019-10-16 7:28 ` Thomas Gleixner
2019-10-16 9:48 ` Jianyong Wu (Arm Technology China)
2019-10-16 10:23 ` Thomas Gleixner
2019-10-15 20:12 ` Thomas Gleixner
2019-10-15 22:35 ` Paolo Bonzini
2019-10-16 10:01 ` Jianyong Wu (Arm Technology China)
2019-10-16 10:26 ` Thomas Gleixner
2019-10-15 10:48 ` [PATCH v5 4/6] psci: Add hvc call service for ptp_kvm Jianyong Wu
2019-10-16 7:24 ` Paolo Bonzini
2019-10-16 7:31 ` Thomas Gleixner
2019-10-16 7:42 ` Paolo Bonzini
2019-10-16 10:20 ` Jianyong Wu (Arm Technology China)
2019-10-15 10:48 ` [PATCH v5 5/6] ptp: arm64: Enable ptp_kvm for arm64 Jianyong Wu
2019-10-15 16:39 ` Paolo Bonzini
2019-10-16 3:52 ` Jianyong Wu (Arm Technology China)
2019-10-16 7:10 ` Paolo Bonzini
2019-10-16 7:13 ` Paolo Bonzini
2019-10-16 10:11 ` Jianyong Wu (Arm Technology China)
2019-10-15 10:48 ` [PATCH v5 6/6] kvm: arm64: Add capability check extension for ptp_kvm Jianyong Wu
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=9274d21c-2c43-2e0d-f086-6aaba3863603@redhat.com \
--to=pbonzini@redhat.com \
--cc=Mark.Rutland@arm.com \
--cc=jianyong.wu@arm.com \
--cc=john.stultz@linaro.org \
--cc=justin.he@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=nd@arm.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=sean.j.christopherson@intel.com \
--cc=suzuki.poulose@arm.com \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
--cc=yangbo.lu@nxp.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;
as well as URLs for NNTP newsgroup(s).