]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
tick/sched: Split out jiffies update helper function
authorRichard Cochran (linutronix GmbH) <richardcochran@gmail.com>
Wed, 21 Feb 2024 09:05:44 +0000 (10:05 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 22 Feb 2024 16:52:32 +0000 (17:52 +0100)
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
kernel/time/tick-internal.h
kernel/time/tick-sched.c

index 8b0c28edbd090ec465e8d79e2dd210b1e255863b..ccf39befde853db695574d216eabb4d8fc31dbda 100644 (file)
@@ -157,6 +157,7 @@ static inline void tick_nohz_init(void) { }
 #ifdef CONFIG_NO_HZ_COMMON
 extern unsigned long tick_nohz_active;
 extern void timers_update_nohz(void);
+extern u64 get_jiffies_update(unsigned long *basej);
 # ifdef CONFIG_SMP
 extern struct static_key_false timers_migration_enabled;
 extern void fetch_next_timer_interrupt_remote(unsigned long basej, u64 basem,
index f6b6133802298769322fab66d22bf4981c60a6ee..417bb7f880ca06f62224dcde6ee5d900a5cf573c 100644 (file)
@@ -799,6 +799,24 @@ static inline bool local_timer_softirq_pending(void)
        return local_softirq_pending() & BIT(TIMER_SOFTIRQ);
 }
 
+/*
+ * Read jiffies and the time when jiffies were updated last
+ */
+u64 get_jiffies_update(unsigned long *basej)
+{
+       unsigned long basejiff;
+       unsigned int seq;
+       u64 basemono;
+
+       do {
+               seq = read_seqcount_begin(&jiffies_seq);
+               basemono = last_jiffies_update;
+               basejiff = jiffies;
+       } while (read_seqcount_retry(&jiffies_seq, seq));
+       *basej = basejiff;
+       return basemono;
+}
+
 /**
  * tick_nohz_next_event() - return the clock monotonic based next event
  * @ts:                pointer to tick_sched struct
@@ -813,14 +831,8 @@ static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu)
 {
        u64 basemono, next_tick, delta, expires;
        unsigned long basejiff;
-       unsigned int seq;
 
-       /* Read jiffies and the time when jiffies were updated last */
-       do {
-               seq = read_seqcount_begin(&jiffies_seq);
-               basemono = last_jiffies_update;
-               basejiff = jiffies;
-       } while (read_seqcount_retry(&jiffies_seq, seq));
+       basemono = get_jiffies_update(&basejiff);
        ts->last_jiffies = basejiff;
        ts->timer_expires_base = basemono;