[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220809011557.6472-1-duoming@zju.edu.cn>
Date: Tue, 9 Aug 2022 09:15:57 +0800
From: Duoming Zhou <duoming@....edu.cn>
To: tglx@...utronix.de, linux-kernel@...r.kernel.org
Cc: jstultz@...gle.com, sboyd@...nel.org, edumazet@...gle.com,
Duoming Zhou <duoming@....edu.cn>
Subject: [PATCH v2] timers: fix synchronization rules in comments of del_timer_sync
The del_timer_sync() could stop the periodic timer. The root cause
is shown below which is a part of code in del_timer_sync:
do {
ret = try_to_del_timer_sync(timer);
if (unlikely(ret < 0)) {
del_timer_wait_running(timer);
cpu_relax();
}
} while (ret < 0);
If the timer's handler is running, the try_to_del_timer_sync will
return -1. Then, it will loop until the timer is not queued and
the timer's handler is not running on any CPU.
Although the periodic timer may restart itself in timer's handler,
the del_timer_sync could also stop it.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Duoming Zhou <duoming@....edu.cn>
---
Changes in v2:
- Make commit messages clearer.
- Change the annotations about del_timer_sync.
kernel/time/timer.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 717fcb9fb14..dd623018dbc 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1375,11 +1375,11 @@ static inline void del_timer_wait_running(struct timer_list *timer) { }
* CPUs.
*
* Synchronization rules: Callers must prevent restarting of the timer,
- * otherwise this function is meaningless. It must not be called from
- * interrupt contexts unless the timer is an irqsafe one. The caller must
- * not hold locks which would prevent completion of the timer's
- * handler. The timer's handler must not call add_timer_on(). Upon exit the
- * timer is not queued and the handler is not running on any CPU.
+ * otherwise this function is meaningless. It could also stop periodic timer.
+ * It must not be called from interrupt contexts unless the timer is an irqsafe
+ * one. The caller must not hold locks which would prevent completion of the
+ * timer's handler. Upon exit the timer is not queued and the handler is not
+ * running on any CPU.
*
* Note: For !irqsafe timers, you must not hold locks that are held in
* interrupt context while calling this function. Even if the lock has
--
2.17.1
Powered by blists - more mailing lists