lkml.org 
[lkml]   [2022]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 4/6] timers: Add timer_shutdown_sync() to be called before freeing timers
On Sun, 13 Nov 2022 22:52:16 +0100
Thomas Gleixner <tglx@linutronix.de> wrote:

> On Thu, Nov 10 2022 at 01:41, Steven Rostedt wrote:
>
> $Subject: -ENOPARSE
>
> timers: Provide timer_shutdown_sync()
>
> and then have some reasonable explanation in the change log?
>
> > We are hitting a common bug were a timer is being triggered after it
> > is
>
> We are hitting? Talking in pluralis majestatis by now?

Should I say Chromebooks are hitting?

>
> > freed. This causes a corruption in the timer link list and crashes the
> > kernel. Unfortunately it is not easy to know what timer it was that was
>
> Well, that's not entirely true. debugobjects can tell you exactly what
> happens.

Only if you have it enabled when it happens, and it has too much
overhead to run in production. The full series changes debug object
timers to report an issue if there's a timer not in the shutdown state
when it is freed. This catches potential issues similar to how lockdep
can catch potential deadlocks without having to hit the deadlock.

The current debug object timers only catches it if the race condition
is hit.

>
> > freed. Looking at the code, it appears that there are several cases that
> > del_timer() is used when del_timer_sync() should have been.
> > diff --git a/kernel/time/timer.c b/kernel/time/timer.c
> > index 717fcb9fb14a..111a3550b3f2 100644
> > --- a/kernel/time/timer.c
> > +++ b/kernel/time/timer.c
> > @@ -1017,7 +1017,8 @@ __mod_timer(struct timer_list *timer, unsigned long expires, unsigned int option
> > unsigned int idx = UINT_MAX;
> > int ret = 0;
> >
> > - BUG_ON(!timer->function);
> > + if (WARN_ON_ONCE(!timer->function))
> > + return -EINVAL;
>
> Can you please make these BUG -> WARN conversions a separate patch?

OK.

>
> > +/**
> > + * timer_shutdown_sync - called before freeing the timer
>
> 1) The sentence after the dash starts with an upper case letter as all
> sentences do.
>
> 2) "called before freeing the timer" tells us what?
>
> See below.
>
> > + * @timer: The timer to be freed
> > + *
> > + * Shutdown the timer before freeing. This will return when all pending timers
> > + * have finished and it is safe to free the timer.
>
> "_ALL_ pending timers have finished?"
>
> This is about exactly _ONE_ timer, i.e. the one which is handed in via
> the @timer argument.
>
> You want to educate people to do the right thing and then you go and
> provide them uncomprehensible documentation garbage. How is that
> supposed to work?

I don't know. Other people I showed this to appeared to understand it.
But I'm all for updates.

>
> Can you please stop this frenzy and get your act together?

What the hell. I'm just trying to get this in because it's a thorn in
our side. Sorry I'm not up to par with your expectations. I'm willing
to make changes, but let's leave out the insults. This work is being
done on top of my day job.

>
> > + *
> > + * Note, after calling this, if the timer is added back to the queue
> > + * it will fail to be added and a WARNING will be triggered.
>
> There is surely a way to express this so that the average driver writer
> who does not have the background of you working on this understands this
> "note".
>
> > + *
> > + * Returns if it deactivated a pending timer or not.
>
> Please look up the kernel-doc syntax for documenting return values.
>

Will do.

-- Steve

\
 
 \ /
  Last update: 2022-11-14 01:12    [W:0.166 / U:1.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site