@@ -137,11 +137,6 @@ static u64 div_round_up(u64 dividend, u64 divisor)
137
137
return (dividend + divisor - 1 ) / divisor ;
138
138
}
139
139
140
- static bool vtime_before (u64 a , u64 b )
141
- {
142
- return (s64 )(a - b ) < 0 ;
143
- }
144
-
145
140
static bool cgv_node_less (struct bpf_rb_node * a , const struct bpf_rb_node * b )
146
141
{
147
142
struct cgv_node * cgc_a , * cgc_b ;
@@ -271,7 +266,7 @@ static void cgrp_cap_budget(struct cgv_node *cgv_node, struct fcg_cgrp_ctx *cgc)
271
266
*/
272
267
max_budget = (cgrp_slice_ns * nr_cpus * cgc -> hweight ) /
273
268
(2 * FCG_HWEIGHT_ONE );
274
- if (vtime_before (cvtime , cvtime_now - max_budget ))
269
+ if (time_before (cvtime , cvtime_now - max_budget ))
275
270
cvtime = cvtime_now - max_budget ;
276
271
277
272
cgv_node -> cvtime = cvtime ;
@@ -401,7 +396,7 @@ void BPF_STRUCT_OPS(fcg_enqueue, struct task_struct *p, u64 enq_flags)
401
396
* Limit the amount of budget that an idling task can accumulate
402
397
* to one slice.
403
398
*/
404
- if (vtime_before (tvtime , cgc -> tvtime_now - SCX_SLICE_DFL ))
399
+ if (time_before (tvtime , cgc -> tvtime_now - SCX_SLICE_DFL ))
405
400
tvtime = cgc -> tvtime_now - SCX_SLICE_DFL ;
406
401
407
402
scx_bpf_dsq_insert_vtime (p , cgrp -> kn -> id , SCX_SLICE_DFL ,
@@ -535,7 +530,7 @@ void BPF_STRUCT_OPS(fcg_running, struct task_struct *p)
535
530
* from multiple CPUs and thus racy. Any error should be
536
531
* contained and temporary. Let's just live with it.
537
532
*/
538
- if (vtime_before (cgc -> tvtime_now , p -> scx .dsq_vtime ))
533
+ if (time_before (cgc -> tvtime_now , p -> scx .dsq_vtime ))
539
534
cgc -> tvtime_now = p -> scx .dsq_vtime ;
540
535
}
541
536
bpf_cgroup_release (cgrp );
@@ -645,7 +640,7 @@ static bool try_pick_next_cgroup(u64 *cgidp)
645
640
cgv_node = container_of (rb_node , struct cgv_node , rb_node );
646
641
cgid = cgv_node -> cgid ;
647
642
648
- if (vtime_before (cvtime_now , cgv_node -> cvtime ))
643
+ if (time_before (cvtime_now , cgv_node -> cvtime ))
649
644
cvtime_now = cgv_node -> cvtime ;
650
645
651
646
/*
@@ -744,7 +739,7 @@ void BPF_STRUCT_OPS(fcg_dispatch, s32 cpu, struct task_struct *prev)
744
739
if (!cpuc -> cur_cgid )
745
740
goto pick_next_cgroup ;
746
741
747
- if (vtime_before (now , cpuc -> cur_at + cgrp_slice_ns )) {
742
+ if (time_before (now , cpuc -> cur_at + cgrp_slice_ns )) {
748
743
if (scx_bpf_dsq_move_to_local (cpuc -> cur_cgid )) {
749
744
stat_inc (FCG_STAT_CNS_KEEP );
750
745
return ;
@@ -920,14 +915,14 @@ void BPF_STRUCT_OPS(fcg_cgroup_move, struct task_struct *p,
920
915
struct cgroup * from , struct cgroup * to )
921
916
{
922
917
struct fcg_cgrp_ctx * from_cgc , * to_cgc ;
923
- s64 vtime_delta ;
918
+ s64 delta ;
924
919
925
920
/* find_cgrp_ctx() triggers scx_ops_error() on lookup failures */
926
921
if (!(from_cgc = find_cgrp_ctx (from )) || !(to_cgc = find_cgrp_ctx (to )))
927
922
return ;
928
923
929
- vtime_delta = p -> scx .dsq_vtime - from_cgc -> tvtime_now ;
930
- p -> scx .dsq_vtime = to_cgc -> tvtime_now + vtime_delta ;
924
+ delta = time_delta ( p -> scx .dsq_vtime , from_cgc -> tvtime_now ) ;
925
+ p -> scx .dsq_vtime = to_cgc -> tvtime_now + delta ;
931
926
}
932
927
933
928
s32 BPF_STRUCT_OPS_SLEEPABLE (fcg_init )
0 commit comments