Hi Peter, Please take a look at the v3 of refcounted interrupt disabling.
Changes since v2: - Fix NMI_OFFSET underflow issue reported by sashiko. See patch #1 (__nmi_ext()) and #10 (__preempt_count_nmi_exit()) for details: we have to replace preempt_count_sub() with preempt_count_set(). - Add WARN_ON_ONCE(in_nmi()) in local_interrupt_disable() per Peter. - Remove the use of should_resched() in local_interrupt_enable(), see patch #13. - Remove my gmail in SoB. v1: https://lore.kernel.org/rust-for-linux/[email protected]/ v2: Boqun Feng (9): preempt: Introduce HARDIRQ_DISABLE_BITS preempt: Introduce __preempt_count_{sub, add}_return() irq & spin_lock: Add counted interrupt disabling/enabling locking: Switch to _irq_{disable,enable}() variants in cleanup guards sched: Remove the unused preempt_offset parameter of __cant_sleep() sched: Avoid signed comparison of preempt_count() in __cant_migrate() preempt: Introduce HAS_SEPARATE_PREEMPT_RESCHED_BITS arm64: sched/preempt: Enable HAS_SEPARATE_PREEMPT_RESCHED_BITS irq: Optimize reschedule check in local_interrupt_enable() Heiko Carstens (1): s390/preempt: Enable HAS_SEPARATE_PREEMPT_RESCHED_BITS Joel Fernandes (1): preempt: Track NMI nesting to separate per-CPU counter Lyude Paul (2): openrisc: Include <linux/cpumask.h> in smp.h irq: Add KUnit test for refcounted interrupt enable/disable arch/arm64/Kconfig | 1 + arch/arm64/include/asm/preempt.h | 18 +++ arch/openrisc/include/asm/smp.h | 2 + arch/s390/Kconfig | 1 + arch/s390/include/asm/lowcore.h | 13 ++- arch/s390/include/asm/preempt.h | 49 ++++---- arch/x86/Kconfig | 1 + arch/x86/include/asm/preempt.h | 61 +++++++--- arch/x86/kernel/cpu/common.c | 2 +- include/asm-generic/preempt.h | 14 +++ include/linux/hardirq.h | 41 ++++++- include/linux/interrupt_rc.h | 76 ++++++++++++ include/linux/kernel.h | 4 +- include/linux/preempt.h | 35 ++++-- include/linux/spinlock.h | 49 +++++--- include/linux/spinlock_api_smp.h | 41 +++++++ include/linux/spinlock_api_up.h | 16 +++ include/linux/spinlock_rt.h | 18 +++ kernel/Kconfig.preempt | 4 + kernel/irq/Makefile | 1 + kernel/irq/refcount_interrupt_test.c | 109 ++++++++++++++++++ kernel/locking/spinlock.c | 29 +++++ kernel/sched/core.c | 18 ++- kernel/softirq.c | 22 +++- lib/locking-selftest.c | 2 +- .../testing/selftests/bpf/bpf_experimental.h | 7 +- 26 files changed, 554 insertions(+), 80 deletions(-) create mode 100644 include/linux/interrupt_rc.h create mode 100644 kernel/irq/refcount_interrupt_test.c -- 2.51.0

