@@ -118,7 +118,6 @@ static inline struct cgroup *task_cgroup(struct task_struct *p)
118118 return cgrp ;
119119}
120120
121-
122121struct {
123122 __uint (type , BPF_MAP_TYPE_TASK_STORAGE );
124123 __uint (map_flags , BPF_F_NO_PREALLOC );
@@ -347,8 +346,6 @@ static inline int update_task_cpumask(struct task_struct *p,
347346
348347 /* --- Point to the correct (cell,L3) DSQ and set vtime baseline --- */
349348 tctx -> dsq = get_cell_l3_dsq_id (tctx -> cell , tctx -> l3 );
350- if (tctx -> dsq == DSQ_ERROR )
351- return - EINVAL ;
352349
353350 struct cell * cell = lookup_cell (tctx -> cell );
354351 if (!cell )
@@ -606,7 +603,7 @@ void BPF_STRUCT_OPS(mitosis_enqueue, struct task_struct *p, u64 enq_flags)
606603 if (time_before (vtime , basis_vtime - slice_ns ))
607604 vtime = basis_vtime - slice_ns ;
608605
609- scx_bpf_dsq_insert_vtime (p , tctx -> dsq , slice_ns , vtime , enq_flags );
606+ scx_bpf_dsq_insert_vtime (p , tctx -> dsq . raw , slice_ns , vtime , enq_flags );
610607
611608 /* Kick the CPU if needed */
612609 if (!__COMPAT_is_enq_cpu_selected (enq_flags ) && cpu >= 0 )
@@ -626,14 +623,10 @@ void BPF_STRUCT_OPS(mitosis_dispatch, s32 cpu, struct task_struct *prev)
626623 cell = READ_ONCE (cctx -> cell );
627624
628625 /* Start from a valid DSQ */
629- u64 local_dsq = get_cpu_dsq_id (cpu );
630- if (!local_dsq ) {
631- scx_bpf_error ("get_cpu_dsq_id(%d) returned 0" , cpu );
632- return ;
633- }
626+ dsq_id_t local_dsq = get_cpu_dsq_id (cpu );
634627
635628 bool found = false;
636- u64 min_vtime_dsq = local_dsq ;
629+ dsq_id_t min_vtime_dsq = local_dsq ;
637630 u64 min_vtime = ~0ULL ; /* U64_MAX */
638631 struct task_struct * p ;
639632
@@ -644,19 +637,17 @@ void BPF_STRUCT_OPS(mitosis_dispatch, s32 cpu, struct task_struct *prev)
644637
645638 /* Check the L3 queue */
646639 if (l3 != INVALID_L3_ID ) {
647- u64 cell_l3_dsq = get_cell_l3_dsq_id (cell , l3 );
648- if (cell_l3_dsq != DSQ_ERROR ) {
649- bpf_for_each (scx_dsq , p , cell_l3_dsq , 0 ) {
650- min_vtime = p -> scx .dsq_vtime ;
651- min_vtime_dsq = cell_l3_dsq ;
652- found = true;
653- break ;
654- }
640+ dsq_id_t cell_l3_dsq = get_cell_l3_dsq_id (cell , l3 );
641+ bpf_for_each (scx_dsq , p , cell_l3_dsq .raw , 0 ) {
642+ min_vtime = p -> scx .dsq_vtime ;
643+ min_vtime_dsq = cell_l3_dsq ;
644+ found = true;
645+ break ;
655646 }
656647 }
657648
658649 /* Check the CPU DSQ for a lower vtime */
659- bpf_for_each (scx_dsq , p , local_dsq , 0 ) {
650+ bpf_for_each (scx_dsq , p , local_dsq . raw , 0 ) {
660651 if (!found || time_before (p -> scx .dsq_vtime , min_vtime )) {
661652 min_vtime = p -> scx .dsq_vtime ;
662653 min_vtime_dsq = local_dsq ;
@@ -672,7 +663,7 @@ void BPF_STRUCT_OPS(mitosis_dispatch, s32 cpu, struct task_struct *prev)
672663 */
673664 // TODO: The upstream side has "&& min_vtime_dsq != dsq" as part of this condition.
674665 // Do we care?
675- if (!scx_bpf_dsq_move_to_local (min_vtime_dsq )) {
666+ if (!scx_bpf_dsq_move_to_local (min_vtime_dsq . raw )) {
676667#if MITOSIS_ENABLE_STEALING
677668 /* Dead-simple work stealing:
678669 * If our local choices are empty, scan sibling (cell,L3) DSQs in the
@@ -684,19 +675,18 @@ void BPF_STRUCT_OPS(mitosis_dispatch, s32 cpu, struct task_struct *prev)
684675 // TODO: This math is kinda dumb and confusing.
685676 u32 start = ((u32 )l3 + 1 ) % nr_l3 ;
686677 u32 off ;
678+ // TODO: This might try a bunch of L3s outside of the cell
687679 bpf_for (off , 0 , nr_l3 ) {
688680 u32 cand = (start + off ) % nr_l3 ;
689681 if (cand == (u32 )l3 )
690682 continue ;
691- u64 src = get_cell_l3_dsq_id (cell , cand );
692- if (src == DSQ_ERROR )
693- continue ;
683+ dsq_id_t src = get_cell_l3_dsq_id (cell , cand );
694684
695685 struct task_struct * q ;
696686 /* Peek only at the head. */
697- bpf_for_each (scx_dsq , q , src , 0 ) {
687+ bpf_for_each (scx_dsq , q , src . raw , 0 ) {
698688 // TODO maybe this should use if (scx_bpf_dsq_move(BPF_FOR_EACH_ITER, q, SCX_DSQ_LOCAL, 0) == 0)
699- if (scx_bpf_dsq_move_to_local (src )) {
689+ if (scx_bpf_dsq_move_to_local (src . raw )) {
700690 struct task_ctx * qt = lookup_task_ctx (q );
701691 if (qt ) {
702692 qt -> steal_count ++ ;
@@ -722,7 +712,7 @@ void BPF_STRUCT_OPS(mitosis_dispatch, s32 cpu, struct task_struct *prev)
722712 }
723713 if (!moved )
724714#endif
725- scx_bpf_dsq_move_to_local (local_dsq );
715+ scx_bpf_dsq_move_to_local (local_dsq . raw );
726716 }
727717}
728718
@@ -1149,7 +1139,7 @@ void BPF_STRUCT_OPS(mitosis_running, struct task_struct *p)
11491139#endif
11501140
11511141 /* Validate task's DSQ before it starts running */
1152- if (tctx -> dsq == 0 ) {
1142+ if (tctx -> dsq . raw == DSQ_INVALID . raw ) {
11531143 if (tctx -> all_cell_cpus_allowed ) {
11541144 scx_bpf_error (
11551145 "Task %d has invalid DSQ 0 in running callback (CELL-SCHEDULABLE task, can run on any CPU in cell %d)" ,
@@ -1437,13 +1427,13 @@ static __always_inline void dump_cell_state(u32 cell_idx)
14371427 }
14381428}
14391429
1430+ // TODO: FIX THIS
14401431static __always_inline void dump_l3_state (){
1441-
14421432}
14431433
14441434void BPF_STRUCT_OPS (mitosis_dump , struct scx_dump_ctx * dctx )
14451435{
1446- u64 dsq_id ;
1436+ dsq_id_t dsq_id ;
14471437 int i ;
14481438 struct cell * cell ;
14491439 struct cpu_ctx * cpu_ctx ;
@@ -1472,7 +1462,7 @@ void BPF_STRUCT_OPS(mitosis_dump, struct scx_dump_ctx *dctx)
14721462 dsq_id = get_cpu_dsq_id (i );
14731463 scx_bpf_dump ("CPU[%d] cell=%d vtime=%llu nr_queued=%d\n" , i ,
14741464 cpu_ctx -> cell , READ_ONCE (cpu_ctx -> vtime_now ),
1475- scx_bpf_dsq_nr_queued (dsq_id ));
1465+ scx_bpf_dsq_nr_queued (dsq_id . raw ));
14761466 }
14771467
14781468 dump_l3_state ();
@@ -1488,9 +1478,9 @@ void BPF_STRUCT_OPS(mitosis_dump_task, struct scx_dump_ctx *dctx,
14881478 return ;
14891479
14901480 scx_bpf_dump (
1491- "Task[%d] vtime=%llu basis_vtime=%llu cell=%u dsq=%x all_cell_cpus_allowed=%d\n" ,
1481+ "Task[%d] vtime=%llu basis_vtime=%llu cell=%u dsq=%llu all_cell_cpus_allowed=%d\n" ,
14921482 p -> pid , p -> scx .dsq_vtime , tctx -> basis_vtime , tctx -> cell ,
1493- tctx -> dsq , tctx -> all_cell_cpus_allowed );
1483+ tctx -> dsq . raw , tctx -> all_cell_cpus_allowed );
14941484 scx_bpf_dump ("Task[%d] CPUS=" , p -> pid );
14951485 dump_cpumask (p -> cpus_ptr );
14961486 scx_bpf_dump ("\n" );
@@ -1522,7 +1512,7 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(mitosis_init)
15221512 if ((u8_ptr = MEMBER_VPTR (all_cpus , [i / 8 ]))) {
15231513 if (* u8_ptr & (1 << (i % 8 ))) {
15241514 bpf_cpumask_set_cpu (i , cpumask );
1525- ret = scx_bpf_create_dsq (get_cpu_dsq_id (i ), ANY_NUMA );
1515+ ret = scx_bpf_create_dsq (get_cpu_dsq_id (i ). raw , ANY_NUMA );
15261516 if (ret < 0 ) {
15271517 bpf_cpumask_release (cpumask );
15281518 return ret ;
@@ -1584,12 +1574,10 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(mitosis_init)
15841574 u32 l3 ;
15851575 bpf_for (l3 , 0 , nr_l3 )
15861576 {
1587- u32 id = get_cell_l3_dsq_id (i , l3 );
1588- if (id == DSQ_ERROR )
1589- return - EINVAL ;
1590- ret = scx_bpf_create_dsq (id , ANY_NUMA );
1577+ dsq_id_t id = get_cell_l3_dsq_id (i , l3 );
1578+ ret = scx_bpf_create_dsq (id .raw , ANY_NUMA );
15911579 if (ret < 0 )
1592- return ret ;
1580+ scx_bpf_error ( "Failed to create DSQ for cell %d, L3 %d: err %d" , i , l3 , ret ) ;
15931581 }
15941582 }
15951583
0 commit comments