Skip to content

perf(irq): avoid unconditional scheduling on timer interrupt exit - #2574

Merged
fslongjin merged 1 commit into
DragonOS-Community:masterfrom
fslongjin:codex/irq-request-driven-reschedule
Oct 28, 2026
Merged

fslongjin merged 1 commit into
DragonOS-Community:masterfrom
fslongjin:codex/irq-request-driven-reschedule

Conversation

@fslongjin

Copy link
Copy Markdown
Member

Problem and change

The x86 interrupt exit path calls __schedule() on every APIC timer interrupt, even when NEED_SCHEDULE is clear. That repeats scheduler bookkeeping/task selection and chooses the RCU ToKernel disposition without a scheduling request.

Use NEED_SCHEDULE for every interrupt vector and remove the unused timer-vector import. The outermost-IRQ guard, softirq processing, RCU exit protocol and scheduler-side preemption checks remain in place. Fair/RT ticks, wakeups and deadline processing retain their existing reschedule-request paths. This follows Linux 6.6's request-driven IRQ-exit scheduling model.

Validation

Validated against master 2515e3c91828dc7ea6dadbf3c29aff8f0088c58b:

  • make kernel, cargo fmt --all --check, and git diff --check passed.
  • Normal 2-vCPU guest: 208 timing/scheduling, 27 fair-group and 15 cpuset test executions passed. The final production rebuild was additionally booted and reran the 208 timing/scheduling executions successfully.
  • Explicit mm_selftest,sched_selftest build: 210 test executions passed. Default production features are unchanged.
  • Unmodified control: the same 208 timing/scheduling test executions passed. These are focused suites, not full-repository coverage.
  • Independent review checked Fair/RT, idle, preemption deferral, RCU and softirq/deadline wakeup contracts.

Performance evidence and remaining uncertainty

Two fixed rounds of normal-kernel create/delete benchmarks used 20 measured creates plus 5 warm-ups per batch at concurrency 1/5/10. Across control, candidate and Linux comparison runs, all 360 measured and 90 warm-up lifecycles succeeded. Pooled measurements below use 40 measured creates per variant and concurrency; p95 is nearest-rank.

Concurrency Control median (ms) Candidate median (ms) Control p95 (ms) Candidate p95 (ms)
1 182.997 173.256 210.491 212.816
5 280.471 762.699 771.705 810.000
10 921.459 925.019 1017.931 1142.505

The concurrency-5 adverse result and concurrency-10 tail increase remain unresolved. Shared-host variation and snapshot state may influence measurements, but their contributions have not been established and do not invalidate the adverse samples. Later packet observations show initial responses crossing the existing health-probe budget and a subsequent retry interval; they do not establish whether this IRQ change caused the initial response delay.

This PR removes unnecessary scheduler entries. It does not claim an overall sandbox creation speedup, absence of performance regression, or completion of the broader performance investigation.

The x86 IRQ exit path enters __schedule for every local APIC timer
interrupt even when the scheduler has not requested a reschedule. This
repeats scheduler bookkeeping and task selection for an otherwise
continuing task, and selects the RCU ToKernel disposition unnecessarily.

Use NEED_SCHEDULE as the common scheduling predicate for all vectors.
Keep the outermost-IRQ restriction, softirq processing, RCU exit handling
and scheduler-side preemption checks unchanged. Fair/RT ticks, wakeups
and deadline processing continue to publish their existing reschedule
requests. Remove the unused APIC timer-vector import.

Validation on the same base and patch: normal 2-vCPU guest suites passed
208 timing/scheduling, 27 fair-group and 15 cpuset cases; the explicit
mm_selftest+sched_selftest configuration passed 210 cases. The unmodified
control passed the same 208 timing/scheduling cases. No test features are
enabled by this change.

End-to-end sandbox performance remains mixed. Two fixed rounds of
20 measured creates per concurrency showed pooled c1 median improving
182.997 to 173.256 ms, but c5 worsening 280.471 to 762.699 ms and c10 p95
worsening 1017.931 to 1142.505 ms. These observations do not establish the
cause of the adverse results or prove absence of performance regression;
this change does not claim to complete sandbox creation optimization.

Signed-off-by: longjin <longjin@dragonos.org>
@github-actions github-actions Bot added the test Unitest/User space test label Oct 28, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-28T22:35:43.508714Z
We couldn’t complete this review. Comment @codex review to try again.
0015e40 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fslongjin
fslongjin merged commit e2a4002 into DragonOS-Community:master Oct 28, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Unitest/User space test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant