All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 1/2] timers: Add pending timer bool in struct timer_base
@ 2021-06-10 12:59 Nicolas Saenz Julienne
  2021-06-10 12:59 ` [RFC 2/2] timers: Make sure irq_work is handled when no pending timers Nicolas Saenz Julienne
  2021-06-18 21:06 ` [RFC 1/2] timers: Add pending timer bool in struct timer_base Thomas Gleixner
  0 siblings, 2 replies; 9+ messages in thread
From: Nicolas Saenz Julienne @ 2021-06-10 12:59 UTC (permalink / raw)
  To: linux-rt-users, frederic; +Cc: tglx, mtosatti, Nicolas Saenz Julienne

We need to efficiently check whether a timer base has no pending events.
So introduce a new variable in struct timer_base to do so.

Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
---
 kernel/time/timer.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 4f7602724f9a..2d7d68296a3b 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -201,6 +201,7 @@ struct timer_base {
 #ifdef CONFIG_PREEMPT_RT
 	spinlock_t		expiry_lock;
 	atomic_t		timer_waiters;
+	bool			pending;
 #endif
 	unsigned long		clk;
 	unsigned long		next_expiry;
@@ -596,6 +597,9 @@ static void enqueue_timer(struct timer_base *base, struct timer_list *timer,
 		 */
 		base->next_expiry = bucket_expiry;
 		base->next_expiry_recalc = false;
+#ifdef CONFIG_PREEMPT_RT
+		base->pending = true;
+#endif
 		trigger_dyntick_cpu(base, timer);
 	}
 }
@@ -1598,6 +1602,9 @@ static unsigned long __next_timer_interrupt(struct timer_base *base)
 	}
 
 	base->next_expiry_recalc = false;
+#ifdef CONFIG_PREEMPT_RT
+	base->pending = (next != base->clk + NEXT_TIMER_MAX_DELTA);
+#endif
 
 	return next;
 }
@@ -1966,6 +1973,9 @@ int timers_prepare_cpu(unsigned int cpu)
 		base->clk = jiffies;
 		base->next_expiry = base->clk + NEXT_TIMER_MAX_DELTA;
 		base->is_idle = false;
+#ifdef CONFIG_PREEMPT_RT
+		base->pending = false;
+#endif
 	}
 	return 0;
 }
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-06-30 17:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10 12:59 [RFC 1/2] timers: Add pending timer bool in struct timer_base Nicolas Saenz Julienne
2021-06-10 12:59 ` [RFC 2/2] timers: Make sure irq_work is handled when no pending timers Nicolas Saenz Julienne
2021-06-18 22:47   ` Thomas Gleixner
2021-06-19  8:22     ` Thomas Gleixner
2021-06-22 13:44     ` Peter Zijlstra
2021-06-22 17:33       ` Jiri Olsa
2021-06-22 17:42         ` Jiri Olsa
2021-06-30 17:43   ` Alison Chaiken
2021-06-18 21:06 ` [RFC 1/2] timers: Add pending timer bool in struct timer_base Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.