lkml.org 
[lkml]   [2022]   [Sep]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH V3] firmware: google: Test spinlock on panic path to avoid lockups
On Thu, Sep 01, 2022 at 12:59:36PM -0300, Guilherme G. Piccoli wrote:
> + Petr, since this was extensively discussed in the original thread [0]
> and maybe he can help with the argument.
>
> [0]
> https://lore.kernel.org/lkml/20220427224924.592546-1-gpiccoli@igalia.com/
>
>
> On 01/09/2022 12:52, Greg KH wrote:
> > [...]
>
> >> + * Perform the lock check before effectively trying
> >> + * to acquire it on gsmi_shutdown_reason() to avoid
> >> + * potential lockups in atomic context.
> >> + */
> >> + if (spin_is_locked(&gsmi_dev.lock))
> >> + return NOTIFY_DONE;
> >> +
> >
> > What happens if the lock is grabbed right after testing for it?
> > Shouldn't you use lockdep_assert_held() instead as the documentation
> > says to?
>
> How, if in this point only a single CPU (this one, executing the code)
> is running?

How are we supposed to know this here?

> Remember this is the panic path - before this point we disabled all
> other CPUs, except this one executing the code. So, either the lock was
> taken (and we bail), or it wasn't and it's safe to continue.

Then who else could have taken the lock? And if all other CPUs are
stopped, who cares about the lock at all? Just don't grab it (you
should check for that when you want to grab it) and then you can work
properly at that point in time.

thanks,

greg k-h

\
 
 \ /
  Last update: 2022-09-01 18:05    [W:1.035 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site