Skip to content

sched: a wake its poster parks or exits behind runs where it was posted - #1111

Draft
Japabu wants to merge 2 commits into
mainfrom
sched-place
Draft

Japabu wants to merge 2 commits into
mainfrom
sched-place

Conversation

@Japabu

@Japabu Japabu commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Problem

SchedPass::begin drains the mailbox before the pass knows its disposition. A fair wake posted on the poster's own CPU was judged against the running task in the very pass that parks or ends that task, and was forwarded to an idle CPU: an IPI and a cold cache where a local switch a moment later was free. The same forward moves communicating pairs apart. In fs-rtt's r2 sweep on the AMD bench, a client that landed on the server's CPU had the server forwarded away (10→14, 14→8), and a pair split across the two CCXs pays about 1.9 µs per round trip (read_4k_at 16.1–16.4 µs in one LLC against 19.9–20.4 µs across).

Behaviour

  • Step 1: the opening drain holds any wake that would queue behind the running task. Each disposition then places it against the CPU as it leaves it:

    • after a park, a stop or an exit, the wake runs here;
    • before a yield, or with the task kept, it is forwarded as before.

    Only the opening drain holds.

  • Step 2: WakeCause::parks_next(cpu) names the CPU of a poster that parks next. The home CPU hands such a fair wake there inside one LLC, and the poster's park runs it. No caller sets it yet; it is the placement input for the IPC phase-2 combined call.

Checks

check revision result
cargo run -- --ci host the tree before 161fc1e1c was dropped from this branch 105 steps, exit 0
cargo test -p kernel --lib, cargo test -p kernel-sim, kernel clippy b24b37a56 exit 0 each
  • Host tests: six (park, exit and yield for step 1; same LLC, other LLC and RT for step 2), plus the simulator's turn_taking_pair over 40 seeds: no turn forwarded off its CPU.
  • Mutations: six, each turning only its own test red. The simulator test also reds without step 1.

The rebase changed nothing these checks cover, so the host CI result carries over.

Evidence and what is still owed

Risks

  • A held wake waits for the disposition within the same pass. That costs nothing measurable on the host, and the metal price is not yet read.
  • The one-LLC limit for step 2 is a one-line change if the fs-rtt sweep argues otherwise.

🤖 Generated with Claude Code

Japabu and others added 2 commits October 29, 2026 00:22
SchedPass::begin drains the mailbox before the pass knows its
disposition, so a fair wake posted on the poster's own CPU was judged
behind the running task in the very pass that parks or ends that task,
and was forwarded to an idle CPU: an IPI and a cold cache where a local
switch a moment later was free. osbench's same-CPU pingpong rows held
their placement in none of 53 T14 boots, which is what this forward
predicts; a thread started and then joined meets it at the join.

The opening drain now holds what it finds behind the running task, and
each disposition places it against the CPU as it leaves it: after a
park, a stop or an exit it runs here; before a yield or with the task
kept it is forwarded as before. Only the opening drain holds, so the
CPU's own later drains are unchanged.

WakeCause gains `parker`, the CPU whose task posted the wake and parks
next in the same call. The home CPU hands such a fair wake to that CPU
inside one LLC, where the poster's park runs it and the pair's later
wakes are local. No caller sets it yet: it is the placement input the
whole-message IPC's combined call drives in its phase 2.

The simulator's turn_taking_pair holds the first half across seeds:
both threads start on cpu0 beside an idle cpu1 with balancing off, and
no turn is forwarded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b24b37a added CpuSched::held and ::holding without entries in
tripwire_field, so a shadow mismatch inside either was reported as the
nearest field below it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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