Skip to contentSkip to conversation

irq: Make refcount_interrupt kunit test selectable

PATCH In review Kuan-Wei Chiu 4 participants 11 messages Aug 23 – Sep 28 IRQ

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

Fixes 07a88e2bcd5b ("irq: Add KUnit test for refcounted interrupt enable/disable")
---
 kernel/irq/Kconfig  | 12 ++++++++++++
 kernel/irq/Makefile |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
kernel/irq/Kconfig +12 -0
index 05cba4e16dad..6923f37eaab4 100644
@@ -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
index 44c4d6fc502a..0e5df962a149 100644
@@ -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.55.0.766.g2966f0265a-goog
reviewer
#1 lore raw
Quoted 7 lines · Kuan-Wei Chiu

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.

Quoted 6 lines
Fixes 07a88e2bcd5b ("irq: Add KUnit test for refcounted interrupt enable/disable")

---
 kernel/irq/Kconfig  | 12 ++++++++++++
 kernel/irq/Makefile |  2 +-

 2 files changed, 13 insertions(+), 1 deletion(-)

Can someone please explain me why this needs to be a separate unit test in the first place and can't be integrated into the (previously) existing unit test gated by IRQ_KUNIT_TEST?

Ironically, both the issue that this patch is trying to fix and my question were raised by sashiko here:
https://lore.kernel.org/all/[email protected]/

Quoted 33 lines
kernel/irq/Kconfig +0 -0
index 05cba4e16dad..6923f37eaab4 100644
@@ -150,6 +150,18 @@ config IRQ_KUNIT_TEST


    If unsure, say N.

kernel/irq/Kconfig +12 -0
+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 +0 -0
index 44c4d6fc502a..0e5df962a149 100644
@@ -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

kernel/irq/Makefile +1 -1
-obj-$(CONFIG_KUNIT) += refcount_interrupt_test.o
+obj-$(CONFIG_REFCOUNT_INTERRUPT_KUNIT_TEST) += refcount_interrupt_test.o
#2 lore raw
Quoted 15 lines · Radu Rendec
Quoted 7 lines · Kuan-Wei Chiu

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.

Quoted 6 lines
Fixes 07a88e2bcd5b ("irq: Add KUnit test for refcounted interrupt enable/disable")

---
 kernel/irq/Kconfig  | 12 ++++++++++++
 kernel/irq/Makefile |  2 +-

 2 files changed, 13 insertions(+), 1 deletion(-)
Quoted 4 lines

Can someone please explain me why this needs to be a separate unit test in the first place and can't be integrated into the (previously) existing unit test gated by IRQ_KUNIT_TEST?

If you look at the irq_test.c, you will find that it primarily tests the {request,disable,enable}_irq() API (i.e. allocating IRQ vectors and enabling and disabling them), which is not the same scope as local_interrupt_{disable,enable}() (i.e. operating the CPU irq disabling status), so it makes sense to have a separate test case.

But yes, I agree Kuan-Wei's fix is needed.

Regards,
Boqun

Quoted 37 lines

Ironically, both the issue that this patch is trying to fix and my question were raised by sashiko here:
https://lore.kernel.org/all/[email protected]/

Quoted 33 lines
kernel/irq/Kconfig +0 -0
index 05cba4e16dad..6923f37eaab4 100644
@@ -150,6 +150,18 @@ config IRQ_KUNIT_TEST


    If unsure, say N.

kernel/irq/Kconfig +12 -0
+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 +0 -0
index 44c4d6fc502a..0e5df962a149 100644
@@ -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

kernel/irq/Makefile +1 -1
-obj-$(CONFIG_KUNIT) += refcount_interrupt_test.o
+obj-$(CONFIG_REFCOUNT_INTERRUPT_KUNIT_TEST) += refcount_interrupt_test.o
reviewer
#3 lore raw
Quoted 21 lines · Boqun Feng
Quoted 15 lines · Radu Rendec
Quoted 7 lines · Kuan-Wei Chiu

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.

Quoted 6 lines
Fixes 07a88e2bcd5b ("irq: Add KUnit test for refcounted interrupt enable/disable")

---
 kernel/irq/Kconfig  | 12 ++++++++++++
 kernel/irq/Makefile |  2 +-

 2 files changed, 13 insertions(+), 1 deletion(-)
Quoted 4 lines

Can someone please explain me why this needs to be a separate unit test in the first place and can't be integrated into the (previously) existing unit test gated by IRQ_KUNIT_TEST?

Quoted 5 lines

If you look at the irq_test.c, you will find that it primarily tests the {request,disable,enable}_irq() API (i.e. allocating IRQ vectors and enabling and disabling them), which is not the same scope as local_interrupt_{disable,enable}() (i.e. operating the CPU irq disabling status), so it makes sense to have a separate test case.

Thanks! If we want to keep the unit tests separated/grouped by scope, then yes, it makes sense for sure. What I don't like about this is:
* The naming of the two config options is inconsistent: IRQ_KUNIT_TEST and REFCOUNT_INTERRUPT_KUNIT_TEST.
* The naming and description of the older test become misleading. The way they are formulated, I would expect them to test "everything related to IRQ" but now we have a separate option (and kunit test) dedicated to the refcount stuff.

If they must be separated/grouped by scope, I would find it much nicer and less confusing if they were called something like:
IRQ_MANAGEMENT_KUNIT_TEST and
IRQ_REFCOUNT_KUNIT_TEST,
and also the corresponding .c files were somewhat consistent with the Kconfig option names. The description of the older test would have to be updated to make it clear that it's not just "everything IRQ".

In that scenario, new kunit test(s) related to different aspects of the IRQ subsystem would get their own Kconfig option and file, and would hopefully follow the same naming pattern.

To be clear, I'm not arguing that keeping the tests separate is wrong. I'm arguing that if we do that, we should also make some adjustments to keep everything clean and tidy.

Quoted 1 line

But yes, I agree Kuan-Wei's fix is needed.

Yes, I agree, those unit tests must not be gated by KUNIT alone, so something must be done to fix it.

Quoted 37 lines
Quoted 37 lines

Ironically, both the issue that this patch is trying to fix and my question were raised by sashiko here:
https://lore.kernel.org/all/[email protected]/

Quoted 33 lines
kernel/irq/Kconfig +0 -0
index 05cba4e16dad..6923f37eaab4 100644
@@ -150,6 +150,18 @@ config IRQ_KUNIT_TEST


    If unsure, say N.

kernel/irq/Kconfig +12 -0
+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 +0 -0
index 44c4d6fc502a..0e5df962a149 100644
@@ -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

kernel/irq/Makefile +1 -1
-obj-$(CONFIG_KUNIT) += refcount_interrupt_test.o
+obj-$(CONFIG_REFCOUNT_INTERRUPT_KUNIT_TEST) += refcount_interrupt_test.o
Signature · 2 lines
Best regards,
Radu
#4 lore raw
Quoted 28 lines · Radu Rendec
Quoted 21 lines · Boqun Feng
Quoted 15 lines · Radu Rendec
Quoted 7 lines · Kuan-Wei Chiu

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.

Quoted 6 lines
Fixes 07a88e2bcd5b ("irq: Add KUnit test for refcounted interrupt enable/disable")

---
 kernel/irq/Kconfig  | 12 ++++++++++++
 kernel/irq/Makefile |  2 +-

 2 files changed, 13 insertions(+), 1 deletion(-)
Quoted 4 lines

Can someone please explain me why this needs to be a separate unit test in the first place and can't be integrated into the (previously) existing unit test gated by IRQ_KUNIT_TEST?

Quoted 5 lines

If you look at the irq_test.c, you will find that it primarily tests the {request,disable,enable}_irq() API (i.e. allocating IRQ vectors and enabling and disabling them), which is not the same scope as local_interrupt_{disable,enable}() (i.e. operating the CPU irq disabling status), so it makes sense to have a separate test case.

Quoted 9 lines

Thanks! If we want to keep the unit tests separated/grouped by scope, then yes, it makes sense for sure. What I don't like about this is:
* The naming of the two config options is inconsistent: IRQ_KUNIT_TEST and REFCOUNT_INTERRUPT_KUNIT_TEST.
* The naming and description of the older test become misleading. The way they are formulated, I would expect them to test "everything related to IRQ" but now we have a separate option (and kunit test) dedicated to the refcount stuff.

These are valid points. However, I think the "inconsistency" comes from refcount_interrupt_test.c being in kernel/irq/. IRQ management (code in kernel/irq/) and IRQ disabling/enabling are very different things to me (for example include/linux/irqflags.h is not listed in the "IRQ SUBSYSTEM" entry). IMO, refcount_interrupt_test.c should be moved into lib/tests/.

Quoted 8 lines

If they must be separated/grouped by scope, I would find it much nicer and less confusing if they were called something like:
IRQ_MANAGEMENT_KUNIT_TEST and
IRQ_REFCOUNT_KUNIT_TEST,
and also the corresponding .c files were somewhat consistent with the Kconfig option names. The description of the older test would have to be updated to make it clear that it's not just "everything IRQ".

Quoted 8 lines

In that scenario, new kunit test(s) related to different aspects of the IRQ subsystem would get their own Kconfig option and file, and would hopefully follow the same naming pattern.

To be clear, I'm not arguing that keeping the tests separate is wrong. I'm arguing that if we do that, we should also make some adjustments to keep everything clean and tidy.

Understood, and thank you for bringing it up.

So how about we keep Kuan-Wei's fix as it is and move the refcount_interrupt_test.c file into lib/tests/? It's more clean and tidy to me this way. Thoughts?

Regards,
Boqun

Quoted 46 lines
Quoted 1 line

But yes, I agree Kuan-Wei's fix is needed.

Yes, I agree, those unit tests must not be gated by KUNIT alone, so something must be done to fix it.

Quoted 37 lines
Quoted 37 lines

Ironically, both the issue that this patch is trying to fix and my question were raised by sashiko here:
https://lore.kernel.org/all/[email protected]/

Quoted 33 lines
kernel/irq/Kconfig +0 -0
index 05cba4e16dad..6923f37eaab4 100644
@@ -150,6 +150,18 @@ config IRQ_KUNIT_TEST


    If unsure, say N.

kernel/irq/Kconfig +12 -0
+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 +0 -0
index 44c4d6fc502a..0e5df962a149 100644
@@ -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

kernel/irq/Makefile +1 -1
-obj-$(CONFIG_KUNIT) += refcount_interrupt_test.o
+obj-$(CONFIG_REFCOUNT_INTERRUPT_KUNIT_TEST) += refcount_interrupt_test.o
Signature · 2 lines
Best regards,
Radu
reviewer
#5 lore raw
Quoted 39 lines · Boqun Feng
Quoted 28 lines · Radu Rendec
Quoted 21 lines · Boqun Feng
Quoted 15 lines · Radu Rendec
Quoted 7 lines · Kuan-Wei Chiu

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.

Quoted 6 lines
Fixes 07a88e2bcd5b ("irq: Add KUnit test for refcounted interrupt enable/disable")

---
 kernel/irq/Kconfig  | 12 ++++++++++++
 kernel/irq/Makefile |  2 +-

 2 files changed, 13 insertions(+), 1 deletion(-)
Quoted 4 lines

Can someone please explain me why this needs to be a separate unit test in the first place and can't be integrated into the (previously) existing unit test gated by IRQ_KUNIT_TEST?

Quoted 5 lines

If you look at the irq_test.c, you will find that it primarily tests the {request,disable,enable}_irq() API (i.e. allocating IRQ vectors and enabling and disabling them), which is not the same scope as local_interrupt_{disable,enable}() (i.e. operating the CPU irq disabling status), so it makes sense to have a separate test case.

Quoted 9 lines

Thanks! If we want to keep the unit tests separated/grouped by scope, then yes, it makes sense for sure. What I don't like about this is:
 * The naming of the two config options is inconsistent: IRQ_KUNIT_TEST and REFCOUNT_INTERRUPT_KUNIT_TEST.
 * The naming and description of the older test become misleading. The way they are formulated, I would expect them to test "everything related to IRQ" but now we have a separate option (and kunit test) dedicated to the refcount stuff.

Quoted 3 lines

These are valid points. However, I think the "inconsistency" comes from refcount_interrupt_test.c being in kernel/irq/. IRQ management (code in kernel/irq/) and IRQ disabling/enabling are very different things to me

I agree, they are different indeed, which is a good reason to keep the tests separated as you pointed out.

Quoted 2 lines

(for example include/linux/irqflags.h is not listed in the "IRQ SUBSYSTEM" entry).

It's not, and neither are a bunch of other IRQ related header files in include/linux/ (get_maintainer.pl returns just the generic linux-kernel mailing list). To me, that looks more like an omission, because it means they have no maintainer.

Quoted 2 lines

IMO, refcount_interrupt_test.c should be moved into lib/tests/.

I'm not sure about that. I looked, and and the tests in lib/tests/ are for the stuff that's implemented in lib/*.c. On the other hand, most of the IRQ refcount code is in include/linux/interrupt_rc.h, with some bits in kernel/softirq.c (e.g. the per-cpu state variable). If the IRQ refcount code hadn't consisted of mostly static inline functions, where would that code have been added? Still kernel/softirq.c? I'm thinking the corresponding unit tests belong in the same place, whatever that is. Assuming kernel/softirq.c, I would have suggested to put the unit tests in kernel/tests/, but it doesn't exist :)

Quoted 12 lines
Quoted 12 lines

If they must be separated/grouped by scope, I would find it much nicer and less confusing if they were called something like:
IRQ_MANAGEMENT_KUNIT_TEST and
IRQ_REFCOUNT_KUNIT_TEST,
and also the corresponding .c files were somewhat consistent with the Kconfig option names. The description of the older test would have to be updated to make it clear that it's not just "everything IRQ".

In that scenario, new kunit test(s) related to different aspects of the IRQ subsystem would get their own Kconfig option and file, and would hopefully follow the same naming pattern.

Quoted 6 lines
Quoted 4 lines

To be clear, I'm not arguing that keeping the tests separate is wrong. I'm arguing that if we do that, we should also make some adjustments to keep everything clean and tidy.

Understood, and thank you for bringing it up.

No problem. And thank you for not taking it the wrong way :)

Quoted 3 lines

So how about we keep Kuan-Wei's fix as it is and move the refcount_interrupt_test.c file into lib/tests/? It's more clean and tidy to me this way. Thoughts?

I'm fine with taking Kuan-Wei's patch as it is. It fixes a real problem, and the test code is already there (in kernel/irq/), it's not like the patch is putting it there. Meanwhile, we can keep discussing to find a better home for the test code and move it in a future patch. I'll send a r-b tag separately.

Quoted 44 lines
Quoted 42 lines
Quoted 1 line

But yes, I agree Kuan-Wei's fix is needed.

Yes, I agree, those unit tests must not be gated by KUNIT alone, so something must be done to fix it.

Quoted 37 lines
Quoted 37 lines

Ironically, both the issue that this patch is trying to fix and my question were raised by sashiko here:
https://lore.kernel.org/all/[email protected]/

Quoted 33 lines
kernel/irq/Kconfig +0 -0
index 05cba4e16dad..6923f37eaab4 100644
@@ -150,6 +150,18 @@ config IRQ_KUNIT_TEST


    If unsure, say N.

kernel/irq/Kconfig +12 -0
+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 +0 -0
index 44c4d6fc502a..0e5df962a149 100644
@@ -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

kernel/irq/Makefile +1 -1
-obj-$(CONFIG_KUNIT) += refcount_interrupt_test.o
+obj-$(CONFIG_REFCOUNT_INTERRUPT_KUNIT_TEST) += refcount_interrupt_test.o
Signature · 2 lines
Best regards,
Radu
#6 lore raw
Quoted 55 lines · Radu Rendec
Quoted 39 lines · Boqun Feng
Quoted 28 lines · Radu Rendec
Quoted 21 lines · Boqun Feng
Quoted 15 lines · Radu Rendec
Quoted 7 lines · Kuan-Wei Chiu

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.

Quoted 6 lines
Fixes 07a88e2bcd5b ("irq: Add KUnit test for refcounted interrupt enable/disable")

---
 kernel/irq/Kconfig  | 12 ++++++++++++
 kernel/irq/Makefile |  2 +-

 2 files changed, 13 insertions(+), 1 deletion(-)
Quoted 4 lines

Can someone please explain me why this needs to be a separate unit test in the first place and can't be integrated into the (previously) existing unit test gated by IRQ_KUNIT_TEST?

Quoted 5 lines

If you look at the irq_test.c, you will find that it primarily tests the {request,disable,enable}_irq() API (i.e. allocating IRQ vectors and enabling and disabling them), which is not the same scope as local_interrupt_{disable,enable}() (i.e. operating the CPU irq disabling status), so it makes sense to have a separate test case.

Quoted 9 lines

Thanks! If we want to keep the unit tests separated/grouped by scope, then yes, it makes sense for sure. What I don't like about this is:
 * The naming of the two config options is inconsistent: IRQ_KUNIT_TEST and REFCOUNT_INTERRUPT_KUNIT_TEST.
 * The naming and description of the older test become misleading. The way they are formulated, I would expect them to test "everything related to IRQ" but now we have a separate option (and kunit test) dedicated to the refcount stuff.

Quoted 3 lines

These are valid points. However, I think the "inconsistency" comes from refcount_interrupt_test.c being in kernel/irq/. IRQ management (code in kernel/irq/) and IRQ disabling/enabling are very different things to me

I agree, they are different indeed, which is a good reason to keep the tests separated as you pointed out.

Quoted 2 lines

(for example include/linux/irqflags.h is not listed in the "IRQ SUBSYSTEM" entry).

It's not, and neither are a bunch of other IRQ related header files in include/linux/ (get_maintainer.pl returns just the generic linux-kernel mailing list). To me, that looks more like an omission, because it means they have no maintainer.

Quoted 5 lines
Quoted 2 lines

IMO, refcount_interrupt_test.c should be moved into lib/tests/.

I'm not sure about that. I looked, and and the tests in lib/tests/ are for the stuff that's implemented in lib/*.c. On the other hand, most of

Make sense.

Quoted 4 lines

the IRQ refcount code is in include/linux/interrupt_rc.h, with some bits in kernel/softirq.c (e.g. the per-cpu state variable). If the IRQ refcount code hadn't consisted of mostly static inline functions, where would that code have been added? Still kernel/softirq.c? I'm thinking

Yeah, I think that's the place (for example,
local_interrupt_disable_state is defined here).

Quoted 3 lines

the corresponding unit tests belong in the same place, whatever that is. Assuming kernel/softirq.c, I would have suggested to put the unit tests in kernel/tests/, but it doesn't exist :)

Right, I need to check whether we have other unit tests for kernel/ and maybe start a discussion on where to put them for now and future.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

If they must be separated/grouped by scope, I would find it much nicer and less confusing if they were called something like:
IRQ_MANAGEMENT_KUNIT_TEST and
IRQ_REFCOUNT_KUNIT_TEST,
and also the corresponding .c files were somewhat consistent with the Kconfig option names. The description of the older test would have to be updated to make it clear that it's not just "everything IRQ".

In that scenario, new kunit test(s) related to different aspects of the IRQ subsystem would get their own Kconfig option and file, and would hopefully follow the same naming pattern.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

To be clear, I'm not arguing that keeping the tests separate is wrong. I'm arguing that if we do that, we should also make some adjustments to keep everything clean and tidy.

Understood, and thank you for bringing it up.

No problem. And thank you for not taking it the wrong way :)

Of course! Appreciate your input!

Quoted 10 lines
Quoted 3 lines

So how about we keep Kuan-Wei's fix as it is and move the refcount_interrupt_test.c file into lib/tests/? It's more clean and tidy to me this way. Thoughts?

I'm fine with taking Kuan-Wei's patch as it is. It fixes a real problem, and the test code is already there (in kernel/irq/), it's not like the patch is putting it there. Meanwhile, we can keep discussing to find a better home for the test code and move it in a future patch. I'll send a r-b tag separately.

Thank you!

Regards,
Boqun

Quoted 47 lines
Quoted 44 lines
Quoted 42 lines
Quoted 1 line

But yes, I agree Kuan-Wei's fix is needed.

Yes, I agree, those unit tests must not be gated by KUNIT alone, so something must be done to fix it.

Quoted 37 lines
Quoted 37 lines

Ironically, both the issue that this patch is trying to fix and my question were raised by sashiko here:
https://lore.kernel.org/all/[email protected]/

Quoted 33 lines
kernel/irq/Kconfig +0 -0
index 05cba4e16dad..6923f37eaab4 100644
@@ -150,6 +150,18 @@ config IRQ_KUNIT_TEST


    If unsure, say N.

kernel/irq/Kconfig +12 -0
+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 +0 -0
index 44c4d6fc502a..0e5df962a149 100644
@@ -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

kernel/irq/Makefile +1 -1
-obj-$(CONFIG_KUNIT) += refcount_interrupt_test.o
+obj-$(CONFIG_REFCOUNT_INTERRUPT_KUNIT_TEST) += refcount_interrupt_test.o
Signature · 2 lines
Best regards,
Radu
Reviewed-by on v1 1/1
#7 lore raw
In reply to Kuan-Wei Chiu
Quoted 7 lines · Kuan-Wei Chiu

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.

Sorry about this..

Quoted 2 lines
Fixes 07a88e2bcd5b ("irq: Add KUnit test for refcounted interrupt enable/disable")

Regards,
Boqun

Quoted 41 lines
---
 kernel/irq/Kconfig  | 12 ++++++++++++
 kernel/irq/Makefile |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
kernel/irq/Kconfig +12 -0
index 05cba4e16dad..6923f37eaab4 100644
@@ -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
index 44c4d6fc502a..0e5df962a149 100644
@@ -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.55.0.766.g2966f0265a-goog
reviewer Reviewed-by on v1 1/1
#8 lore raw
In reply to Kuan-Wei Chiu
Quoted 45 lines · Kuan-Wei Chiu

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.

Fixes 07a88e2bcd5b ("irq: Add KUnit test for refcounted interrupt enable/disable")

---
 kernel/irq/Kconfig  | 12 ++++++++++++
 kernel/irq/Makefile |  2 +-

 2 files changed, 13 insertions(+), 1 deletion(-)
kernel/irq/Kconfig +0 -0
index 05cba4e16dad..6923f37eaab4 100644
@@ -150,6 +150,18 @@ config IRQ_KUNIT_TEST


    If unsure, say N.

kernel/irq/Kconfig +12 -0
+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 +0 -0
index 44c4d6fc502a..0e5df962a149 100644
@@ -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

kernel/irq/Makefile obj-$(CONFIG_SMP) += affinity.o · line 19

Quoted 2 lines
kernel/irq/Makefile +1 -1
-obj-$(CONFIG_KUNIT) += refcount_interrupt_test.o
+obj-$(CONFIG_REFCOUNT_INTERRUPT_KUNIT_TEST) += refcount_interrupt_test.o
Reviewed-by on v1 1/1
#9 lore raw
In reply to Kuan-Wei Chiu
Quoted 53 lines · Kuan-Wei Chiu

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.

Fixes 07a88e2bcd5b ("irq: Add KUnit test for refcounted interrupt

enable/disable")

---
 kernel/irq/Kconfig  | 12 ++++++++++++
 kernel/irq/Makefile |  2 +-

 2 files changed, 13 insertions(+), 1 deletion(-)
kernel/irq/Kconfig +0 -0
index 05cba4e16dad..6923f37eaab4 100644
@@ -150,6 +150,18 @@ config IRQ_KUNIT_TEST


    If unsure, say N.

kernel/irq/Kconfig +2 -0
+config REFCOUNT_INTERRUPT_KUNIT_TEST
+	tristate "Test refcounted interrupt enable/disable" if

!KUNIT_ALL_TESTS

kernel/irq/Kconfig +5 -0
+	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,

kernel/irq/Kconfig +1 -0
+	  and multiple interrupt enable/disable state changes and

ensures

kernel/irq/Kconfig +1 -0
+	  that the underlying reference counting mechanisms work as

expected.

kernel/irq/Kconfig +3 -0
+
+	  If unsure, say N.
+

 endmenu

 config GENERIC_IRQ_MULTI_HANDLER

kernel/irq/Makefile +0 -0
index 44c4d6fc502a..0e5df962a149 100644
@@ -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

kernel/irq/Makefile +1 -1
-obj-$(CONFIG_KUNIT) += refcount_interrupt_test.o
+obj-$(CONFIG_REFCOUNT_INTERRUPT_KUNIT_TEST) +=

refcount_interrupt_test.o

#10 lore raw
In reply to Kuan-Wei Chiu
Quoted 9 lines · Kuan-Wei Chiu

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.

Fixes 07a88e2bcd5b ("irq: Add KUnit test for refcounted interrupt enable/disable")

Thomas & Peter, gentle ping on this, thank you!

If you rather let me send a PR to tip for v7.4. Please let me know.

Regards,
Boqun

Quoted 41 lines
---
 kernel/irq/Kconfig  | 12 ++++++++++++
 kernel/irq/Makefile |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
kernel/irq/Kconfig +12 -0
index 05cba4e16dad..6923f37eaab4 100644
@@ -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
index 44c4d6fc502a..0e5df962a149 100644
@@ -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.55.0.766.g2966f0265a-goog