Skip to content

Commit 3520c35

Browse files
committed
Merge tag 'timers-urgent-2024-04-07' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fixes from Ingo Molnar: "Fix various timer bugs: - Fix a timer migration bug that may result in missed events - Fix timer migration group hierarchy event updates - Fix a PowerPC64 build warning - Fix a handful of DocBook annotation bugs" * tag 'timers-urgent-2024-04-07' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: timers/migration: Return early on deactivation timers/migration: Fix ignored event due to missing CPU update vdso: Use CONFIG_PAGE_SHIFT in vdso/datapage.h timers: Fix text inconsistencies and spelling tick/sched: Fix struct tick_sched doc warnings tick/sched: Fix various kernel-doc warnings timers: Fix kernel-doc format and add Return values time/timekeeping: Fix kernel-doc warnings and typos time/timecounter: Fix inline documentation
2 parents e2948ef + 7a96a84 commit 3520c35

File tree

9 files changed

+121
-36
lines changed

9 files changed

+121
-36
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#ifndef __ASSEMBLY__
66

7-
#include <asm/page.h>
87
#include <asm/vdso/timebase.h>
98
#include <asm/barrier.h>
109
#include <asm/unistd.h>
@@ -95,7 +94,7 @@ const struct vdso_data *__arch_get_vdso_data(void);
9594
static __always_inline
9695
const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd)
9796
{
98-
return (void *)vd + PAGE_SIZE;
97+
return (void *)vd + (1U << CONFIG_PAGE_SHIFT);
9998
}
10099
#endif
101100

include/linux/timecounter.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
* @read: returns the current cycle value
2424
* @mask: bitmask for two's complement
25-
* subtraction of non 64 bit counters,
25+
* subtraction of non-64-bit counters,
2626
* see CYCLECOUNTER_MASK() helper macro
2727
* @mult: cycle to nanosecond multiplier
2828
* @shift: cycle to nanosecond divisor (power of two)
@@ -35,7 +35,7 @@ struct cyclecounter {
3535
};
3636

3737
/**
38-
* struct timecounter - layer above a %struct cyclecounter which counts nanoseconds
38+
* struct timecounter - layer above a &struct cyclecounter which counts nanoseconds
3939
* Contains the state needed by timecounter_read() to detect
4040
* cycle counter wrap around. Initialize with
4141
* timecounter_init(). Also used to convert cycle counts into the
@@ -66,6 +66,8 @@ struct timecounter {
6666
* @cycles: Cycles
6767
* @mask: bit mask for maintaining the 'frac' field
6868
* @frac: pointer to storage for the fractional nanoseconds.
69+
*
70+
* Returns: cycle counter cycles converted to nanoseconds
6971
*/
7072
static inline u64 cyclecounter_cyc2ns(const struct cyclecounter *cc,
7173
u64 cycles, u64 mask, u64 *frac)
@@ -79,6 +81,7 @@ static inline u64 cyclecounter_cyc2ns(const struct cyclecounter *cc,
7981

8082
/**
8183
* timecounter_adjtime - Shifts the time of the clock.
84+
* @tc: The &struct timecounter to adjust
8285
* @delta: Desired change in nanoseconds.
8386
*/
8487
static inline void timecounter_adjtime(struct timecounter *tc, s64 delta)
@@ -107,6 +110,8 @@ extern void timecounter_init(struct timecounter *tc,
107110
*
108111
* In other words, keeps track of time since the same epoch as
109112
* the function which generated the initial time stamp.
113+
*
114+
* Returns: nanoseconds since the initial time stamp
110115
*/
111116
extern u64 timecounter_read(struct timecounter *tc);
112117

@@ -123,6 +128,8 @@ extern u64 timecounter_read(struct timecounter *tc);
123128
*
124129
* This allows conversion of cycle counter values which were generated
125130
* in the past.
131+
*
132+
* Returns: cycle counter converted to nanoseconds since the initial time stamp
126133
*/
127134
extern u64 timecounter_cyc2time(const struct timecounter *tc,
128135
u64 cycle_tstamp);

include/linux/timekeeping.h

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ extern int do_sys_settimeofday64(const struct timespec64 *tv,
2222
const struct timezone *tz);
2323

2424
/*
25-
* ktime_get() family: read the current time in a multitude of ways,
25+
* ktime_get() family - read the current time in a multitude of ways.
2626
*
2727
* The default time reference is CLOCK_MONOTONIC, starting at
2828
* boot time but not counting the time spent in suspend.
2929
* For other references, use the functions with "real", "clocktai",
3030
* "boottime" and "raw" suffixes.
3131
*
32-
* To get the time in a different format, use the ones wit
32+
* To get the time in a different format, use the ones with
3333
* "ns", "ts64" and "seconds" suffix.
3434
*
3535
* See Documentation/core-api/timekeeping.rst for more details.
@@ -74,6 +74,8 @@ extern u32 ktime_get_resolution_ns(void);
7474

7575
/**
7676
* ktime_get_real - get the real (wall-) time in ktime_t format
77+
*
78+
* Returns: real (wall) time in ktime_t format
7779
*/
7880
static inline ktime_t ktime_get_real(void)
7981
{
@@ -86,10 +88,12 @@ static inline ktime_t ktime_get_coarse_real(void)
8688
}
8789

8890
/**
89-
* ktime_get_boottime - Returns monotonic time since boot in ktime_t format
91+
* ktime_get_boottime - Get monotonic time since boot in ktime_t format
9092
*
9193
* This is similar to CLOCK_MONTONIC/ktime_get, but also includes the
9294
* time spent in suspend.
95+
*
96+
* Returns: monotonic time since boot in ktime_t format
9397
*/
9498
static inline ktime_t ktime_get_boottime(void)
9599
{
@@ -102,7 +106,9 @@ static inline ktime_t ktime_get_coarse_boottime(void)
102106
}
103107

104108
/**
105-
* ktime_get_clocktai - Returns the TAI time of day in ktime_t format
109+
* ktime_get_clocktai - Get the TAI time of day in ktime_t format
110+
*
111+
* Returns: the TAI time of day in ktime_t format
106112
*/
107113
static inline ktime_t ktime_get_clocktai(void)
108114
{
@@ -144,32 +150,60 @@ static inline u64 ktime_get_coarse_clocktai_ns(void)
144150

145151
/**
146152
* ktime_mono_to_real - Convert monotonic time to clock realtime
153+
* @mono: monotonic time to convert
154+
*
155+
* Returns: time converted to realtime clock
147156
*/
148157
static inline ktime_t ktime_mono_to_real(ktime_t mono)
149158
{
150159
return ktime_mono_to_any(mono, TK_OFFS_REAL);
151160
}
152161

162+
/**
163+
* ktime_get_ns - Get the current time in nanoseconds
164+
*
165+
* Returns: current time converted to nanoseconds
166+
*/
153167
static inline u64 ktime_get_ns(void)
154168
{
155169
return ktime_to_ns(ktime_get());
156170
}
157171

172+
/**
173+
* ktime_get_real_ns - Get the current real/wall time in nanoseconds
174+
*
175+
* Returns: current real time converted to nanoseconds
176+
*/
158177
static inline u64 ktime_get_real_ns(void)
159178
{
160179
return ktime_to_ns(ktime_get_real());
161180
}
162181

182+
/**
183+
* ktime_get_boottime_ns - Get the monotonic time since boot in nanoseconds
184+
*
185+
* Returns: current boottime converted to nanoseconds
186+
*/
163187
static inline u64 ktime_get_boottime_ns(void)
164188
{
165189
return ktime_to_ns(ktime_get_boottime());
166190
}
167191

192+
/**
193+
* ktime_get_clocktai_ns - Get the current TAI time of day in nanoseconds
194+
*
195+
* Returns: current TAI time converted to nanoseconds
196+
*/
168197
static inline u64 ktime_get_clocktai_ns(void)
169198
{
170199
return ktime_to_ns(ktime_get_clocktai());
171200
}
172201

202+
/**
203+
* ktime_get_raw_ns - Get the raw monotonic time in nanoseconds
204+
*
205+
* Returns: current raw monotonic time converted to nanoseconds
206+
*/
173207
static inline u64 ktime_get_raw_ns(void)
174208
{
175209
return ktime_to_ns(ktime_get_raw());
@@ -224,8 +258,8 @@ extern bool timekeeping_rtc_skipresume(void);
224258

225259
extern void timekeeping_inject_sleeptime64(const struct timespec64 *delta);
226260

227-
/*
228-
* struct ktime_timestanps - Simultaneous mono/boot/real timestamps
261+
/**
262+
* struct ktime_timestamps - Simultaneous mono/boot/real timestamps
229263
* @mono: Monotonic timestamp
230264
* @boot: Boottime timestamp
231265
* @real: Realtime timestamp
@@ -242,7 +276,8 @@ struct ktime_timestamps {
242276
* @cycles: Clocksource counter value to produce the system times
243277
* @real: Realtime system time
244278
* @raw: Monotonic raw system time
245-
* @clock_was_set_seq: The sequence number of clock was set events
279+
* @cs_id: Clocksource ID
280+
* @clock_was_set_seq: The sequence number of clock-was-set events
246281
* @cs_was_changed_seq: The sequence number of clocksource change events
247282
*/
248283
struct system_time_snapshot {

include/linux/timer.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn)
2323
#endif
2424

25-
/**
25+
/*
2626
* @TIMER_DEFERRABLE: A deferrable timer will work normally when the
2727
* system is busy, but will not cause a CPU to come out of idle just
2828
* to service it; instead, the timer will be serviced when the CPU
@@ -140,7 +140,7 @@ static inline void destroy_timer_on_stack(struct timer_list *timer) { }
140140
* or not. Callers must ensure serialization wrt. other operations done
141141
* to this timer, eg. interrupt contexts, or other CPUs on SMP.
142142
*
143-
* return value: 1 if the timer is pending, 0 if not.
143+
* Returns: 1 if the timer is pending, 0 if not.
144144
*/
145145
static inline int timer_pending(const struct timer_list * timer)
146146
{
@@ -175,6 +175,10 @@ extern int timer_shutdown(struct timer_list *timer);
175175
* See timer_delete_sync() for detailed explanation.
176176
*
177177
* Do not use in new code. Use timer_delete_sync() instead.
178+
*
179+
* Returns:
180+
* * %0 - The timer was not pending
181+
* * %1 - The timer was pending and deactivated
178182
*/
179183
static inline int del_timer_sync(struct timer_list *timer)
180184
{
@@ -188,6 +192,10 @@ static inline int del_timer_sync(struct timer_list *timer)
188192
* See timer_delete() for detailed explanation.
189193
*
190194
* Do not use in new code. Use timer_delete() instead.
195+
*
196+
* Returns:
197+
* * %0 - The timer was not pending
198+
* * %1 - The timer was pending and deactivated
191199
*/
192200
static inline int del_timer(struct timer_list *timer)
193201
{

include/vdso/datapage.h

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

22-
#ifdef CONFIG_ARM64
23-
#include <asm/page-def.h>
24-
#else
25-
#include <asm/page.h>
26-
#endif
27-
2822
#ifdef CONFIG_ARCH_HAS_VDSO_DATA
2923
#include <asm/vdso/data.h>
3024
#else
@@ -132,7 +126,7 @@ extern struct vdso_data _timens_data[CS_BASES] __attribute__((visibility("hidden
132126
*/
133127
union vdso_data_store {
134128
struct vdso_data data[CS_BASES];
135-
u8 page[PAGE_SIZE];
129+
u8 page[1U << CONFIG_PAGE_SHIFT];
136130
};
137131

138132
/*

kernel/time/tick-sched.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ bool tick_nohz_tick_stopped_cpu(int cpu)
697697

698698
/**
699699
* tick_nohz_update_jiffies - update jiffies when idle was interrupted
700+
* @now: current ktime_t
700701
*
701702
* Called from interrupt entry when the CPU was idle
702703
*
@@ -794,7 +795,7 @@ static u64 get_cpu_sleep_time_us(struct tick_sched *ts, ktime_t *sleeptime,
794795
* This time is measured via accounting rather than sampling,
795796
* and is as accurate as ktime_get() is.
796797
*
797-
* This function returns -1 if NOHZ is not enabled.
798+
* Return: -1 if NOHZ is not enabled, else total idle time of the @cpu
798799
*/
799800
u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time)
800801
{
@@ -820,7 +821,7 @@ EXPORT_SYMBOL_GPL(get_cpu_idle_time_us);
820821
* This time is measured via accounting rather than sampling,
821822
* and is as accurate as ktime_get() is.
822823
*
823-
* This function returns -1 if NOHZ is not enabled.
824+
* Return: -1 if NOHZ is not enabled, else total iowait time of @cpu
824825
*/
825826
u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time)
826827
{
@@ -1287,6 +1288,8 @@ void tick_nohz_irq_exit(void)
12871288

12881289
/**
12891290
* tick_nohz_idle_got_tick - Check whether or not the tick handler has run
1291+
*
1292+
* Return: %true if the tick handler has run, otherwise %false
12901293
*/
12911294
bool tick_nohz_idle_got_tick(void)
12921295
{
@@ -1305,6 +1308,8 @@ bool tick_nohz_idle_got_tick(void)
13051308
* stopped, it returns the next hrtimer.
13061309
*
13071310
* Called from power state control code with interrupts disabled
1311+
*
1312+
* Return: the next expiration time
13081313
*/
13091314
ktime_t tick_nohz_get_next_hrtimer(void)
13101315
{
@@ -1320,6 +1325,8 @@ ktime_t tick_nohz_get_next_hrtimer(void)
13201325
* The return value of this function and/or the value returned by it through the
13211326
* @delta_next pointer can be negative which must be taken into account by its
13221327
* callers.
1328+
*
1329+
* Return: the expected length of the current sleep
13231330
*/
13241331
ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next)
13251332
{
@@ -1357,8 +1364,11 @@ ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next)
13571364
/**
13581365
* tick_nohz_get_idle_calls_cpu - return the current idle calls counter value
13591366
* for a particular CPU.
1367+
* @cpu: target CPU number
13601368
*
13611369
* Called from the schedutil frequency scaling governor in scheduler context.
1370+
*
1371+
* Return: the current idle calls counter value for @cpu
13621372
*/
13631373
unsigned long tick_nohz_get_idle_calls_cpu(int cpu)
13641374
{
@@ -1371,6 +1381,8 @@ unsigned long tick_nohz_get_idle_calls_cpu(int cpu)
13711381
* tick_nohz_get_idle_calls - return the current idle calls counter value
13721382
*
13731383
* Called from the schedutil frequency scaling governor in scheduler context.
1384+
*
1385+
* Return: the current idle calls counter value for the current CPU
13741386
*/
13751387
unsigned long tick_nohz_get_idle_calls(void)
13761388
{
@@ -1559,7 +1571,7 @@ early_param("skew_tick", skew_tick);
15591571

15601572
/**
15611573
* tick_setup_sched_timer - setup the tick emulation timer
1562-
* @mode: tick_nohz_mode to setup for
1574+
* @hrtimer: whether to use the hrtimer or not
15631575
*/
15641576
void tick_setup_sched_timer(bool hrtimer)
15651577
{

kernel/time/tick-sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ struct tick_device {
4646
* @next_tick: Next tick to be fired when in dynticks mode.
4747
* @idle_jiffies: jiffies at the entry to idle for idle time accounting
4848
* @idle_waketime: Time when the idle was interrupted
49+
* @idle_sleeptime_seq: sequence counter for data consistency
4950
* @idle_entrytime: Time when the idle call was entered
50-
* @nohz_mode: Mode - one state of tick_nohz_mode
5151
* @last_jiffies: Base jiffies snapshot when next event was last computed
5252
* @timer_expires_base: Base time clock monotonic for @timer_expires
5353
* @timer_expires: Anticipated timer expiration time (in case sched tick is stopped)

0 commit comments

Comments
 (0)