Re: [PATCH] sched/idle: Destroy on-stack hrtimer in play_idle_precise()
From: Peter Zijlstra
Date: Thu Oct 15 2026 - 03:08:06 EST
On Thu, Oct 15, 2026 at 11:50:28AM +0900, Hui Su wrote:
> play_idle_precise() initializes it.timer with hrtimer_setup_on_stack(),
> but does not call destroy_hrtimer_on_stack() before the stack object
> goes out of scope.
>
> With CONFIG_DEBUG_OBJECTS_TIMERS, hrtimer_setup_on_stack() registers the
> timer as an on-stack debug object. Such objects must be removed before
> leaving the function which allocated them.
>
> Call destroy_hrtimer_on_stack() after the expiry loop to balance the
> on-stack timer lifetime.
Maybe, but I'm hating on this.
For one, the hrtimer_setup_on_stack() comment doesn't mention
destroy_hrtimer_on_stack(), so how are we to know.
Secondly, we have __cleanup(), which gives us the opportunity to
actually do the right thing and create a better interface.