Re: [RFC][PATCH v2 20/31] timers: usb: Use del_timer_shutdown() before freeing timer
From: Steven Rostedt
Date: Fri Oct 28 2022 - 16:40:21 EST
On Fri, 28 Oct 2022 12:59:59 -0700
Guenter Roeck <linux@xxxxxxxxxxxx> wrote:
>
> I'll test again with the following changes on top of your published
> patch series. I hope this is the current status, but I may have lost
> something.
>
> Looking into it ... deactivate_timer() doesn't do anything
> and seems wrong. Did I miss something ?
You mean debug_deactivate_timer() or debug_deactivate?
> --- a/kernel/time/timer.c
> +++ b/kernel/time/timer.c
>
> -static inline void debug_timer_deactivate(struct timer_list *timer)
> +static inline void debug_timer_deactivate(struct timer_list *timer, bool free)
> {
> - if (timer->enabled)
> - debug_object_deactivate(timer, &timer_debug_descr);
> + switch (timer->enabled) {
> + case TIMER_DEBUG_DISABLED:
DISABLE is set before an activate happens (before it is ever armed).
> + return;
> + case TIMER_DEBUG_ENABLED:
> + if (!free)
> + return;
This is called by del_timer{,_sync}() where free is false, or
del_timer_shutdown() where free is true.
We only want to deactivate when free is true.
> + timer->enabled = TIMER_DEBUG_DISABLED;
And we allow for initialization of a "freed" timer again.
> + break;
> + case TIMER_DEBUG_WORK:
This is part of the delayed_work timers, were we keep the old behavior
(del_timer() and del_timer_sync() both deactivate the timer.
> + break;
> + }
> + debug_object_deactivate(timer, &timer_debug_descr);
Here we call the debug object code to deactivate it.
> }
>
> static inline void debug_timer_assert_init(struct timer_list *timer)
> @@ -833,6 +854,7 @@ static inline void debug_init(struct timer_list *timer)
>
> static inline void debug_deactivate(struct timer_list *timer)
> {
> + debug_timer_deactivate(timer, false);
This calls the above code.
> trace_timer_cancel(timer);
> }
Or am I confused and you meant something else?
-- Steve