mitosis: preempt on tick and check borrow fairness#3469
Open
likewhatevs wants to merge 1 commit intosched-ext:mainfrom
Open
mitosis: preempt on tick and check borrow fairness#3469likewhatevs wants to merge 1 commit intosched-ext:mainfrom
likewhatevs wants to merge 1 commit intosched-ext:mainfrom
Conversation
Add ops.tick to zero the running task's slice when this CPU's per-CPU DSQ has waiting work, or when the task is cross-cell and the native cell DSQ has waiting work. This triggers dispatch within the current tick rather than waiting for the full slice to expire, reducing latency for per-CPU DSQ tasks and reclaiming CPUs when native cell work arrives. Add borrow eligibility check in try_pick_idle_cpu: before borrowing a CPU, verify the target cell's DSQ and per-CPU DSQ have no waiting work at borrow time. Work arriving after the borrow starts is handled by tick. Add cpu_dsq_raw() and cell_llc_dsq_raw() helpers to dsq.bpf.h for contexts where BPF does not support aggregate return values from get_cpu_dsq_id() / get_cell_llc_dsq_id(). Signed-off-by: Pat Somaru <patso@likewhatevs.io>
8612914 to
790b5d8
Compare
This was referenced Mar 27, 2026
dschatzberg
requested changes
Mar 30, 2026
| target_cctx->cell, tllc)) > 0 || | ||
| scx_bpf_dsq_nr_queued(cpu_dsq_raw(cpu)) > 0) | ||
| goto no_borrow; | ||
| } |
Contributor
There was a problem hiding this comment.
This doesn't make a ton of sense to me - it seems like papering over some other bug if we're finding idle CPUs in a cell with work in its DSQ
| p->scx.slice = 0; | ||
| } | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
I think I rather make this choice at select_cpu or enqueue time rather than on a periodic tick. That being said - this just seems like a fairness change - maybe let's wait on this until we've resolved more obvious correctness issues?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
work is waiting, or when a cross-cell borrower occupies a CPU whose
native cell has queued work.
are empty — skip the borrow if the target cell needs the CPU.
return aggregates.
Together with #3468, this gets the vtime contamination test in #3467
to pass.