History

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()

Linus Torvalds committed 6 years ago

Commit b923f122 parents b6b178e b0294f315 files · +84 −16Browse files

Showing the changes to kernel (5 of 15 files). Show all

Unified · Split

5 files
  1. kernel/time/alarmtimer.c +1 −1
  2. kernel/time/sched_clock.c +1 −1
  3. kernel/time/timekeeping.c +2 −2
  4. kernel/time/timekeeping_internal.h +8 −3
  5. kernel/time/vsyscall.c +41 −0
kernel/time/alarmtimer.c+1−1
@@ -192,7 +192,7 @@ static void alarmtimer_dequeue(struct alarm_base *base, struct alarm *alarm) · 191 unmodified lines
192 * When a alarm timer fires, this runs through the timerqueue to192 * When a alarm timer fires, this runs through the timerqueue to
193 * see which alarms expired, and runs those. If there are more alarm193 * see which alarms expired, and runs those. If there are more alarm
194 * timers queued for the future, we set the hrtimer to fire when194 * 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.
196 */196 */
197static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer)197static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer)
198{198{
kernel/time/sched_clock.c+1−1
@@ -229,7 +229,7 @@ void __init generic_sched_clock_init(void) · 228 unmodified lines
229{229{
230 /*230 /*
231 * If no sched_clock() function has been provided at that point,231 * If no sched_clock() function has been provided at that point,
232 * make it the final one one.232 * make it the final one.
233 */233 */
234 if (cd.actual_read_sched_clock == jiffy_sched_clock_read)234 if (cd.actual_read_sched_clock == jiffy_sched_clock_read)
235 sched_clock_register(jiffy_sched_clock_read, BITS_PER_LONG, HZ);235 sched_clock_register(jiffy_sched_clock_read, BITS_PER_LONG, HZ);
kernel/time/timekeeping.c+2−2
@@ -39,7 +39,7 @@ enum timekeeping_adv_mode { · 38 unmodified lines
39 TK_ADV_FREQ39 TK_ADV_FREQ
40};40};
41 41
42static DEFINE_RAW_SPINLOCK(timekeeper_lock);42DEFINE_RAW_SPINLOCK(timekeeper_lock);
43 43
44/*44/*
45 * The most important data for readout fits into a single 64 byte45 * The most important data for readout fits into a single 64 byte
@@ -2004,7 +2004,7 @@ static inline unsigned int accumulate_nsecs_to_secs(struct timekeeper *tk) · 1958 unmodified lines
2004 * logarithmic_accumulation - shifted accumulation of cycles2004 * logarithmic_accumulation - shifted accumulation of cycles
2005 *2005 *
2006 * This functions accumulates a shifted interval of cycles into2006 * This functions accumulates a shifted interval of cycles into
2007 * into a shifted interval nanoseconds. Allows for O(log) accumulation2007 * a shifted interval nanoseconds. Allows for O(log) accumulation
2008 * loop.2008 * loop.
2009 *2009 *
2010 * Returns the unconsumed cycles.2010 * Returns the unconsumed cycles.
kernel/time/timekeeping_internal.h+8−3
@@ -1,12 +1,14 @@
1/* SPDX-License-Identifier: GPL-2.0 */1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _TIMEKEEPING_INTERNAL_H2#ifndef _TIMEKEEPING_INTERNAL_H
3#define _TIMEKEEPING_INTERNAL_H3#define _TIMEKEEPING_INTERNAL_H
4/*4
5 * timekeeping debug functions
6 */
7#include <linux/clocksource.h>5#include <linux/clocksource.h>
6#include <linux/spinlock.h>
8#include <linux/time.h>7#include <linux/time.h>
9 8
9/*
10 * timekeeping debug functions
11 */
10#ifdef CONFIG_DEBUG_FS12#ifdef CONFIG_DEBUG_FS
11extern void tk_debug_account_sleep_time(const struct timespec64 *t);13extern void tk_debug_account_sleep_time(const struct timespec64 *t);
12#else14#else
@@ -31,4 +33,7 @@ static inline u64 clocksource_delta(u64 now, u64 last, u64 mask) · 18 unmodified lines
31}33}
32#endif34#endif
33 35
36/* Semi public for serialization of non timekeeper VDSO updates. */
37extern raw_spinlock_t timekeeper_lock;
38
34#endif /* _TIMEKEEPING_INTERNAL_H */39#endif /* _TIMEKEEPING_INTERNAL_H */
kernel/time/vsyscall.c+41−0
@@ -13,6 +13,8 @@ · 12 unmodified lines
13#include <vdso/helpers.h>13#include <vdso/helpers.h>
14#include <vdso/vsyscall.h>14#include <vdso/vsyscall.h>
15 15
16#include "timekeeping_internal.h"
17
16static inline void update_vdso_data(struct vdso_data *vdata,18static inline void update_vdso_data(struct vdso_data *vdata,
17 struct timekeeper *tk)19 struct timekeeper *tk)
18{20{
@@ -127,3 +129,42 @@ void update_vsyscall_tz(void) · 108 unmodified lines
127 129
128 __arch_sync_vdso_data(vdata);130 __arch_sync_vdso_data(vdata);
129}131}
132
133/**
134 * vdso_update_begin - Start of a VDSO update section
135 *
136 * Allows architecture code to safely update the architecture specific VDSO
137 * data. Disables interrupts, acquires timekeeper lock to serialize against
138 * concurrent updates from timekeeping and invalidates the VDSO data
139 * sequence counter to prevent concurrent readers from accessing
140 * inconsistent data.
141 *
142 * Returns: Saved interrupt flags which need to be handed in to
143 * vdso_update_end().
144 */
145unsigned long vdso_update_begin(void)
146{
147 struct vdso_data *vdata = __arch_get_k_vdso_data();
148 unsigned long flags;
149
150 raw_spin_lock_irqsave(&timekeeper_lock, flags);
151 vdso_write_begin(vdata);
152 return flags;
153}
154
155/**
156 * vdso_update_end - End of a VDSO update section
157 * @flags: Interrupt flags as returned from vdso_update_begin()
158 *
159 * Pairs with vdso_update_begin(). Marks vdso data consistent, invokes data
160 * synchronization if the architecture requires it, drops timekeeper lock
161 * and restores interrupt flags.
162 */
163void vdso_update_end(unsigned long flags)
164{
165 struct vdso_data *vdata = __arch_get_k_vdso_data();
166
167 vdso_write_end(vdata);
168 __arch_sync_vdso_data(vdata);
169 raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
170}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t