Skip to content

Commit 17a1b88

Browse files
committed
hrtimer: Add bases argument to clock_was_set()
clock_was_set() unconditionaly invokes retrigger_next_event() on all online CPUs. This was necessary because that mechanism was also used for resume from suspend to idle which is not longer the case. The bases arguments allows the callers of clock_was_set() to hand in a mask which tells clock_was_set() which of the hrtimer clock bases are affected by the clock setting. This mask will be used in the next step to check whether a CPU base has timers queued on a clock base affected by the event and avoid the SMP function call if there are none. Add a @Bases argument, provide defines for the active bases masking and fixup all callsites. Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1b26779 commit 17a1b88

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

kernel/time/hrtimer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ static void hrtimer_reprogram(struct hrtimer *timer, bool reprogram)
880880
* in the tick, which obviously might be stopped, so this has to bring out
881881
* the remote CPU which might sleep in idle to get this sorted.
882882
*/
883-
void clock_was_set(void)
883+
void clock_was_set(unsigned int bases)
884884
{
885885
if (!hrtimer_hres_active() && !tick_nohz_active)
886886
goto out_timerfd;
@@ -894,7 +894,7 @@ void clock_was_set(void)
894894

895895
static void clock_was_set_work(struct work_struct *work)
896896
{
897-
clock_was_set();
897+
clock_was_set(CLOCK_SET_WALL);
898898
}
899899

900900
static DECLARE_WORK(hrtimer_work, clock_was_set_work);

kernel/time/tick-internal.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,14 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
166166
extern u64 get_next_timer_interrupt(unsigned long basej, u64 basem);
167167
void timer_clear_idle(void);
168168

169-
void clock_was_set(void);
169+
#define CLOCK_SET_WALL \
170+
(BIT(HRTIMER_BASE_REALTIME) | BIT(HRTIMER_BASE_REALTIME_SOFT) | \
171+
BIT(HRTIMER_BASE_TAI) | BIT(HRTIMER_BASE_TAI_SOFT))
172+
173+
#define CLOCK_SET_BOOT \
174+
(BIT(HRTIMER_BASE_BOOTTIME) | BIT(HRTIMER_BASE_BOOTTIME_SOFT))
175+
176+
void clock_was_set(unsigned int bases);
170177
void clock_was_set_delayed(void);
171178

172179
void hrtimers_resume_local(void);

kernel/time/timekeeping.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,8 +1323,8 @@ int do_settimeofday64(const struct timespec64 *ts)
13231323
write_seqcount_end(&tk_core.seq);
13241324
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
13251325

1326-
/* signal hrtimers about time change */
1327-
clock_was_set();
1326+
/* Signal hrtimers about time change */
1327+
clock_was_set(CLOCK_SET_WALL);
13281328

13291329
if (!ret)
13301330
audit_tk_injoffset(ts_delta);
@@ -1371,8 +1371,8 @@ static int timekeeping_inject_offset(const struct timespec64 *ts)
13711371
write_seqcount_end(&tk_core.seq);
13721372
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
13731373

1374-
/* signal hrtimers about time change */
1375-
clock_was_set();
1374+
/* Signal hrtimers about time change */
1375+
clock_was_set(CLOCK_SET_WALL);
13761376

13771377
return ret;
13781378
}
@@ -1746,8 +1746,8 @@ void timekeeping_inject_sleeptime64(const struct timespec64 *delta)
17461746
write_seqcount_end(&tk_core.seq);
17471747
raw_spin_unlock_irqrestore(&timekeeper_lock, flags);
17481748

1749-
/* signal hrtimers about time change */
1750-
clock_was_set();
1749+
/* Signal hrtimers about time change */
1750+
clock_was_set(CLOCK_SET_WALL | CLOCK_SET_BOOT);
17511751
}
17521752
#endif
17531753

@@ -2440,7 +2440,7 @@ int do_adjtimex(struct __kernel_timex *txc)
24402440
clock_set |= timekeeping_advance(TK_ADV_FREQ);
24412441

24422442
if (clock_set)
2443-
clock_was_set();
2443+
clock_was_set(CLOCK_REALTIME);
24442444

24452445
ntp_notify_cmos_timer();
24462446

0 commit comments

Comments
 (0)