svn commit: r331298 - head/sys/dev/syscons

Bruce Evans brde at optusnet.com.au
Thu Mar 22 06:39:20 UTC 2018


On Wed, 21 Mar 2018, Warner Losh wrote:

> On Wed, Mar 21, 2018 at 11:53 AM, Bruce Evans <brde at optusnet.com.au> wrote:
>
>> On Wed, 21 Mar 2018, Warner Losh wrote:
>>
>> Log:
>>>  Unlock giant when calling shutdown_nice()
>>
>> This breaks the driver.  Giant is syscons' driver lock, and also the
>> interrupt handler lock for at least the atkbd keyboard driver, so vt
>> sometimes holds the lock for.
>
> OK. I got carried away. You're right. The proper fix is to unlock Giant at
> the top of kern_reboot() instead. This handles the case where we call
> shutdown_nice() with no init running and have to call kern_reboot directly.
> Otherwise it's perfectly fine to just call shutdown_nice() with Giant held
> since we just signal init from there. So I'll revert this change and make
> that other change instead.
> ...
> Good point. I think the following change is good for everything except
> calling shutdown_nice() from a fast interrupt handler with noinit running:
>
> diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
> index e5ea9644ad3f..564aecd811be 100644
> --- a/sys/kern/kern_shutdown.c
> +++ b/sys/kern/kern_shutdown.c
> @@ -366,6 +366,12 @@ kern_reboot(int howto)
> {
>        static int once = 0;
>
> +       /*
> +        * Drop Giant once and for all.
> +        */
> +       while (mtx_owned(&Giant))
> +               mtx_unlock(&Giant);
> +
> #if defined(SMP)
>        /*
>         * Bind us to the first CPU so that all shutdown code runs there.
> Some
>
> Comments?

Try putting this in vfs_mountroot_parse() and/or the second clause of
shutdown_nice() only.  The only other calls are from is from sys_reboot()
and vpanic().  sys_reboot() is either MPSAFE or not, and it should know
when it is safe to drop its Giant lock if at all.  vpanic() sets
SCHEDULER_STOPPED() to avoid seeing problems with Giant or any other
mutex.

Bruce


More information about the svn-src-head mailing list