Skip to contentSkip to conversation

lib: vdso: Add support for CLOCK_BOOTTIME

PATCH Superseded Mark Salyzyn 1 participant 1 message Oct 27, 2017

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 11/12 lib: vdso: Add support for CLOCK_BOOTTIME

Add a case for CLOCK_BOOTTIME as it is popular for measuring relative time on systems expected to suspend() or hibernate().

Cc James Morse <[email protected]>
Cc Russell King <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Dmitry Safonov <[email protected]>
Cc John Stultz <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Kees Cook <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Andy Gross <[email protected]>
Cc Kevin Brodsky <[email protected]>
Cc Andrew Pinski <[email protected]>
Cc linux-kernel at vger.kernel.org
Cc linux-arm-kernel at lists.infradead.org

v2:
- rebased and changed from 3/3 to 10/10, fortified commit message.

v3:
- move arch/arm/vdso/vgettimeofday.c to lib/vdso/vgettimeofday.c

---
 arch/arm/include/asm/vdso_datapage.h   |  1 +
 arch/arm/kernel/vdso.c                 |  1 +
 arch/arm64/include/asm/vdso_datapage.h |  1 +
 arch/arm64/kernel/vdso.c               |  1 +
 lib/vdso/vgettimeofday.c               | 56 ++++++++++++++++++++++++++++++++++
 5 files changed, 60 insertions(+)
arch/arm/include/asm/vdso_datapage.h +1 -0
index d57c296f7f52..d2c8e0807f06 100644
@@ -47,6 +47,7 @@ struct vdso_data {
 	u32 tz_minuteswest;	/* timezone info for gettimeofday(2) */
 	u32 tz_dsttime;
 
+	u64 btm_nsec;		/* monotonic to boot time */
 	u32 cs_raw_mult;	/* Raw clocksource multipler */
 	u32 raw_time_sec;	/* Raw time */
 	u32 raw_time_nsec;
arch/arm/kernel/vdso.c +1 -0
index 287424541f3a..9370ab4b2734 100644
@@ -347,6 +347,7 @@ void update_vsyscall(struct timekeeper *tk)
 		/* tkr_mono.shift == tkr_raw.shift */
 		vdso_data->cs_shift		= tk->tkr_mono.shift;
 		vdso_data->cs_mask		= tk->tkr_mono.mask;
+		vdso_data->btm_nsec		= ktime_to_ns(tk->offs_boot);
 	}
 
 	vdso_write_end(vdso_data);
arch/arm64/include/asm/vdso_datapage.h +1 -0
index c9e30226cdbc..1e115b0f373d 100644
@@ -30,6 +30,7 @@ struct vdso_data {
 	__u64 xtime_coarse_nsec;
 	__u64 wtm_clock_sec;	/* Wall to monotonic time */
 	__u64 wtm_clock_nsec;
+	__u64 btm_nsec;		/* monotonic to boot time */
 	__u32 tb_seq_count;	/* Timebase sequence counter */
 	/* cs_* members must be adjacent and in this order (ldp accesses) */
 	__u32 cs_mono_mult;	/* NTP-adjusted clocksource multiplier */
arch/arm64/kernel/vdso.c +1 -0
index 59f150c25889..0710edd8bedc 100644
@@ -243,6 +243,7 @@ void update_vsyscall(struct timekeeper *tk)
 		vdso_data->cs_raw_mult		= tk->tkr_raw.mult;
 		/* tkr_mono.shift == tkr_raw.shift */
 		vdso_data->cs_shift		= tk->tkr_mono.shift;
+		vdso_data->btm_nsec		= ktime_to_ns(tk->offs_boot);
 	}
 
 	smp_wmb();
lib/vdso/vgettimeofday.c +56 -0

80 lines not on this page · raw message

Signature · 1 line
2.15.0.rc2.357.g7e34df9404-goog