@@ -739,7 +739,7 @@ void BPF_STRUCT_OPS(p2dq_stopping, struct task_struct *p, bool runnable)
739
739
struct task_ctx * taskc ;
740
740
struct cpu_ctx * cpuc ;
741
741
struct llc_ctx * llcx ;
742
- u64 used , last_dsq_slice_ns ;
742
+ u64 used , scaled_used , last_dsq_slice_ns ;
743
743
u64 now = scx_bpf_now ();
744
744
745
745
if (!(taskc = lookup_task_ctx (p )))
@@ -759,12 +759,13 @@ void BPF_STRUCT_OPS(p2dq_stopping, struct task_struct *p, bool runnable)
759
759
}
760
760
761
761
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 ;
763
764
taskc -> last_dsq_id = taskc -> dsq_id ;
764
765
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 );
768
769
769
770
// On stopping determine if the task can move to a longer DSQ by
770
771
// comparing the used time to the scaled DSQ slice.
0 commit comments