[kernel,boot] Add istack option to measure timer_bh delays and calculate max interrupt stack size#2533
Conversation
This was referenced Dec 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds code to determine whether the timer_bh (bottom half timer) routine was ever delayed, such that another hardware timer interrupt occurred prior to it being scheduled to run.
Much to my surprise, it was found that timer_bh execution is sometimes delayed 20-80 ms (i.e. 2-8 timer ticks)!! The reason for this is explained below, but a longer explanation, along with solutions and possible ramifications, will be the subject of an issue to be opened separately.
The new code determines whether the timer_bh routine has been delayed longer than one tick, and displays "TIMER_BH DELAY <n>" showing the number of ticks delay.
The bottom half handlers all run on the interrupt stack, but are currently allowed to run only when the kernel wasn't already running. That is, they run only when the hardware interrupted a user task, never currently when the hardware interrupted the kernel.
With the timer_bh delay code activated and high system load a TIMER_BH DELAY message or two is displayed. This will be investigated further.
An
istackoption (tracing |= TRACE_ISTACK) was added to /bootopts, allowing the new delay code to be turned on only when wanted (providing CHECK_ISTACK is defined), otherwise the system operates normally.The idle task stack size was increased from 128 bo 160 bytes to avoid some idle stack overflow messages seen with the increased usage of printk running when idle.
Also includes more source code cleanup and rearrangement in irqtab.S and strace.c, with no changes to system operation.