[v4,01/24] kernel: Standardize vdso_datapage
diff mbox series

Message ID 20190115135539.24762-2-vincenzo.frascino@arm.com
State New
Headers show
Series
  • Unify vDSOs across more architectures
Related show

Commit Message

Vincenzo Frascino Jan. 15, 2019, 1:55 p.m. UTC
In an effort to unify the common code for managing the vdso library in
between all the architectures that support it, this patch tries to
provide a common format for the vdso datapage.

As a result of this, this patch generalized the data structures in vgtod.h
from x86 private includes to general includes (include/vdso).

Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 include/vdso/datapage.h | 60 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 include/vdso/datapage.h

Comments

Thomas Gleixner Jan. 15, 2019, 2:57 p.m. UTC | #1
On Tue, 15 Jan 2019, Vincenzo Frascino wrote:

> +/*
> + * There is one vdso_timestamp object in vvar for each vDSO-accelerated
> + * clock_id. For high-resolution clocks, this encodes the time
> + * corresponding to vdso_data.cycle_last. For coarse clocks this encodes
> + * the actual time.
> + *
> + * To be noticed that nsec is left-shifted by vdso_data.shift.

This is only true for highres clocks. For coarse the nsec value is not
shifted.

> + */
> +struct vdso_timestamp {
> +	u64 sec;
> +	u64 nsec;
> +};
> +
> +/*
> + * vdso_data will be accessed by 32 and 64 bit code at the same time
> + * so we should be careful before modifying this structure.
> + */
> +struct vdso_data {
> +	u32 seq;		/* Timebase sequence counter */
> +
> +	s32 clock_mode;
> +	u64 cycle_last;		/* Timebase at clocksource init */
> +	u64 mask;		/* Clocksource mask (mono = raw) */

mono = raw? This is broken. The VDSO cannot define time different from the
regular syscall interfaces.

Thanks,

	tglx
Vincenzo Frascino Jan. 15, 2019, 3:26 p.m. UTC | #2
On 15/01/2019 14:57, Thomas Gleixner wrote:
> On Tue, 15 Jan 2019, Vincenzo Frascino wrote:
> 
>> +/*
>> + * There is one vdso_timestamp object in vvar for each vDSO-accelerated
>> + * clock_id. For high-resolution clocks, this encodes the time
>> + * corresponding to vdso_data.cycle_last. For coarse clocks this encodes
>> + * the actual time.
>> + *
>> + * To be noticed that nsec is left-shifted by vdso_data.shift.
> 
> This is only true for highres clocks. For coarse the nsec value is not
> shifted.
>

Agreed, missed part of the comment here. I will fix it in v5.

>> + */
>> +struct vdso_timestamp {
>> +	u64 sec;
>> +	u64 nsec;
>> +};
>> +
>> +/*
>> + * vdso_data will be accessed by 32 and 64 bit code at the same time
>> + * so we should be careful before modifying this structure.
>> + */
>> +struct vdso_data {
>> +	u32 seq;		/* Timebase sequence counter */
>> +
>> +	s32 clock_mode;
>> +	u64 cycle_last;		/* Timebase at clocksource init */
>> +	u64 mask;		/* Clocksource mask (mono = raw) */
> 
> mono = raw? This is broken. The VDSO cannot define time different from the
> regular syscall interfaces.
> 

On v2 of this series I had the masks for mono and raw separate, but based on
your comment (the core timekeeper has them duplicated purely for access pattern
optimization and simplicity). I unified them. Could you please provide more
details on what should be done in this case?

> Thanks,
> 
> 	tglx
>
Thomas Gleixner Jan. 15, 2019, 3:29 p.m. UTC | #3
On Tue, 15 Jan 2019, Vincenzo Frascino wrote:
> On 15/01/2019 14:57, Thomas Gleixner wrote:
> >> +	u64 mask;		/* Clocksource mask (mono = raw) */
> > 
> > mono = raw? This is broken. The VDSO cannot define time different from the
> > regular syscall interfaces.
> > 
> 
> On v2 of this series I had the masks for mono and raw separate, but based on
> your comment (the core timekeeper has them duplicated purely for access pattern
> optimization and simplicity). I unified them. Could you please provide more
> details on what should be done in this case?

The mask is the same, but the mult is different. I'm not seing how this is
implemented. Both MONO and MONO_RAW invoke do_hres() and use the common
mult/shift pair.

Thanks,

	tglx

Patch
diff mbox series

diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
new file mode 100644
index 000000000000..e88678f918e5
--- /dev/null
+++ b/include/vdso/datapage.h
@@ -0,0 +1,60 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __VDSO_DATAPAGE_H
+#define __VDSO_DATAPAGE_H
+
+#ifdef __KERNEL__
+
+#ifndef __ASSEMBLY__
+
+#include <linux/bits.h>
+#include <linux/types.h>
+#include <linux/time.h>
+
+#define VDSO_BASES	(CLOCK_TAI + 1)
+#define VDSO_HRES	(BIT(CLOCK_REALTIME)		| \
+			 BIT(CLOCK_MONOTONIC)		| \
+			 BIT(CLOCK_MONOTONIC_RAW)	| \
+			 BIT(CLOCK_BOOTTIME)		| \
+			 BIT(CLOCK_TAI))
+#define VDSO_COARSE	(BIT(CLOCK_REALTIME_COARSE)	| \
+			 BIT(CLOCK_MONOTONIC_COARSE))
+
+/*
+ * There is one vdso_timestamp object in vvar for each vDSO-accelerated
+ * clock_id. For high-resolution clocks, this encodes the time
+ * corresponding to vdso_data.cycle_last. For coarse clocks this encodes
+ * the actual time.
+ *
+ * To be noticed that nsec is left-shifted by vdso_data.shift.
+ */
+struct vdso_timestamp {
+	u64 sec;
+	u64 nsec;
+};
+
+/*
+ * vdso_data will be accessed by 32 and 64 bit code at the same time
+ * so we should be careful before modifying this structure.
+ */
+struct vdso_data {
+	u32 seq;		/* Timebase sequence counter */
+
+	s32 clock_mode;
+	u64 cycle_last;		/* Timebase at clocksource init */
+	u64 mask;		/* Clocksource mask (mono = raw) */
+	u32 mult;		/* Clocksource multiplier */
+	u32 shift;		/* Clocksource shift (mono = raw) */
+
+	struct vdso_timestamp basetime[VDSO_BASES];
+
+	s32 tz_minuteswest;	/* Timezone definitions */
+	s32 tz_dsttime;
+	u32 use_syscall;
+	u32 __reserved;
+};
+
+#endif /* !__ASSEMBLY__ */
+
+#endif /* __KERNEL__ */
+
+#endif /* __VDSO_DATAPAGE_H */