Re: [PATCH] locking: Revert switching guards to _irq_{disable,enable}()

From: Peter Zijlstra

Date: Fri Aug 28 2026 - 03:01:01 EST


On Thu, Aug 27, 2026 at 02:33:05PM -0700, Boqun Feng wrote:

> Ok, so brainstorm on the oddballs:
>
> # 1: double disable
>
> local_irq_disable();
> local_irq_disable();
> local_irq_enable();
>
> # 2: double enable
>
> local_irq_disable();
> local_irq_enable();
> local_irq_enable();
>
> I think these mean we should probably do count = 1 and count = 0 in
> irq_{enable,disable}() than count++ and count--?

Could yeah, but ideally we'd take this opportunity to finally get rid of
them. We've ran into them a number of times, and I'm sure get fixed up a
bunch at some point, but never made the push to clean them out.

As is, lockdep only counts the redundant ones. They're a stat nobody
ever looks at.

> # 3: only restore once
>
> local_irq_save(flag1);
> local_irq_save(flag2);
> local_irq_restore(flag1);
>
> # 4: keep restoring
>
> local_irq_save(flag1);
> local_irq_restore(flag1);
> local_irq_restore(flag1);
>
> these are a bit tricky, I guess we could only fix the users? But we
> should not postpone the infrastructure because of these?

Yeah, so I do have a solution for that, but it is too horrible to write
in this small margin and all that :-) Thomas will kick my ass.

Best we simply detect and clean up.