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
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 {
kernel/time/sched_clock.c+1−1
@@ -229,7 +229,7 @@ void __init generic_sched_clock_init(void) · 228 unmodified lines
229229 {
230230 /*
231231 * If no sched_clock() function has been provided at that point,
232− * make it the final one one.
232+ * make it the final one.
233233 */
234234 if (cd.actual_read_sched_clock == jiffy_sched_clock_read)
235235 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
3939 TK_ADV_FREQ
4040 };
4141
42−static DEFINE_RAW_SPINLOCK(timekeeper_lock);
42+DEFINE_RAW_SPINLOCK(timekeeper_lock);
4343
4444 /*
4545 * 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
20042004 * logarithmic_accumulation - shifted accumulation of cycles
20052005 *
20062006 * This functions accumulates a shifted interval of cycles into
2007− * into a shifted interval nanoseconds. Allows for O(log) accumulation
2007+ * a shifted interval nanoseconds. Allows for O(log) accumulation
20082008 * loop.
20092009 *
20102010 * Returns the unconsumed cycles.
kernel/time/timekeeping_internal.h+8−3
@@ -1,12 +1,14 @@
11 /* SPDX-License-Identifier: GPL-2.0 */
22 #ifndef _TIMEKEEPING_INTERNAL_H
33 #define _TIMEKEEPING_INTERNAL_H
4−/*
5− * timekeeping debug functions
6− */
4+
75 #include <linux/clocksource.h>
6+#include <linux/spinlock.h>
87 #include <linux/time.h>
98
9+/*
10+ * timekeeping debug functions
11+ */
1012 #ifdef CONFIG_DEBUG_FS
1113 extern void tk_debug_account_sleep_time(const struct timespec64 *t);
1214 #else
@@ -31,4 +33,7 @@ static inline u64 clocksource_delta(u64 now, u64 last, u64 mask) · 18 unmodified lines
3133 }
3234 #endif
3335
36+/* Semi public for serialization of non timekeeper VDSO updates. */
37+extern raw_spinlock_t timekeeper_lock;
38+
3439 #endif /* _TIMEKEEPING_INTERNAL_H */
kernel/time/vsyscall.c+41−0
@@ -13,6 +13,8 @@ · 12 unmodified lines
1313 #include <vdso/helpers.h>
1414 #include <vdso/vsyscall.h>
1515
16+#include "timekeeping_internal.h"
17+
1618 static inline void update_vdso_data(struct vdso_data *vdata,
1719 struct timekeeper *tk)
1820 {
@@ -127,3 +129,42 @@ void update_vsyscall_tz(void) · 108 unmodified lines
127129
128130 __arch_sync_vdso_data(vdata);
129131 }
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+ */
145+unsigned 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+ */
163+void 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