Skip to main content

Module deferred_work

Module deferred_work 

Source
Expand description

Deferred work queue — softirq-equivalent for Strat9-OS.

Moves heavy tick processing out of the hardirq handler into safe execution contexts (post-switch, idle loop, syscall return).

§Design

Each CPU has a lock-free AtomicU32 bitmask of pending work items. The hardirq timer handler calls raise_deferred_work() which sets bits atomically — no locks, no allocation, O(1) cost.

Processing happens at safe points where IRQs may be re-enabled and scheduler locks can be acquired without deadlock:

  • finish_switch() — after cooperative context switch completes
  • finish_interrupt_switch() — after interrupt-driven switch completes
  • idle_task_main() — idle loop before HLT
  • maybe_preempt() — at preemption entry (for work raised during IRQ)

§What stays in hardirq

  • TICK_COUNT, CPU_TOTAL_TICKS, CPU_LOCAL_TICKS increments (lock-free)
  • FORCE_RESCHED_HINT setting (lock-free)
  • speaker_tick, n3_watchdog_tick (minimal)
  • EOI (must be immediate)

§What moves to deferred

  • tick_all_timers() — interval timer processing
  • check_wake_deadlines() — deadline-based wakeups
  • Per-task Fair class accounting (runnable_len, tick_update_wait)

Structs§

DeferredWorkCpu 🔒
Per-CPU deferred work state.
DeferredWorkMetrics
Snapshot of deferred work metrics across all CPUs.

Enums§

DeferredWork
Work item types that can be deferred from hardirq context.

Statics§

DEFERRED_WORK 🔒
Per-CPU deferred work queues.

Functions§

has_pending
Check if there is pending deferred work on the current CPU.
metrics_snapshot
Take a snapshot of deferred work metrics.
process_deferred_work
Process deferred work items for the current CPU.
process_per_task_accounting 🔒
Process per-task Fair class accounting for the current CPU.
raise_deferred_work
Raise deferred work items for the current CPU.
raise_tick_deferred_work
Raise all tick-related deferred work items for the current CPU.
reset_metrics
Reset deferred work metrics.