Re: [PATCH] locking: Revert switching guards to _irq_{disable,enable}()
From: Peter Zijlstra
Date: Fri Aug 28 2026 - 02:45:26 EST
On Fri, Aug 28, 2026 at 12:52:26AM +0200, Thomas Gleixner wrote:
> --- a/include/linux/irq-entry-common.h
> +++ b/include/linux/irq-entry-common.h
> @@ -97,6 +97,7 @@ static __always_inline bool arch_in_rcu_
> */
> static __always_inline void enter_from_user_mode(struct pt_regs *regs)
> {
> + __preempt_count_inc_hardirqs_disable();
> arch_enter_from_user_mode(regs);
> lockdep_hardirqs_off(CALLER_ADDR0);
>
> @@ -275,6 +276,7 @@ static __always_inline void exit_to_user
> user_enter_irqoff();
> arch_exit_to_user_mode();
> lockdep_hardirqs_on(CALLER_ADDR0);
> + __preempt_count_dec_hardirqs_disable();
> }
>
> /**
> @@ -385,6 +387,8 @@ static __always_inline irqentry_state_t
> .exit_rcu = false,
> };
>
> + __preempt_count_inc_hardirqs_disable();
> +
> /*
> * If this entry hit the idle task invoke ct_irq_enter() whether
> * RCU is watching or not.
> @@ -498,6 +502,7 @@ irqentry_exit_to_kernel_mode_after_preem
> instrumentation_end();
> ct_irq_exit();
> lockdep_hardirqs_on(CALLER_ADDR0);
> + __preempt_count_dec_hardirqs_disable();
> return;
> }
>
> @@ -514,6 +519,7 @@ irqentry_exit_to_kernel_mode_after_preem
> if (state.exit_rcu)
> ct_irq_exit();
> }
> + __preempt_count_dec_hardirqs_disable();
> }
>
> /**
> --- a/kernel/entry/common.c
> +++ b/kernel/entry/common.c
> @@ -171,6 +171,7 @@ irqentry_state_t noinstr irqentry_nmi_en
> {
> irqentry_state_t irq_state;
>
> + __preempt_count_inc_hardirqs_disable();
> irq_state.lockdep = lockdep_hardirqs_enabled();
>
> __nmi_enter();
> @@ -202,4 +203,5 @@ void noinstr irqentry_nmi_exit(struct pt
> if (irq_state.lockdep)
> lockdep_hardirqs_on(CALLER_ADDR0);
> __nmi_exit();
> + __preempt_count_dec_hardirqs_disable();
> }
So I was thinking about this, and can't we get away with not doing this?
That is, simply leave DISABLED_OFFSET set while in userspace?
We always exit to userspace with IRQs disabled, and every entry will
disable them anyway, so they match up, might as well make use of that,
no?