Re: [PATCH v6 4/6] timers: Add timer_shutdown_sync() to be called before freeing timers

From: Steven Rostedt
Date: Mon Nov 14 2022 - 08:36:02 EST


On Mon, 14 Nov 2022 01:33:25 +0100
Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:

> On Sun, Nov 13 2022 at 19:15, Steven Rostedt wrote:
> > Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> >> You surely have spent a massive amount of analysis on this!
> >>
> >> Can you please explain how you came up with the brilliant idea of asking
> >> Linus to pull this post -rc4 without a review from the timer maintainers
> >> or anyone else who understands concurrency?
> >
> > I trusted the source of this code:
> >
> > https://lore.kernel.org/all/87pmlrkgi3.ffs@tglx/
>
> Sure because uncomplied suggestions are the ultimate source of truth and
> correctness, right?

Well, I figured it covered the race conditions.

>
> I'm terribly sorry that I misled you on this, but OTOH it's pretty
> obvious that you decided to ignore:
>
> https://lore.kernel.org/all/87v8vjiaih.ffs@tglx/
>

I'm not sure what you mean by that. The idea is that once timer_shutdown()
is called, we still warn on re-arming the timer. Yeah, I did not follow
Linus's suggestion that we just use shutdown to prevent the race and let it
re-arm if it wants. That is, I did not blindly convert all del_timer_sync()
to timer_shutdown(). The script only converts it if there's an immediate
free of the object that holds the timer in the same function without any
paths to avoid it.

The final patch series
(https://lore.kernel.org/all/20221104054053.431922658@xxxxxxxxxxx/) works
to make sure that after the shutdown is called, it does not get re-armed.

-- Steve