@@ -30,6 +30,8 @@ const volatile bool switch_partial;
3030static u64 vtime_now ;
3131struct user_exit_info uei ;
3232
33+ #define SHARED_DSQ 0
34+
3335struct {
3436 __uint (type , BPF_MAP_TYPE_PERCPU_ARRAY );
3537 __uint (key_size , sizeof (u32 ));
@@ -65,7 +67,7 @@ void BPF_STRUCT_OPS(simple_enqueue, struct task_struct *p, u64 enq_flags)
6567 stat_inc (1 ); /* count global queueing */
6668
6769 if (fifo_sched ) {
68- scx_bpf_dispatch (p , SCX_DSQ_GLOBAL , SCX_SLICE_DFL , enq_flags );
70+ scx_bpf_dispatch (p , SHARED_DSQ , SCX_SLICE_DFL , enq_flags );
6971 } else {
7072 u64 vtime = p -> scx .dsq_vtime ;
7173
@@ -76,11 +78,16 @@ void BPF_STRUCT_OPS(simple_enqueue, struct task_struct *p, u64 enq_flags)
7678 if (vtime_before (vtime , vtime_now - SCX_SLICE_DFL ))
7779 vtime = vtime_now - SCX_SLICE_DFL ;
7880
79- scx_bpf_dispatch_vtime (p , SCX_DSQ_GLOBAL , SCX_SLICE_DFL , vtime ,
81+ scx_bpf_dispatch_vtime (p , SHARED_DSQ , SCX_SLICE_DFL , vtime ,
8082 enq_flags );
8183 }
8284}
8385
86+ void BPF_STRUCT_OPS (simple_dispatch , s32 cpu , struct task_struct * prev )
87+ {
88+ scx_bpf_consume (SHARED_DSQ );
89+ }
90+
8491void BPF_STRUCT_OPS (simple_running , struct task_struct * p )
8592{
8693 if (fifo_sched )
@@ -119,11 +126,12 @@ void BPF_STRUCT_OPS(simple_enable, struct task_struct *p,
119126 p -> scx .dsq_vtime = vtime_now ;
120127}
121128
122- s32 BPF_STRUCT_OPS (simple_init )
129+ s32 BPF_STRUCT_OPS_SLEEPABLE (simple_init )
123130{
124131 if (!switch_partial )
125132 scx_bpf_switch_all ();
126- return 0 ;
133+
134+ return scx_bpf_create_dsq (SHARED_DSQ , -1 );
127135}
128136
129137void BPF_STRUCT_OPS (simple_exit , struct scx_exit_info * ei )
@@ -134,6 +142,7 @@ void BPF_STRUCT_OPS(simple_exit, struct scx_exit_info *ei)
134142SEC (".struct_ops.link" )
135143struct sched_ext_ops simple_ops = {
136144 .enqueue = (void * )simple_enqueue ,
145+ .dispatch = (void * )simple_dispatch ,
137146 .running = (void * )simple_running ,
138147 .stopping = (void * )simple_stopping ,
139148 .enable = (void * )simple_enable ,
0 commit comments