提交 87bdd932 编写于 作者: T Thomas Gleixner

Documentation: Replace del_timer/del_timer_sync()

Adjust to the new preferred function names.
Suggested-by: NSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Reviewed-by: NJacob Keller <jacob.e.keller@intel.com>
Reviewed-by: NAnna-Maria Behnsen <anna-maria@linutronix.de>
Link: https://lore.kernel.org/r/20221123201625.075320635@linutronix.de
上级 bb663f0f
...@@ -1858,7 +1858,7 @@ unloaded. After a given module has been unloaded, any attempt to call ...@@ -1858,7 +1858,7 @@ unloaded. After a given module has been unloaded, any attempt to call
one of its functions results in a segmentation fault. The module-unload one of its functions results in a segmentation fault. The module-unload
functions must therefore cancel any delayed calls to loadable-module functions must therefore cancel any delayed calls to loadable-module
functions, for example, any outstanding mod_timer() must be dealt functions, for example, any outstanding mod_timer() must be dealt
with via del_timer_sync() or similar. with via timer_delete_sync() or similar.
Unfortunately, there is no way to cancel an RCU callback; once you Unfortunately, there is no way to cancel an RCU callback; once you
invoke call_rcu(), the callback function is eventually going to be invoke call_rcu(), the callback function is eventually going to be
......
...@@ -191,7 +191,7 @@ Here is a sample module which implements a basic per cpu counter using ...@@ -191,7 +191,7 @@ Here is a sample module which implements a basic per cpu counter using
static void __exit test_exit(void) static void __exit test_exit(void)
{ {
del_timer_sync(&test_timer); timer_delete_sync(&test_timer);
} }
module_init(test_init); module_init(test_init);
......
...@@ -967,7 +967,7 @@ you might do the following:: ...@@ -967,7 +967,7 @@ you might do the following::
while (list) { while (list) {
struct foo *next = list->next; struct foo *next = list->next;
del_timer(&list->timer); timer_delete(&list->timer);
kfree(list); kfree(list);
list = next; list = next;
} }
...@@ -981,7 +981,7 @@ the lock after we spin_unlock_bh(), and then try to free ...@@ -981,7 +981,7 @@ the lock after we spin_unlock_bh(), and then try to free
the element (which has already been freed!). the element (which has already been freed!).
This can be avoided by checking the result of This can be avoided by checking the result of
del_timer(): if it returns 1, the timer has been deleted. timer_delete(): if it returns 1, the timer has been deleted.
If 0, it means (in this case) that it is currently running, so we can If 0, it means (in this case) that it is currently running, so we can
do:: do::
...@@ -990,7 +990,7 @@ do:: ...@@ -990,7 +990,7 @@ do::
while (list) { while (list) {
struct foo *next = list->next; struct foo *next = list->next;
if (!del_timer(&list->timer)) { if (!timer_delete(&list->timer)) {
/* Give timer a chance to delete this */ /* Give timer a chance to delete this */
spin_unlock_bh(&list_lock); spin_unlock_bh(&list_lock);
goto retry; goto retry;
...@@ -1005,8 +1005,7 @@ do:: ...@@ -1005,8 +1005,7 @@ do::
Another common problem is deleting timers which restart themselves (by Another common problem is deleting timers which restart themselves (by
calling add_timer() at the end of their timer function). calling add_timer() at the end of their timer function).
Because this is a fairly common case which is prone to races, you should Because this is a fairly common case which is prone to races, you should
use del_timer_sync() (``include/linux/timer.h``) to use timer_delete_sync() (``include/linux/timer.h``) to handle this case.
handle this case.
Locking Speed Locking Speed
============= =============
...@@ -1334,7 +1333,7 @@ lock. ...@@ -1334,7 +1333,7 @@ lock.
- kfree() - kfree()
- add_timer() and del_timer() - add_timer() and timer_delete()
Mutex API reference Mutex API reference
=================== ===================
......
...@@ -118,7 +118,7 @@ existing timer wheel code, as it is mature and well suited. Sharing code ...@@ -118,7 +118,7 @@ existing timer wheel code, as it is mature and well suited. Sharing code
was not really a win, due to the different data structures. Also, the was not really a win, due to the different data structures. Also, the
hrtimer functions now have clearer behavior and clearer names - such as hrtimer functions now have clearer behavior and clearer names - such as
hrtimer_try_to_cancel() and hrtimer_cancel() [which are roughly hrtimer_try_to_cancel() and hrtimer_cancel() [which are roughly
equivalent to del_timer() and del_timer_sync()] - so there's no direct equivalent to timer_delete() and timer_delete_sync()] - so there's no direct
1:1 mapping between them on the algorithmic level, and thus no real 1:1 mapping between them on the algorithmic level, and thus no real
potential for code sharing either. potential for code sharing either.
......
...@@ -990,7 +990,7 @@ potreste fare come segue:: ...@@ -990,7 +990,7 @@ potreste fare come segue::
while (list) { while (list) {
struct foo *next = list->next; struct foo *next = list->next;
del_timer(&list->timer); timer_delete(&list->timer);
kfree(list); kfree(list);
list = next; list = next;
} }
...@@ -1003,7 +1003,7 @@ e prenderà il *lock* solo dopo spin_unlock_bh(), e cercherà ...@@ -1003,7 +1003,7 @@ e prenderà il *lock* solo dopo spin_unlock_bh(), e cercherà
di eliminare il suo oggetto (che però è già stato eliminato). di eliminare il suo oggetto (che però è già stato eliminato).
Questo può essere evitato controllando il valore di ritorno di Questo può essere evitato controllando il valore di ritorno di
del_timer(): se ritorna 1, il temporizzatore è stato già timer_delete(): se ritorna 1, il temporizzatore è stato già
rimosso. Se 0, significa (in questo caso) che il temporizzatore è in rimosso. Se 0, significa (in questo caso) che il temporizzatore è in
esecuzione, quindi possiamo fare come segue:: esecuzione, quindi possiamo fare come segue::
...@@ -1012,7 +1012,7 @@ esecuzione, quindi possiamo fare come segue:: ...@@ -1012,7 +1012,7 @@ esecuzione, quindi possiamo fare come segue::
while (list) { while (list) {
struct foo *next = list->next; struct foo *next = list->next;
if (!del_timer(&list->timer)) { if (!timer_delete(&list->timer)) {
/* Give timer a chance to delete this */ /* Give timer a chance to delete this */
spin_unlock_bh(&list_lock); spin_unlock_bh(&list_lock);
goto retry; goto retry;
...@@ -1026,7 +1026,7 @@ esecuzione, quindi possiamo fare come segue:: ...@@ -1026,7 +1026,7 @@ esecuzione, quindi possiamo fare come segue::
Un altro problema è l'eliminazione dei temporizzatori che si riavviano Un altro problema è l'eliminazione dei temporizzatori che si riavviano
da soli (chiamando add_timer() alla fine della loro esecuzione). da soli (chiamando add_timer() alla fine della loro esecuzione).
Dato che questo è un problema abbastanza comune con una propensione Dato che questo è un problema abbastanza comune con una propensione
alle corse critiche, dovreste usare del_timer_sync() alle corse critiche, dovreste usare timer_delete_sync()
(``include/linux/timer.h``) per gestire questo caso. (``include/linux/timer.h``) per gestire questo caso.
Velocità della sincronizzazione Velocità della sincronizzazione
...@@ -1372,7 +1372,7 @@ contesto, o trattenendo un qualsiasi *lock*. ...@@ -1372,7 +1372,7 @@ contesto, o trattenendo un qualsiasi *lock*.
- kfree() - kfree()
- add_timer() e del_timer() - add_timer() e timer_delete()
Riferimento per l'API dei Mutex Riferimento per l'API dei Mutex
=============================== ===============================
......
...@@ -185,7 +185,7 @@ UP之间没有不同的行为,在你的架构的 ``local.h`` 中包括 ``asm-g ...@@ -185,7 +185,7 @@ UP之间没有不同的行为,在你的架构的 ``local.h`` 中包括 ``asm-g
static void __exit test_exit(void) static void __exit test_exit(void)
{ {
del_timer_sync(&test_timer); timer_delete_sync(&test_timer);
} }
module_init(test_init); module_init(test_init);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册