Skip to content

[kernel,boot] Add istack option to measure timer_bh delays and calculate max interrupt stack size#2533

Merged
ghaerr merged 2 commits intomasterfrom
istack
Dec 16, 2025
Merged

[kernel,boot] Add istack option to measure timer_bh delays and calculate max interrupt stack size#2533
ghaerr merged 2 commits intomasterfrom
istack

Conversation

@ghaerr
Copy link
Copy Markdown
Owner

@ghaerr ghaerr commented Dec 16, 2025

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 istack option (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.

@ghaerr ghaerr merged commit 707a226 into master Dec 16, 2025
2 checks passed
@ghaerr ghaerr deleted the istack branch December 16, 2025 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant