summaryrefslogtreecommitdiff
path: root/kernel/time
diff options
context:
space:
mode:
authorHui Su <sh_def@163.com>2026-10-16 10:09:43 +0900
committerThomas Gleixner <tglx@kernel.org>2026-10-25 22:43:19 +0100
commit064bcd117e8a1a266bb92b840f63862999b7cb87 (patch)
tree307d72210e27990b7295bc570c34819b5681f75d /kernel/time
parent6541fbc942f3b63bb8bd44e34eee6223e0abe719 (diff)
hrtimer: Add cleanup class for on-stack timers
hrtimer_setup_on_stack() requires callers to destroy the timer before its backing stack storage goes out of scope, but the setup interface does not encode the required teardown pairing. Add an hrtimer_on_stack cleanup class that pairs on-stack setup with destroy_hrtimer_on_stack(). Document the existing setup API's lifetime requirement. The cleanup class provides debug-object teardown, not timer cancellation. Callers must ensure that no hrtimer operation can still access the timer before the scope ends; in particular, the timer must no longer be queued and any running callback must have completed. Signed-off-by: Hui Su <sh_def@163.com> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Link: https://patch.msgid.link/5f48c32490d19f51035e4209174f9cfe44472c71.1792083743.git.sh_def@163.com
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/hrtimer.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index cbf1693c86b3..12e136d5691f 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1975,8 +1975,12 @@ EXPORT_SYMBOL_GPL(hrtimer_setup);
* @clock_id: The clock to be used
* @mode: The timer mode
*
- * Similar to hrtimer_setup(), except that this one must be used if struct hrtimer is in stack
- * memory.
+ * Similar to hrtimer_setup(), except that this one must be used if struct
+ * hrtimer is in stack memory.
+ *
+ * Callers that do not use the hrtimer_on_stack cleanup class must call
+ * destroy_hrtimer_on_stack() before the stack storage goes out of scope. The
+ * cleanup class pairs setup and destruction automatically.
*/
void hrtimer_setup_on_stack(struct hrtimer *timer,
enum hrtimer_restart (*function)(struct hrtimer *),