-
Notifications
You must be signed in to change notification settings - Fork 7.4k
tests: kernel: interrupt: Rework nested interrupt test #23614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: kernel: interrupt: Rework nested interrupt test #23614
Conversation
All checks passed. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
Output from the reworked test:
Output from the old (very broken) test:
|
NOTE: Shippable will fail for this test until #23593 is fixed, because the new test does not lie. |
Can you put this in the test documentation via a doxygen header somewhere. |
This commit re-organises the kernel interrupt tests for consistency. In addition, it removes any references to the `irq_offload` feature, which is no longer used by this test. Signed-off-by: Stephanos Ioannidis <[email protected]>
The current nested interrupt test implementation is both buggy and fundamentally flawed because it does not trigger a higher priority interrupt from a lower priority interrupt context and relies on the system timer interrupt, which is not fully governed by the test; moreover, the current implementation does not properly validate the test results and can report success if no interrupt is triggered and serviced at all. This commit reworks this test to have the following well-defined and logical procedure: 1. [thread] Trigger IRQ 0 (lower priority) 2. [isr0] Set ISR 0 result token and trigger IRQ 1 (higher priority) 3. [isr1] Set ISR 1 result token and return 4. [isr0] Validate ISR 1 result token and return 5. [thread] Validate ISR 0 result token The reworked test scenario ensures that the interrupt nesting works properly and any abnormal conditions are detected (e.g. interrupts not triggering at all, or ISR 1 not being nested under ISR 0). Signed-off-by: Stephanos Ioannidis <[email protected]>
This commit disables the nested interrupt test for the RISC-V platform, as interrupt nesting is not supported on the current RISV-C architecture port. Furthermore, the current `trigger_irq` implementation for RISC-V is mostly incorrect and cannot be used, so there is no point in leaving that in the codebase (see zephyrproject-rtos#23593). Signed-off-by: Stephanos Ioannidis <[email protected]>
e24b12a
to
f95b550
Compare
@nashif I have added the documentation for |
Force pushing for further clean-up and adding documentation. Also, I have added an additional commit that disables nested interrupt test for the RISC-V, as that seems to be not supported by the arch port and, even if it is supported, there is no practical way to test that in software because CLINT does not support priority-based interrupt nesting/preemption (for more details, see #23593). |
@npitre @kgugala @pgielda @nategraff-sifive It would be very helpful if one of the RISC-V maintainers could comment on the removal of the (previously broken and still is) nested interrupt testing for the RISC-V architectures. |
*/ | ||
#if (defined(CONFIG_DYNAMIC_INTERRUPTS) \ | ||
&& defined(CONFIG_GEN_SW_ISR_TABLE)) | ||
#define DYNTEST 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephanosio i wonder if you could clean up this local macro define - and use directly the corresponding CONFIG_ macro defines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will address that in the PR for #23614 (comment) as well.
#define ISR1_PRIO 1 | ||
/* | ||
* For Cortex-M NVIC, unused and available IRQs are automatically detected when | ||
* when the test is run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double "when"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix that in another PR since this already got merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in #23881
* and must be specified for every supported platform. | ||
* | ||
* In terms of priority, the IRQ1 is triggered from the ISR of the IRQ0; | ||
* therefore, the priority of IRQ1 must be greater than that of the IRQ0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"greater than" is this Cortex-specific requirement or applies to all? Just asking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"greater" here means "greater in priority" and not "greater in numerical value," so it applies universally.
* For Cortex-M NVIC, unused and available IRQs are automatically detected when | ||
* when the test is run. | ||
*/ | ||
#define IRQ0_PRIO 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephanosio what is the ultimate reason that we need different priorities for Cortex-M compared to all other ARCHes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly, I just copied what it was doing before, but the "ultimate reason" would be:
zephyr/include/arch/arm/aarch32/exc.h
Line 44 in 685bf54
#define _EXCEPTION_RESERVED_PRIO 0 |
But now that I am looking at it, it might have been better to do _EXCEPTION_RESERVED_PRIO + N
here since the reserved priority offset is 1
instead of 0
if CONFIG_CPU_CORTEX_M_HAS_PROGRAMMABLE_FAULT_PRIOS
is set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might have been better to do
_EXCEPTION_RESERVED_PRIO + N
Actually, this is not necessary because z_arm_irq_priority_set
already does that:
zephyr/arch/arm/core/aarch32/irq_manage.c
Line 84 in 685bf54
prio += _IRQ_PRIO_OFFSET; |
We should be okay as long as we do not use the priority value 0; I will add a comment about this in the upcoming PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in #23881
@@ -55,19 +60,8 @@ static void trigger_irq(int irq) | |||
#endif | |||
} | |||
|
|||
#elif defined(CONFIG_RISCV) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephanosio can you make a note that for RISCv the test does not run any more and link to the respective github issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an issue about this:
#23593
As far as I can see, since this test should have never been enabled for RISC-V in the first place, I think this is really a non-issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK, I have some minor questions and comments for improvement
@stephanosio still the nested-test runs only for Cortex-M - not Cortex-R, correct?
This was already tested on ARM64. ACK. |
@ioannisg This test runs on Cortex-R (and future AArch32 Cortex-A) as well, given that the system uses GIC ( |
The current nested interrupt test implementation is both buggy and
fundamentally flawed because it does not trigger a higher priority
interrupt from a lower priority interrupt context and relies on the
system timer interrupt, which is not fully governed by the test;
moreover, the current implementation does not properly validate the
test results and can report success if no interrupt is triggered and
serviced at all.
This commit reworks this test to have the following well-defined
and logical procedure:
The reworked test scenario ensures that the interrupt nesting works
properly and any abnormal conditions are detected (e.g. interrupts not
triggering at all, or ISR 1 not being nested under ISR 0).
Signed-off-by: Stephanos Ioannidis [email protected]
Closes #23593