aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time/timer.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <frederic@kernel.org>2020-11-13 13:13:33 +0100
committerPaul E. McKenney <paulmck@kernel.org>2021-01-06 16:24:59 -0800
commitdcd42591ebb8a25895b551a5297ea9c24414ba54 (patch)
treeeec399bc78a189494237e0e3842098b2b8591e9b /kernel/time/timer.c
parent43759fe5a137389e94ed6d4680c3c63c17273158 (diff)
downloadlinux-dcd42591ebb8a25895b551a5297ea9c24414ba54.tar.gz
timer: Add timer_curr_running()
This commit adds a timer_curr_running() function that verifies that the current code is running in the context of the specified timer's handler. Cc: Josh Triplett <josh@joshtriplett.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Lai Jiangshan <jiangshanlai@gmail.com> Cc: Joel Fernandes <joel@joelfernandes.org> Cc: Neeraj Upadhyay <neeraju@codeaurora.org> Cc: Thomas Gleixner <tglx@linutronix.de> Tested-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'kernel/time/timer.c')
-rw-r--r--kernel/time/timer.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 8dbc008f8942b8..f9b2096456e597 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1237,6 +1237,19 @@ int try_to_del_timer_sync(struct timer_list *timer)
}
EXPORT_SYMBOL(try_to_del_timer_sync);
+bool timer_curr_running(struct timer_list *timer)
+{
+ int i;
+
+ for (i = 0; i < NR_BASES; i++) {
+ struct timer_base *base = this_cpu_ptr(&timer_bases[i]);
+ if (base->running_timer == timer)
+ return true;
+ }
+
+ return false;
+}
+
#ifdef CONFIG_PREEMPT_RT
static __init void timer_base_init_expiry_lock(struct timer_base *base)
{