Skip to content

WFE performance busy wait improvement#195

Open
ShahriarAhnaf wants to merge 1 commit intorenode:masterfrom
ShahriarAhnaf:ahnaf/wfe-bug
Open

WFE performance busy wait improvement#195
ShahriarAhnaf wants to merge 1 commit intorenode:masterfrom
ShahriarAhnaf:ahnaf/wfe-bug

Conversation

@ShahriarAhnaf
Copy link
Copy Markdown
Contributor

Change for WFE performance:

  • BaseCPU: Sleep for the full remaining quantum during WFI/WFE instead of only the real-time pacing delta. sleeper.Interrupt() from OnGPIO wakes the thread early when an IRQ arrives, so host CPU usage drops from 100% to near-idle during WFE/WFI wait loops.
  • in conjunction with fixing [tlib] Arm7 WFE event register bug in Tlib renode#892

Three changes to fix WFE correctness and performance:

1. tlib: Set event register (sev_pending) on exception return in
   do_v7m_exception_exit() and do_v7m_secure_return(), per ARMv7-M ARM
   B1.4.2. Without this, firmware using WFE + ISR-sets-RAM-flag patterns
   deadlocks when the interrupt fires before the CPU reaches WFE.

2. tlib: Set event register on exception entry in do_interrupt_v7m(),
   per ARMv7-M ARM B1.4.2. Needed for nested exception scenarios.

3. tlib: Check and consume event register inline in HELPER(wfe) before
   halting. If sev_pending is set, clear it and return immediately
   instead of entering the WFI halt path.

4. BaseCPU: Sleep for the full remaining quantum during WFI/WFE instead
   of only the real-time pacing delta. sleeper.Interrupt() from OnGPIO
   wakes the thread early when an IRQ arrives, so host CPU usage drops
   from 100% to near-idle during WFE/WFI wait loops.
@ShahriarAhnaf ShahriarAhnaf changed the title Ahnaf/wfe bug WFE performance busy wait improvement Mar 28, 2026
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