Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

timers: Update the documentation to reflect on the new timer_shutdown() API

In order to make sure that a timer is not re-armed after it is stopped
before freeing, a new shutdown state is added to the timer code. The API
timer_shutdown_sync() and timer_shutdown() must be called before the
object that holds the timer can be freed.

Update the documentation to reflect this new workflow.

[ tglx: Updated to the new semantics and updated the zh_CN version ]

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Link: https://lore.kernel.org/r/20221110064147.712934793@goodmis.org
Link: https://lore.kernel.org/r/20221123201625.375284489@linutronix.de

authored by

Steven Rostedt (Google) and committed by
Thomas Gleixner
a31323be f571faf6

+8 -3
+1 -1
Documentation/RCU/Design/Requirements/Requirements.rst
··· 1858 1858 one of its functions results in a segmentation fault. The module-unload 1859 1859 functions must therefore cancel any delayed calls to loadable-module 1860 1860 functions, for example, any outstanding mod_timer() must be dealt 1861 - with via timer_delete_sync() or similar. 1861 + with via timer_shutdown_sync() or similar. 1862 1862 1863 1863 Unfortunately, there is no way to cancel an RCU callback; once you 1864 1864 invoke call_rcu(), the callback function is eventually going to be
+1 -1
Documentation/core-api/local_ops.rst
··· 191 191 192 192 static void __exit test_exit(void) 193 193 { 194 - timer_delete_sync(&test_timer); 194 + timer_shutdown_sync(&test_timer); 195 195 } 196 196 197 197 module_init(test_init);
+5
Documentation/kernel-hacking/locking.rst
··· 1007 1007 Because this is a fairly common case which is prone to races, you should 1008 1008 use timer_delete_sync() (``include/linux/timer.h``) to handle this case. 1009 1009 1010 + Before freeing a timer, timer_shutdown() or timer_shutdown_sync() should be 1011 + called which will keep it from being rearmed. Any subsequent attempt to 1012 + rearm the timer will be silently ignored by the core code. 1013 + 1014 + 1010 1015 Locking Speed 1011 1016 ============= 1012 1017
+1 -1
Documentation/translations/zh_CN/core-api/local_ops.rst
··· 185 185 186 186 static void __exit test_exit(void) 187 187 { 188 - timer_delete_sync(&test_timer); 188 + timer_shutdown_sync(&test_timer); 189 189 } 190 190 191 191 module_init(test_init);