@@ -155,6 +155,7 @@ struct tune_input{
155
155
} tune_input ;
156
156
157
157
__u64 tune_params_gen ;
158
+ private (A ) struct bpf_cpumask __kptr * all_cpumask ;
158
159
private (A ) struct bpf_cpumask __kptr * direct_greedy_cpumask ;
159
160
private (A ) struct bpf_cpumask __kptr * kick_greedy_cpumask ;
160
161
@@ -790,7 +791,8 @@ void BPF_STRUCT_OPS(rusty_set_cpumask, struct task_struct *p,
790
791
}
791
792
792
793
task_pick_and_set_domain (task_ctx , p , cpumask , false);
793
- task_ctx -> all_cpus = bpf_cpumask_full (cpumask );
794
+ if (all_cpumask )
795
+ task_ctx -> all_cpus = bpf_cpumask_subset (all_cpumask , cpumask );
794
796
}
795
797
796
798
s32 BPF_STRUCT_OPS (rusty_prep_enable , struct task_struct * p ,
@@ -890,8 +892,14 @@ static s32 create_dom(u32 dom_id)
890
892
return - ENOENT ;
891
893
}
892
894
893
- if (* dmask & (1LLU << (cpu % 64 )))
895
+ if (* dmask & (1LLU << (cpu % 64 ))) {
894
896
bpf_cpumask_set_cpu (cpu , cpumask );
897
+
898
+ bpf_rcu_read_lock ();
899
+ if (all_cpumask )
900
+ bpf_cpumask_set_cpu (cpu , all_cpumask );
901
+ bpf_rcu_read_unlock ();
902
+ }
895
903
}
896
904
897
905
cpumask = bpf_kptr_xchg (& domc -> cpumask , cpumask );
@@ -924,17 +932,12 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(rusty_init)
924
932
struct bpf_cpumask * cpumask ;
925
933
s32 i , ret ;
926
934
927
- if (!switch_partial )
928
- scx_bpf_switch_all ();
929
-
930
- bpf_for (i , 0 , nr_doms ) {
931
- ret = create_dom (i );
932
- if (ret )
933
- return ret ;
934
- }
935
-
936
- bpf_for (i , 0 , nr_cpus )
937
- pcpu_ctx [i ].dom_rr_cur = i ;
935
+ cpumask = bpf_cpumask_create ();
936
+ if (!cpumask )
937
+ return - ENOMEM ;
938
+ cpumask = bpf_kptr_xchg (& all_cpumask , cpumask );
939
+ if (cpumask )
940
+ bpf_cpumask_release (cpumask );
938
941
939
942
cpumask = bpf_cpumask_create ();
940
943
if (!cpumask )
@@ -950,6 +953,18 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(rusty_init)
950
953
if (cpumask )
951
954
bpf_cpumask_release (cpumask );
952
955
956
+ if (!switch_partial )
957
+ scx_bpf_switch_all ();
958
+
959
+ bpf_for (i , 0 , nr_doms ) {
960
+ ret = create_dom (i );
961
+ if (ret )
962
+ return ret ;
963
+ }
964
+
965
+ bpf_for (i , 0 , nr_cpus )
966
+ pcpu_ctx [i ].dom_rr_cur = i ;
967
+
953
968
return 0 ;
954
969
}
955
970
0 commit comments