Skip to content

Commit b923f12

Browse files
committed
Merge tag 'timers-urgent-2020-08-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timekeeping updates from Thomas Gleixner: "A set of timekeeping/VDSO updates: - Preparatory work to allow S390 to switch over to the generic VDSO implementation. S390 requires that the VDSO data pointer is handed in to the counter read function when time namespace support is enabled. Adding the pointer is a NOOP for all other architectures because the compiler is supposed to optimize that out when it is unused in the architecture specific inline. The change also solved a similar problem for MIPS which fortunately has time namespaces not yet enabled. S390 needs to update clock related VDSO data independent of the timekeeping updates. This was solved so far with yet another sequence counter in the S390 implementation. A better solution is to utilize the already existing VDSO sequence count for this. The core code now exposes helper functions which allow to serialize against the timekeeper code and against concurrent readers. S390 needs extra data for their clock readout function. The initial common VDSO data structure did not provide a way to add that. It now has an embedded architecture specific struct embedded which defaults to an empty struct. Doing this now avoids tree dependencies and conflicts post rc1 and allows all other architectures which work on generic VDSO support to work from a common upstream base. - A trivial comment fix" * tag 'timers-urgent-2020-08-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: time: Delete repeated words in comments lib/vdso: Allow to add architecture-specific vdso data timekeeping/vsyscall: Provide vdso_update_begin/end() vdso/treewide: Add vdso_data pointer argument to __arch_get_hw_counter()
2 parents b6b178e + b0294f3 commit b923f12

File tree

15 files changed

+84
-16
lines changed

15 files changed

+84
-16
lines changed

arch/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,9 @@ config HAVE_SPARSE_SYSCALL_NR
972972
entries at 4000, 5000 and 6000 locations. This option turns on syscall
973973
related optimizations for a given architecture.
974974

975+
config ARCH_HAS_VDSO_DATA
976+
bool
977+
975978
source "kernel/gcov/Kconfig"
976979

977980
source "scripts/gcc-plugins/Kconfig"

arch/arm/include/asm/vdso/gettimeofday.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ static inline bool arm_vdso_hres_capable(void)
113113
}
114114
#define __arch_vdso_hres_capable arm_vdso_hres_capable
115115

116-
static __always_inline u64 __arch_get_hw_counter(int clock_mode)
116+
static __always_inline u64 __arch_get_hw_counter(int clock_mode,
117+
const struct vdso_data *vd)
117118
{
118119
#ifdef CONFIG_ARM_ARCH_TIMER
119120
u64 cycle_now;

arch/arm64/include/asm/vdso/compat_gettimeofday.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ int clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
103103
return ret;
104104
}
105105

106-
static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
106+
static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
107+
const struct vdso_data *vd)
107108
{
108109
u64 res;
109110

arch/arm64/include/asm/vdso/gettimeofday.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
6464
return ret;
6565
}
6666

67-
static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
67+
static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
68+
const struct vdso_data *vd)
6869
{
6970
u64 res;
7071

arch/mips/include/asm/vdso/gettimeofday.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,16 @@ static __always_inline u64 read_gic_count(const struct vdso_data *data)
167167

168168
#endif
169169

170-
static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
170+
static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
171+
const struct vdso_data *vd)
171172
{
172173
#ifdef CONFIG_CSRC_R4K
173174
if (clock_mode == VDSO_CLOCKMODE_R4K)
174175
return read_r4k_count();
175176
#endif
176177
#ifdef CONFIG_CLKSRC_MIPS_GIC
177178
if (clock_mode == VDSO_CLOCKMODE_GIC)
178-
return read_gic_count(get_vdso_data());
179+
return read_gic_count(vd);
179180
#endif
180181
/*
181182
* Core checks mode already. So this raced against a concurrent

arch/riscv/include/asm/vdso/gettimeofday.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
6060
return ret;
6161
}
6262

63-
static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
63+
static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
64+
const struct vdso_data *vd)
6465
{
6566
/*
6667
* The purpose of csr_read(CSR_TIME) is to trap the system into

arch/x86/include/asm/vdso/gettimeofday.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ static u64 vread_hvclock(void)
241241
}
242242
#endif
243243

244-
static inline u64 __arch_get_hw_counter(s32 clock_mode)
244+
static inline u64 __arch_get_hw_counter(s32 clock_mode,
245+
const struct vdso_data *vd)
245246
{
246247
if (likely(clock_mode == VDSO_CLOCKMODE_TSC))
247248
return (u64)rdtsc_ordered();

include/vdso/datapage.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
#include <vdso/time32.h>
2020
#include <vdso/time64.h>
2121

22+
#ifdef CONFIG_ARCH_HAS_VDSO_DATA
23+
#include <asm/vdso/data.h>
24+
#else
25+
struct arch_vdso_data {};
26+
#endif
27+
2228
#define VDSO_BASES (CLOCK_TAI + 1)
2329
#define VDSO_HRES (BIT(CLOCK_REALTIME) | \
2430
BIT(CLOCK_MONOTONIC) | \
@@ -64,6 +70,8 @@ struct vdso_timestamp {
6470
* @tz_dsttime: type of DST correction
6571
* @hrtimer_res: hrtimer resolution
6672
* @__unused: unused
73+
* @arch_data: architecture specific data (optional, defaults
74+
* to an empty struct)
6775
*
6876
* vdso_data will be accessed by 64 bit and compat code at the same time
6977
* so we should be careful before modifying this structure.
@@ -97,6 +105,8 @@ struct vdso_data {
97105
s32 tz_dsttime;
98106
u32 hrtimer_res;
99107
u32 __unused;
108+
109+
struct arch_vdso_data arch_data;
100110
};
101111

102112
/*

include/vdso/vsyscall.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
#include <asm/vdso/vsyscall.h>
88

9+
unsigned long vdso_update_begin(void);
10+
void vdso_update_end(unsigned long flags);
11+
912
#endif /* !__ASSEMBLY__ */
1013

1114
#endif /* __VDSO_VSYSCALL_H */

kernel/time/alarmtimer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static void alarmtimer_dequeue(struct alarm_base *base, struct alarm *alarm)
192192
* When a alarm timer fires, this runs through the timerqueue to
193193
* see which alarms expired, and runs those. If there are more alarm
194194
* timers queued for the future, we set the hrtimer to fire when
195-
* when the next future alarm timer expires.
195+
* the next future alarm timer expires.
196196
*/
197197
static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer)
198198
{

0 commit comments

Comments
 (0)