Improvements and fixes on SpinLockIrq patch series
Subsystems (5)
Boqun Feng
reviewerv2 cover Improvements and fixes on SpinLockIrq patch series
Hi Peter,
I realized that v1 [1] was left on the list so I just want to respin it. Just to refresh the memory, v1 was requested [2] as separate patches for changes between v4 and v5 in the main series. I also include the refcount_interrupt kunit test Kconfig change in this version as well. Based on v7.3-rc5.
Please take a look. Thanks!
[1]: https://lore.kernel.org/rust-for-linux/[email protected]/
[2]: https://lore.kernel.org/rust-for-linux/[email protected]/
Regards,
Boqun
Boqun Feng (4):
irq: Add {over,under}flow detection for
local_interrupt_{enable,disable} selftests/bpf: Use the new NMI_BITS definition
irq: Explain better on NMI_MASK overflow condition
irq: Add max local_interrupt_disable() nesting level kunit test case
Kuan-Wei Chiu (1):
irq: Make refcount_interrupt kunit test selectable
include/linux/hardirq.h | 2 +- include/linux/interrupt_rc.h | 13 +++++++++++ kernel/irq/Kconfig | 12 ++++++++++ kernel/irq/Makefile | 2 +- kernel/irq/refcount_interrupt_test.c | 22 +++++++++++++++++++ .../testing/selftests/bpf/bpf_experimental.h | 2 +- 6 files changed, 50 insertions(+), 3 deletions(-)
Signature · 1 line
2.51.0
Boqun Feng
reviewerPATCH v2 1/5 irq: Make refcount_interrupt kunit test selectable
From: Kuan-Wei Chiu <[email protected]>
Currently, refcount_interrupt_test is built unconditionally when CONFIG_KUNIT is enabled, causing it to run unexpectedly during boot.
Fix this by introducing CONFIG_REFCOUNT_INTERRUPT_KUNIT_TEST so the test can be configured independently, following standard kunit practices.
--- kernel/irq/Kconfig | 12 ++++++++++++ kernel/irq/Makefile | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-)
kernel/irq/Kconfig +12 -0
@@ -150,6 +150,18 @@ config IRQ_KUNIT_TEST If unsure, say N. +config REFCOUNT_INTERRUPT_KUNIT_TEST + tristate "Test refcounted interrupt enable/disable" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + This builds the kunit tests for the refcounted interrupt + infrastructure. It verifies the correctness of single, nested, + and multiple interrupt enable/disable state changes and ensures + that the underlying reference counting mechanisms work as expected. + + If unsure, say N. + endmenu config GENERIC_IRQ_MULTI_HANDLER
kernel/irq/Makefile +1 -1
@@ -16,4 +16,4 @@ obj-$(CONFIG_SMP) += affinity.o obj-$(CONFIG_GENERIC_IRQ_DEBUGFS) += debugfs.o obj-$(CONFIG_GENERIC_IRQ_MATRIX_ALLOCATOR) += matrix.o obj-$(CONFIG_IRQ_KUNIT_TEST) += irq_test.o -obj-$(CONFIG_KUNIT) += refcount_interrupt_test.o +obj-$(CONFIG_REFCOUNT_INTERRUPT_KUNIT_TEST) += refcount_interrupt_test.o
Signature · 1 line
2.51.0
[tip: locking/urgent] irq: Make refcount_interrupt kunit test selectable
The following commit has been merged into the locking/urgent branch of tip:
The following commit has been merged into the locking/urgent branch of tip:
Commit-ID: 26f6b6357b1b06e6aaa9b8d796989cca785d8e1d Gitweb: https://git.kernel.org/tip/26f6b6357b1b06e6aaa9b8d796989cca785d8e1d Author: Kuan-Wei Chiu <[email protected]> AuthorDate: Thu, 01 Oct 2026 10:25:15 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 02 Oct 2026 11:40:12 +02:00
irq: Make refcount_interrupt kunit test selectable
Currently, refcount_interrupt_test is built unconditionally when CONFIG_KUNIT is enabled, causing it to run unexpectedly during boot.
Fix this by introducing CONFIG_REFCOUNT_INTERRUPT_KUNIT_TEST so the test can be configured independently, following standard kunit practices.
--- kernel/irq/Kconfig | 12 ++++++++++++ kernel/irq/Makefile | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-)
kernel/irq/Kconfig +12 -0
@@ -150,6 +150,18 @@ config IRQ_KUNIT_TEST If unsure, say N. +config REFCOUNT_INTERRUPT_KUNIT_TEST + tristate "Test refcounted interrupt enable/disable" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + This builds the kunit tests for the refcounted interrupt + infrastructure. It verifies the correctness of single, nested, + and multiple interrupt enable/disable state changes and ensures + that the underlying reference counting mechanisms work as expected. + + If unsure, say N. + endmenu config GENERIC_IRQ_MULTI_HANDLER
kernel/irq/Makefile +1 -1
@@ -16,4 +16,4 @@ obj-$(CONFIG_SMP) += affinity.o obj-$(CONFIG_GENERIC_IRQ_DEBUGFS) += debugfs.o obj-$(CONFIG_GENERIC_IRQ_MATRIX_ALLOCATOR) += matrix.o obj-$(CONFIG_IRQ_KUNIT_TEST) += irq_test.o -obj-$(CONFIG_KUNIT) += refcount_interrupt_test.o +obj-$(CONFIG_REFCOUNT_INTERRUPT_KUNIT_TEST) += refcount_interrupt_test.o
Boqun Feng
reviewerPATCH v2 2/5 irq: Add {over,under}flow detection for local_interrupt_{enable,disable}
In reply to Boqun FengCurrently there is no way to detect overflow and underflow inside the HARDIRQ_DISABLE_MASK part of preempt_count. Add these detection guarded by DEBUG_PREEMPT similar to the detection for PREEMPT_MASK {over,under}flow.
--- include/linux/interrupt_rc.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/linux/interrupt_rc.h +13 -0
@@ -11,6 +11,7 @@* make it easier to include without hitting circular header dependencies. */ +#include <linux/debug_locks.h> #include <linux/irqflags.h> #include <linux/preempt.h> #include <linux/processor.h>
@@ -65,6 +66,13 @@ static inline void local_interrupt_disable(void)local_irq_save (flags); new_count =hardirq_disable_enter (); +/* Is hardirq disable count overflow soon? */ +if (IS_ENABLED (CONFIG_DEBUG_PREEMPT ) && +DEBUG_LOCKS_WARN_ON (((new_count &HARDIRQ_DISABLE_MASK ) + + (10 <<HARDIRQ_DISABLE_SHIFT )) >= +HARDIRQ_DISABLE_MASK )) +return ; +if ((new_count &HARDIRQ_DISABLE_MASK ) ==HARDIRQ_DISABLE_OFFSET )_local_interrupt_save_state (flags); }
@@ -73,6 +81,11 @@ static inline void local_interrupt_enable(void) {int new_count; +/* Unpaired local_interrupt_enable()? Warn and abort. */ +if (IS_ENABLED (CONFIG_DEBUG_PREEMPT ) && +DEBUG_LOCKS_WARN_ON ((preempt_count () &HARDIRQ_DISABLE_MASK ) ==0 )) +return ; + new_count =hardirq_disable_exit ();if ((new_count &HARDIRQ_DISABLE_MASK ) ==0 )
Signature · 1 line
2.51.0
[tip: locking/core] irq: Add {over,under}flow detection for local_interrupt_{enable,disable}
The following commit has been merged into the locking/core branch of tip:
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 9e174422f6f15a1d88994a07067f66c920d2f947 Gitweb: https://git.kernel.org/tip/9e174422f6f15a1d88994a07067f66c920d2f947 Author: Boqun Feng <[email protected]> AuthorDate: Thu, 01 Oct 2026 10:25:16 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 02 Oct 2026 11:47:13 +02:00
irq: Add {over,under}flow detection for local_interrupt_{enable,disable}
Currently there is no way to detect overflow and underflow inside the HARDIRQ_DISABLE_MASK part of preempt_count. Add these detection guarded by DEBUG_PREEMPT similar to the detection for PREEMPT_MASK {over,under}flow.
--- include/linux/interrupt_rc.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/linux/interrupt_rc.h +13 -0
@@ -11,6 +11,7 @@* make it easier to include without hitting circular header dependencies. */ +#include <linux/debug_locks.h> #include <linux/irqflags.h> #include <linux/preempt.h> #include <linux/processor.h>
@@ -65,6 +66,13 @@ static inline void local_interrupt_disable(void)local_irq_save (flags); new_count =hardirq_disable_enter (); +/* Is hardirq disable count overflow soon? */ +if (IS_ENABLED (CONFIG_DEBUG_PREEMPT ) && +DEBUG_LOCKS_WARN_ON (((new_count &HARDIRQ_DISABLE_MASK ) + + (10 <<HARDIRQ_DISABLE_SHIFT )) >= +HARDIRQ_DISABLE_MASK )) +return ; +if ((new_count &HARDIRQ_DISABLE_MASK ) ==HARDIRQ_DISABLE_OFFSET )_local_interrupt_save_state (flags); }
@@ -73,6 +81,11 @@ static inline void local_interrupt_enable(void) {int new_count; +/* Unpaired local_interrupt_enable()? Warn and abort. */ +if (IS_ENABLED (CONFIG_DEBUG_PREEMPT ) && +DEBUG_LOCKS_WARN_ON ((preempt_count () &HARDIRQ_DISABLE_MASK ) ==0 )) +return ; + new_count =hardirq_disable_exit ();if ((new_count &HARDIRQ_DISABLE_MASK ) ==0 )
Boqun Feng
reviewerPATCH v2 3/5 selftests/bpf: Use the new NMI_BITS definition
In reply to Boqun FengThe definition of NMI_BITS was out of sync after the introduction of HAS_SEPARATE_PREEMPT_RESCHED_BITS, hence adjust it.
--- tools/testing/selftests/bpf/bpf_experimental.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/bpf_experimental.h +1 -1
@@ -371,7 +371,7 @@ extern int bpf_sock_read_xattr(struct socket *sock, const char *name__str,#define SOFTIRQ_BITS 8#define HARDIRQ_DISABLE_BITS 8#define HARDIRQ_BITS 4 -#define NMI_BITS 1 +#define NMI_BITS (1 + 3*IS_ENABLED(CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS))#define PREEMPT_SHIFT 0#define SOFTIRQ_SHIFT (PREEMPT_SHIFT + PREEMPT_BITS)
Signature · 1 line
2.51.0
Boqun Feng
reviewerRe: [PATCH v2 3/5] selftests/bpf: Use the new NMI_BITS definition
tools/testing/selftests/bpf/bpf_experimental.h
Quoted 14 lines · Boqun Feng
The definition of
NMI_BITSwas out of sync after the introduction ofHAS_SEPARATE_PREEMPT_RESCHED_BITS, hence adjust it.Reported-by Shrikanth Hegde <[email protected]>Reviewed-by Shrikanth Hegde <[email protected]>Signed-off-by Boqun Feng <[email protected]>--- tools/testing/selftests/bpf/bpf_experimental.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/bpf/bpf_experimental.h +0
-0
Per sashiko's report, seems I need the following to make it work:
tools/testing/selftests/bpf/bpf_experimental.h +3 -0
@@ -367,6 +367,9 @@ extern int bpf_cgroup_read_xattr(struct cgroup *cgroup, const char *name__str, extern int bpf_sock_read_xattr(struct socket *sock, const char *name__str, struct bpf_dynptr *value_p) __weak __ksym; +extern bool CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS __kconfig __weak; +#define IS_ENABLED (cfg) (cfg) +#define PREEMPT_BITS 8#define SOFTIRQ_BITS 8#define HARDIRQ_DISABLE_BITS 8
?
[Cc Leon and Alexi]
Regards,
Boqun
Quoted 12 lines
tools/testing/selftests/bpf/bpf_experimental.h +1
-1@@ -371,7 +371,7 @@ extern int bpf_sock_read_xattr(struct socket *sock, const char *name__str,#define SOFTIRQ_BITS 8#define HARDIRQ_DISABLE_BITS 8#define HARDIRQ_BITS 4 -#define NMI_BITS 1 +#define NMI_BITS (1 + 3*IS_ENABLED(CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS))#define PREEMPT_SHIFT 0#define SOFTIRQ_SHIFT (PREEMPT_SHIFT + PREEMPT_BITS)Signature · 1 line
2.51.0
Leon Hwang
Reviewed-by Shrikanth HegdeRe: [PATCH v2 3/5] selftests/bpf: Use the new NMI_BITS definition
Quoted 11 lines · Boqun Feng
Quoted 10 lines · Boqun Feng
The definition of
NMI_BITSwas out of sync after the introduction ofHAS_SEPARATE_PREEMPT_RESCHED_BITS, hence adjust it.Reported-by Shrikanth Hegde <[email protected]>Reviewed-by Shrikanth Hegde <[email protected]>Signed-off-by Boqun Feng <[email protected]>--- tools/testing/selftests/bpf/bpf_experimental.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 6 lines
tools/testing/selftests/bpf/bpf_experimental.h
Quoted 4 lines
tools/testing/selftests/bpf/bpf_experimental.h +0
-0Per sashiko's report, seems I need the following to make it work:
Sashiko is correct.
BPF compilation context is different from kernel compilation context. It cannot directly use IS_ENABLED(CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS)) when compiling BPF objects.
tools/testing/selftests/bpf/bpf_experimental.h extern int bpf_cgroup_read_xattr(struct cgroup *cgroup, const char *name__str, · line 371
Quoted 11 lines
tools/testing/selftests/bpf/bpf_experimental.h +2
-0@@ -367,6 +367,9 @@ extern int bpf_cgroup_read_xattr(struct cgroup *cgroup, const char *name__str, extern int bpf_sock_read_xattr(struct socket *sock, const char *name__str, struct bpf_dynptr *value_p) __weak __ksym; +extern bool CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS __kconfig __weak; +#define IS_ENABLED (cfg) (cfg)
Correct.
IS_ENABLED is unnecessary here.
The below patch passed the BPF ci [1].
Quoted 8 lines
tools/testing/selftests/bpf/bpf_experimental.h +1
-0+#define PREEMPT_BITS 8#define SOFTIRQ_BITS 8#define HARDIRQ_DISABLE_BITS 8?
[Cc Leon and Alexi]
Please cc BPF list, BPF maintainers, and me when respinning.
Thanks,
Leon
Quoted 4 lines
Regards,
Boqun
---
From 4c1b9a6f6404aa25d1d300465dba4bee9a139668 Mon Sep 17 00:00:00 2001
From: Boqun Feng <[email protected]>
Date: Thu, 1 Oct 2026 10:25:17 +0200
Subject: [PATCH 1/3] selftests/bpf: Use the new NMI_BITS definition
The definition of NMI_BITS was out of sync after the introduction of HAS_SEPARATE_PREEMPT_RESCHED_BITS, hence adjust it.
--- tools/testing/selftests/bpf/bpf_experimental.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
(quoted diff) +0 -0
b/tools/testing/selftests/bpf/bpf_experimental.h
index 2893bf06ff25..b567a48f1dce 100644
tools/testing/selftests/bpf/bpf_experimental.h +0 -0
@@ -367,11 +367,13 @@ extern int bpf_cgroup_read_xattr(struct cgroup
*cgroup, const char *name__str,
extern int bpf_sock_read_xattr(struct socket *sock, const char *name__str,
struct bpf_dynptr *value_p) __weak __ksym;
+extern bool CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS __weak __kconfig; +
#define PREEMPT_BITS 8
#define SOFTIRQ_BITS 8
#define HARDIRQ_DISABLE_BITS 8
#define HARDIRQ_BITS 4
-#define NMI_BITS 1
+#define NMI_BITS (1 + 3*CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS)
#define PREEMPT_SHIFT 0
#define SOFTIRQ_SHIFT (PREEMPT_SHIFT + PREEMPT_BITS)
Signature · 1 line
2.55.0
Boqun Feng
reviewerRe: [PATCH v2 3/5] selftests/bpf: Use the new NMI_BITS definition
Quoted 40 lines · Leon Hwang
Quoted 11 lines · Boqun Feng
Quoted 10 lines · Boqun Feng
The definition of
NMI_BITSwas out of sync after the introduction ofHAS_SEPARATE_PREEMPT_RESCHED_BITS, hence adjust it.Reported-by Shrikanth Hegde <[email protected]>Reviewed-by Shrikanth Hegde <[email protected]>Signed-off-by Boqun Feng <[email protected]>--- tools/testing/selftests/bpf/bpf_experimental.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 6 lines
tools/testing/selftests/bpf/bpf_experimental.h
Quoted 4 lines
tools/testing/selftests/bpf/bpf_experimental.h +0
-0Per sashiko's report, seems I need the following to make it work:
Sashiko is correct.
BPF compilation context is different from kernel compilation context. It cannot directly use
IS_ENABLED(CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS)) when compiling BPF objects.tools/testing/selftests/bpf/bpf_experimental.h extern int bpf_cgroup_read_xattr(struct cgroup *cgroup, const char *name__str, · line 371
Quoted 11 lines
tools/testing/selftests/bpf/bpf_experimental.h +2
-0@@ -367,6 +367,9 @@ extern int bpf_cgroup_read_xattr(struct cgroup *cgroup, const char *name__str, extern int bpf_sock_read_xattr(struct socket *sock, const char *name__str, struct bpf_dynptr *value_p) __weak __ksym; +extern bool CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS __kconfig __weak; +#define IS_ENABLED (cfg) (cfg)Correct.
Quoted 6 lines
IS_ENABLEDis unnecessary here.The below patch passed the BPF ci [1].
Thanks for the testing. I know that IS_ENABLED is not unnecessary, but I put it there to make NMI_BITS definition stay the same as include/linux/preempt.h.
Quoted 11 lines
Quoted 8 lines
tools/testing/selftests/bpf/bpf_experimental.h +1
-0+#define PREEMPT_BITS 8#define SOFTIRQ_BITS 8#define HARDIRQ_DISABLE_BITS 8?
[Cc Leon and Alexi]
Please cc BPF list, BPF maintainers, and me when respinning.
Sure, will do.
Regards,
Boqun
Quoted 49 lines
Thanks,
LeonQuoted 4 lines
Regards,
Boqun---
From
4c1b9a6f6404aa25d1d300465dba4bee9a139668Mon Sep 17 00:00:00 2001
From: Boqun Feng <[email protected]>
Date: Thu, 1 Oct 2026 10:25:17 +0200
Subject: [PATCH 1/3] selftests/bpf: Use the newNMI_BITSdefinitionThe definition of
NMI_BITSwas out of sync after the introduction ofHAS_SEPARATE_PREEMPT_RESCHED_BITS, hence adjust it.Reported-by Shrikanth Hegde <[email protected]>Reviewed-by Shrikanth Hegde <[email protected]>Signed-off-by Boqun Feng <[email protected]>--- tools/testing/selftests/bpf/bpf_experimental.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)tools/testing/selftests/bpf/bpf_experimental.h +3
-1@@ -367,11 +367,13 @@ extern int bpf_cgroup_read_xattr(struct cgroup *cgroup, const char *name__str, extern int bpf_sock_read_xattr(struct socket *sock, const char *name__str, struct bpf_dynptr *value_p) __weak __ksym; +extern bool CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS __weak __kconfig; +#define PREEMPT_BITS 8#define SOFTIRQ_BITS 8#define HARDIRQ_DISABLE_BITS 8#define HARDIRQ_BITS 4 -#define NMI_BITS 1 +#define NMI_BITS (1 + 3*CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS)#define PREEMPT_SHIFT 0#define
SOFTIRQ_SHIFT(PREEMPT_SHIFT+PREEMPT_BITS)Signature · 1 line
2.55.0
Boqun Feng
reviewerPATCH v2 4/5 irq: Explain better on NMI_MASK overflow condition
In reply to Boqun FengCurrently __preempt_count_nmi_enter() uses 15 as the maximum NMI nesting level, and it's because 4 bits are used to represent the nesting level of NMI. Replace the tautological comment with a more direct mention to the 4 bits limitation to help readers understand this condition.
--- include/linux/hardirq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/hardirq.h +1 -1
@@ -108,7 +108,7 @@ DECLARE_PER_CPU(unsigned int, nmi_nesting);#define __preempt_count_nmi_enter () \ do { \ __preempt_count_add(HARDIRQ_OFFSET); \ -/* Maximum NMI nesting is 15. */ \ +/* NMI nesting is represented in 4 bits. */ \BUG_ON (__this_cpu_read (nmi_nesting) >=15 ); \__this_cpu_inc (nmi_nesting); \preempt_count_set (preempt_count () |NMI_MASK ); \
Signature · 1 line
2.51.0
[tip: locking/core] irq: Explain better on NMI_MASK overflow condition
The following commit has been merged into the locking/core branch of tip:
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 1259028ec8f2a788cf560b40efca2c1fa74da89c Gitweb: https://git.kernel.org/tip/1259028ec8f2a788cf560b40efca2c1fa74da89c Author: Boqun Feng <[email protected]> AuthorDate: Thu, 01 Oct 2026 10:25:18 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 02 Oct 2026 11:47:14 +02:00
irq: Explain better on NMI_MASK overflow condition
Currently __preempt_count_nmi_enter() uses 15 as the maximum NMI nesting level, and it's because 4 bits are used to represent the nesting level of NMI. Replace the tautological comment with a more direct mention to the 4 bits limitation to help readers understand this condition.
--- include/linux/hardirq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/hardirq.h +1 -1
@@ -108,7 +108,7 @@ DECLARE_PER_CPU(unsigned int, nmi_nesting);#define __preempt_count_nmi_enter () \ do { \ __preempt_count_add(HARDIRQ_OFFSET); \ -/* Maximum NMI nesting is 15. */ \ +/* NMI nesting is represented in 4 bits. */ \BUG_ON (__this_cpu_read (nmi_nesting) >=15 ); \__this_cpu_inc (nmi_nesting); \preempt_count_set (preempt_count () |NMI_MASK ); \
Boqun Feng
reviewerPATCH v2 5/5 irq: Add max local_interrupt_disable() nesting level kunit test case
In reply to Boqun FengTo confirm the max nesting level of local_interrupt_disable() works, a kunit test is added to the whole test suite.
Note that when DEBUG_PREEMPT=y, it'll generate a warning which is expected.
--- kernel/irq/refcount_interrupt_test.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
kernel/irq/refcount_interrupt_test.c +22 -0
@@ -52,6 +52,27 @@ static void test_multiple_irq_change(struct kunit *test)TEST_IRQ_ON (); } +static void test_max_nesting_irq_change (struct kunit *test) +{ +for (int i =0 ; i <__IRQ_MASK (HARDIRQ_DISABLE_BITS ); i++) { +local_interrupt_disable (); +TEST_IRQ_OFF (); + } + + +for (int i =0 ; i <__IRQ_MASK (HARDIRQ_DISABLE_BITS ); i++) { +TEST_IRQ_OFF (); +local_interrupt_enable (); + } + +TEST_IRQ_ON (); + +local_interrupt_disable (); +TEST_IRQ_OFF (); +local_interrupt_enable (); +TEST_IRQ_ON (); +} +static void test_irq_save (struct kunit *test) {unsigned long flags;
@@ -79,6 +100,7 @@ static struct kunit_case test_cases[] = {KUNIT_CASE (test_single_irq_change),KUNIT_CASE (test_nested_irq_change),KUNIT_CASE (test_multiple_irq_change), +KUNIT_CASE (test_max_nesting_irq_change), KUNIT_CASE(test_irq_save), {}, };
Signature · 1 line
2.51.0
[tip: locking/core] irq: Add max local_interrupt_disable() nesting level kunit test case
The following commit has been merged into the locking/core branch of tip:
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 67e0eadd862616cb22145d6117b79b79c4ae48fe Gitweb: https://git.kernel.org/tip/67e0eadd862616cb22145d6117b79b79c4ae48fe Author: Boqun Feng <[email protected]> AuthorDate: Thu, 01 Oct 2026 10:25:19 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 02 Oct 2026 11:47:14 +02:00
irq: Add max local_interrupt_disable() nesting level kunit test case
To confirm the max nesting level of local_interrupt_disable() works, a kunit test is added to the whole test suite.
Note that when DEBUG_PREEMPT=y, it'll generate a warning which is expected.
--- kernel/irq/refcount_interrupt_test.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
kernel/irq/refcount_interrupt_test.c +22 -0
@@ -52,6 +52,27 @@ static void test_multiple_irq_change(struct kunit *test)TEST_IRQ_ON (); } +static void test_max_nesting_irq_change (struct kunit *test) +{ +for (int i =0 ; i <__IRQ_MASK (HARDIRQ_DISABLE_BITS ); i++) { +local_interrupt_disable (); +TEST_IRQ_OFF (); + } + + +for (int i =0 ; i <__IRQ_MASK (HARDIRQ_DISABLE_BITS ); i++) { +TEST_IRQ_OFF (); +local_interrupt_enable (); + } + +TEST_IRQ_ON (); + +local_interrupt_disable (); +TEST_IRQ_OFF (); +local_interrupt_enable (); +TEST_IRQ_ON (); +} +static void test_irq_save (struct kunit *test) {unsigned long flags;
@@ -79,6 +100,7 @@ static struct kunit_case test_cases[] = {KUNIT_CASE (test_single_irq_change),KUNIT_CASE (test_nested_irq_change),KUNIT_CASE (test_multiple_irq_change), +KUNIT_CASE (test_max_nesting_irq_change), KUNIT_CASE(test_irq_save), {}, };
Quoted 7 lines · Boqun Feng
Hi Peter,
I realized that v1 [1] was left on the list so I just want to respin it. Just to refresh the memory, v1 was requested [2] as separate patches for changes between v4 and v5 in the main series. I also include the
refcount_interruptkunit testKconfigchange in this version as well. Based on v7.3-rc5.
The first should now be in tip/locking/urgent, while all but the BPF one are in queue/locking/core, which will be promoted to tip/locking/core after the robot had a go at it.
Boqun Feng
reviewerQuoted 9 lines · Peter Zijlstra
Quoted 7 lines · Boqun Feng
Hi Peter,
I realized that v1 [1] was left on the list so I just want to respin it. Just to refresh the memory, v1 was requested [2] as separate patches for changes between v4 and v5 in the main series. I also include the
refcount_interruptkunit testKconfigchange in this version as well. Based on v7.3-rc5.
Quoted 3 lines
The first should now be in tip/locking/urgent, while all but the BPF one are in queue/locking/core, which will be promoted to tip/locking/core after the robot had a go at it.
Thanks! I resend the bpf fix v3:
* https://lore.kernel.org/lkml/[email protected]/
Regards,
Boqun