Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Vincent Donnefort <vdonnefort@google.com>
To: rostedt@goodmis.org, mhiramat@kernel.org,
	 linux-trace-kernel@vger.kernel.org, maz@kernel.org,
	oliver.upton@linux.dev
Cc: kvmarm@lists.linux.dev, will@kernel.org, qperret@google.com,
	 kernel-team@android.com, linux-kernel@vger.kernel.org,
	 Vincent Donnefort <vdonnefort@google.com>,
	John Stultz <jstultz@google.com>,
	 Thomas Gleixner <tglx@linutronix.de>,
	Stephen Boyd <sboyd@kernel.org>,
	 "Christopher S. Hall" <christopher.s.hall@intel.com>,
	Richard Cochran <richardcochran@gmail.com>,
	 Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
Subject: [PATCH 04/13] timekeeping: Add the boot clock to system time snapshot
Date: Wed, 11 Sep 2024 10:30:20 +0100	[thread overview]
Message-ID: <20240911093029.3279154-5-vdonnefort@google.com> (raw)
In-Reply-To: <20240911093029.3279154-1-vdonnefort@google.com>

For tracing purpose, the boot clock is interesting as it doesn't stop on
suspend. Export it as part of the time snapshot. This will later allow
the hypervisor to add boot clock timestamps to its events.

Cc: John Stultz <jstultz@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Christopher S. Hall <christopher.s.hall@intel.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index fc12a9ba2c88..e85c27347e44 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -275,6 +275,7 @@ struct ktime_timestamps {
  *				 counter value
  * @cycles:	Clocksource counter value to produce the system times
  * @real:	Realtime system time
+ * @boot:	Boot time
  * @raw:	Monotonic raw system time
  * @cs_id:	Clocksource ID
  * @clock_was_set_seq:	The sequence number of clock-was-set events
@@ -283,6 +284,7 @@ struct ktime_timestamps {
 struct system_time_snapshot {
 	u64			cycles;
 	ktime_t			real;
+	ktime_t			boot;
 	ktime_t			raw;
 	enum clocksource_ids	cs_id;
 	unsigned int		clock_was_set_seq;
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 5391e4167d60..db16c44dccc3 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1060,6 +1060,7 @@ void ktime_get_snapshot(struct system_time_snapshot *systime_snapshot)
 	unsigned int seq;
 	ktime_t base_raw;
 	ktime_t base_real;
+	ktime_t base_boot;
 	u64 nsec_raw;
 	u64 nsec_real;
 	u64 now;
@@ -1074,6 +1075,8 @@ void ktime_get_snapshot(struct system_time_snapshot *systime_snapshot)
 		systime_snapshot->clock_was_set_seq = tk->clock_was_set_seq;
 		base_real = ktime_add(tk->tkr_mono.base,
 				      tk_core.timekeeper.offs_real);
+		base_boot = ktime_add(tk->tkr_mono.base,
+				      tk_core.timekeeper.offs_boot);
 		base_raw = tk->tkr_raw.base;
 		nsec_real = timekeeping_cycles_to_ns(&tk->tkr_mono, now);
 		nsec_raw  = timekeeping_cycles_to_ns(&tk->tkr_raw, now);
@@ -1081,6 +1084,7 @@ void ktime_get_snapshot(struct system_time_snapshot *systime_snapshot)
 
 	systime_snapshot->cycles = now;
 	systime_snapshot->real = ktime_add_ns(base_real, nsec_real);
+	systime_snapshot->boot = ktime_add_ns(base_boot, nsec_real);
 	systime_snapshot->raw = ktime_add_ns(base_raw, nsec_raw);
 }
 EXPORT_SYMBOL_GPL(ktime_get_snapshot);
-- 
2.46.0.598.g6f2099f65c-goog


  parent reply	other threads:[~2024-09-11  9:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-11  9:30 [PATCH 00/13] Tracefs support for pKVM Vincent Donnefort
2024-09-11  9:30 ` [PATCH 01/13] ring-buffer: Check for empty ring-buffer with rb_num_of_entries() Vincent Donnefort
2024-09-11  9:30 ` [PATCH 02/13] ring-buffer: Introducing ring-buffer writer Vincent Donnefort
2024-09-12 12:55   ` kernel test robot
2024-09-11  9:30 ` [PATCH 03/13] ring-buffer: Expose buffer_data_page material Vincent Donnefort
2024-09-11  9:30 ` Vincent Donnefort [this message]
2024-09-13 22:28   ` [PATCH 04/13] timekeeping: Add the boot clock to system time snapshot John Stultz
2024-10-02 15:15   ` Thomas Gleixner
2024-09-11  9:30 ` [PATCH 05/13] KVM: arm64: Support unaligned fixmap in the nVHE hyp Vincent Donnefort
2024-09-11  9:30 ` [PATCH 06/13] KVM: arm64: Add clock support " Vincent Donnefort
2024-09-13 22:41   ` John Stultz
2024-09-16 12:26     ` Vincent Donnefort
2024-09-11  9:30 ` [PATCH 07/13] KVM: arm64: Add tracing support for the pKVM hyp Vincent Donnefort
2024-09-11  9:30 ` [PATCH 08/13] KVM: arm64: Add hyp tracing to tracefs Vincent Donnefort
2024-09-11  9:30 ` [PATCH 09/13] KVM: arm64: Add clock for hyp tracefs Vincent Donnefort
2024-09-13 23:21   ` John Stultz
2024-09-16 12:39     ` Vincent Donnefort
2024-09-11  9:30 ` [PATCH 10/13] KVM: arm64: Add raw interface " Vincent Donnefort
2024-09-11  9:30 ` [PATCH 11/13] KVM: arm64: Add trace " Vincent Donnefort
2024-09-11  9:30 ` [PATCH 12/13] KVM: arm64: Add support for hyp events Vincent Donnefort
2024-09-11  9:30 ` [PATCH 13/13] KVM: arm64: Add kselftest for tracefs hyp tracefs Vincent Donnefort
2025-01-07 19:54 ` [PATCH 00/13] Tracefs support for pKVM Steven Rostedt
2025-01-07 21:46   ` Vincent Donnefort

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=20240911093029.3279154-5-vdonnefort@google.com \
    --to=vdonnefort@google.com \
    --cc=christopher.s.hall@intel.com \
    --cc=jstultz@google.com \
    --cc=kernel-team@android.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=lakshmi.sowjanya.d@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=qperret@google.com \
    --cc=richardcochran@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=will@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox