@@ -2789,40 +2789,52 @@ void BPF_STRUCT_OPS(layered_disable, struct task_struct *p)
27892789 task_uncharge_qrt (taskc );
27902790}
27912791
2792- static u64 dsq_first_runnable_for_ms (u64 dsq_id , u64 now )
2792+ static s64 dsq_first_runnable_at_ms (u64 dsq_id , u64 now )
27932793{
27942794 struct task_struct * p ;
27952795
27962796 bpf_for_each (scx_dsq , p , dsq_id , 0 ) {
27972797 struct task_ctx * taskc ;
27982798
2799- if ((taskc = lookup_task_ctx (p )))
2800- return (now - taskc -> runnable_at ) / 1000000 ;
2799+ if ((taskc = lookup_task_ctx (p ))) {
2800+ u64 runnable_at = taskc -> runnable_at ;
2801+
2802+ if (runnable_at >= now )
2803+ return ((taskc -> runnable_at - now ) / 1000000 );
2804+ else
2805+ return - ((now - taskc -> runnable_at ) / 1000000 );
2806+ }
28012807 }
28022808
28032809 return 0 ;
28042810}
28052811
2812+ __hidden void dump_cpumask_word (s32 word , struct cpumask * cpumask )
2813+ {
2814+ u32 u , v = 0 ;
2815+
2816+ bpf_for (u , 0 , 32 ) {
2817+ s32 cpu = 32 * word + u ;
2818+ if (cpu < nr_cpu_ids &&
2819+ bpf_cpumask_test_cpu (cpu , cpumask ))
2820+ v |= 1 << u ;
2821+ }
2822+ scx_bpf_dump ("%08x" , v );
2823+ }
2824+
28062825static void dump_layer_cpumask (int id )
28072826{
28082827 struct cpumask * layer_cpumask ;
2809- s32 cpu ;
2810- char buf [128 ] = "" , * p ;
2828+ u32 word , nr_words = (nr_cpu_ids + 31 ) / 32 ;
28112829
28122830 if (!(layer_cpumask = lookup_layer_cpumask (id )))
28132831 return ;
28142832
2815- bpf_for (cpu , 0 , scx_bpf_nr_cpu_ids ()) {
2816- if (!(p = MEMBER_VPTR (buf , [cpu ])))
2817- break ;
2818- if (bpf_cpumask_test_cpu (cpu , layer_cpumask ))
2819- * p = '0' + cpu % 10 ;
2820- else
2821- * p = '.' ;
2833+ bpf_for (word , 0 , nr_words ) {
2834+ if (word )
2835+ scx_bpf_dump ("," );
2836+ dump_cpumask_word (nr_words - word - 1 , layer_cpumask );
28222837 }
2823- buf [sizeof (buf ) - 1 ] = '\0' ;
2824-
2825- scx_bpf_dump ("%s" , buf );
28262838}
28272839
28282840void BPF_STRUCT_OPS (layered_dump , struct scx_dump_ctx * dctx )
@@ -2846,24 +2858,24 @@ void BPF_STRUCT_OPS(layered_dump, struct scx_dump_ctx *dctx)
28462858 continue ;
28472859
28482860 dsq_id = layer_dsq_id (layer -> id , j );
2849- scx_bpf_dump ("LAYER[%d][%s] DSQ[%llx] nr_cpus=%u nr_queued=%d -%llums cpus= " ,
2861+ scx_bpf_dump ("LAYER[%d](%s)- DSQ[%llx] nr_cpus=%u nr_queued=%d %+lldms\n " ,
28502862 i , layer -> name , dsq_id , layer -> nr_cpus ,
28512863 scx_bpf_dsq_nr_queued (dsq_id ),
2852- dsq_first_runnable_for_ms (dsq_id , now ));
2853- scx_bpf_dump ("\n" );
2864+ dsq_first_runnable_at_ms (dsq_id , now ));
28542865 }
2866+ scx_bpf_dump ("LAYER[%d](%s) CPUS=" , i , layer -> name );
28552867 dump_layer_cpumask (i );
28562868 scx_bpf_dump ("\n" );
28572869 }
28582870 bpf_for (i , 0 , nr_llcs ) {
28592871 dsq_id = hi_fb_dsq_id (i );
2860- scx_bpf_dump ("HI_[%llx] nr_queued=%d -%llums \n" ,
2872+ scx_bpf_dump ("HI_[%llx] nr_queued=%d %+lldms \n" ,
28612873 dsq_id , scx_bpf_dsq_nr_queued (dsq_id ),
2862- dsq_first_runnable_for_ms (dsq_id , now ));
2874+ dsq_first_runnable_at_ms (dsq_id , now ));
28632875 dsq_id = lo_fb_dsq_id (i );
2864- scx_bpf_dump ("LO_FALLBACK[%llx] nr_queued=%d -%llums \n" ,
2876+ scx_bpf_dump ("LO_FALLBACK[%llx] nr_queued=%d %+lldms \n" ,
28652877 dsq_id , scx_bpf_dsq_nr_queued (dsq_id ),
2866- dsq_first_runnable_for_ms (dsq_id , now ));
2878+ dsq_first_runnable_at_ms (dsq_id , now ));
28672879 }
28682880}
28692881
0 commit comments