Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6f333ef

Browse files
authoredMar 27, 2025··
Merge pull request #1568 from hodgesds/p2dq-vtime-fixes
scx_p2dq Add scaled vtime to accounting
2 parents e91c871 + 0bd9ae9 commit 6f333ef

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
 

‎scheds/rust/scx_p2dq/src/bpf/main.bpf.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ void BPF_STRUCT_OPS(p2dq_stopping, struct task_struct *p, bool runnable)
739739
struct task_ctx *taskc;
740740
struct cpu_ctx *cpuc;
741741
struct llc_ctx *llcx;
742-
u64 used, last_dsq_slice_ns;
742+
u64 used, scaled_used, last_dsq_slice_ns;
743743
u64 now = scx_bpf_now();
744744

745745
if (!(taskc = lookup_task_ctx(p)))
@@ -759,12 +759,13 @@ void BPF_STRUCT_OPS(p2dq_stopping, struct task_struct *p, bool runnable)
759759
}
760760

761761
used = now - taskc->last_run_at;
762-
p->scx.dsq_vtime += scale_by_task_weight_inverse(p, used);
762+
scaled_used = scale_by_task_weight_inverse(p, used);
763+
p->scx.dsq_vtime += scaled_used;
763764
taskc->last_dsq_id = taskc->dsq_id;
764765
taskc->last_dsq_index = dsq_index;
765-
__sync_fetch_and_add(&llcx->vtime, used);
766-
__sync_fetch_and_add(&llcx->dsq_max_vtime[dsq_index], used);
767-
__sync_fetch_and_add(&llcx->dsq_load[dsq_index], used);
766+
__sync_fetch_and_add(&llcx->vtime, scaled_used);
767+
__sync_fetch_and_add(&llcx->dsq_max_vtime[dsq_index], scaled_used);
768+
__sync_fetch_and_add(&llcx->dsq_load[dsq_index], scaled_used);
768769

769770
// On stopping determine if the task can move to a longer DSQ by
770771
// comparing the used time to the scaled DSQ slice.

0 commit comments

Comments
 (0)
Please sign in to comment.