Skip to content

Commit 4c53293

Browse files
richardcochranKAGA-KOKO
authored andcommitted
tick/sched: Split out jiffies update helper function
The logic to get the time of the last jiffies update will be needed by the timer pull model as well. Move the code into a global function in anticipation of the new caller. No functional change. Signed-off-by: Richard Cochran (linutronix GmbH) <richardcochran@gmail.com> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Link: https://lore.kernel.org/r/20240221090548.36600-17-anna-maria@linutronix.de
1 parent 89f01e1 commit 4c53293

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

kernel/time/tick-internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ static inline void tick_nohz_init(void) { }
157157
#ifdef CONFIG_NO_HZ_COMMON
158158
extern unsigned long tick_nohz_active;
159159
extern void timers_update_nohz(void);
160+
extern u64 get_jiffies_update(unsigned long *basej);
160161
# ifdef CONFIG_SMP
161162
extern struct static_key_false timers_migration_enabled;
162163
extern void fetch_next_timer_interrupt_remote(unsigned long basej, u64 basem,

kernel/time/tick-sched.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,24 @@ static inline bool local_timer_softirq_pending(void)
799799
return local_softirq_pending() & BIT(TIMER_SOFTIRQ);
800800
}
801801

802+
/*
803+
* Read jiffies and the time when jiffies were updated last
804+
*/
805+
u64 get_jiffies_update(unsigned long *basej)
806+
{
807+
unsigned long basejiff;
808+
unsigned int seq;
809+
u64 basemono;
810+
811+
do {
812+
seq = read_seqcount_begin(&jiffies_seq);
813+
basemono = last_jiffies_update;
814+
basejiff = jiffies;
815+
} while (read_seqcount_retry(&jiffies_seq, seq));
816+
*basej = basejiff;
817+
return basemono;
818+
}
819+
802820
/**
803821
* tick_nohz_next_event() - return the clock monotonic based next event
804822
* @ts: pointer to tick_sched struct
@@ -813,14 +831,8 @@ static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu)
813831
{
814832
u64 basemono, next_tick, delta, expires;
815833
unsigned long basejiff;
816-
unsigned int seq;
817834

818-
/* Read jiffies and the time when jiffies were updated last */
819-
do {
820-
seq = read_seqcount_begin(&jiffies_seq);
821-
basemono = last_jiffies_update;
822-
basejiff = jiffies;
823-
} while (read_seqcount_retry(&jiffies_seq, seq));
835+
basemono = get_jiffies_update(&basejiff);
824836
ts->last_jiffies = basejiff;
825837
ts->timer_expires_base = basemono;
826838

0 commit comments

Comments
 (0)