Re: [PATCH 07/14] x86: Use lockdep to assert IRQs are disabled/enabled
From: Peter Zijlstra
Date: Sun Oct 22 2017 - 05:20:46 EST
On Fri, Oct 20, 2017 at 02:56:04AM +0200, Frederic Weisbecker wrote:
> diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
> index 03505ff..b4f3a55 100644
> --- a/arch/x86/entry/common.c
> +++ b/arch/x86/entry/common.c
> @@ -186,7 +186,7 @@ __visible inline void prepare_exit_to_usermode(struct pt_regs *regs)
>
> addr_limit_user_check();
>
> - if (IS_ENABLED(CONFIG_PROVE_LOCKING) && WARN_ON(!irqs_disabled()))
> + if (!lockdep_assert_irqs_disabled())
> local_irq_disable();
>
> lockdep_sys_exit();
So this is the only site that ever uses the return value; and for this
you've chosen the wrong value for !CONFIG_PROVE_LOCKING (namely 1),
resulting in an unconditional CLI here for !lockdep kernels.
How about we replace that whole thing with a simple:
lockdep_assert_irqs_disabled();
And leave it at that, allowing us to remove the return value thing
entirely.
The whole if !disabled, disable logic is uber paranoid programming, but
I don't think we've ever seen that WARN trigger, and if it does (and
then burns the kernel) we at least know wtf happend.