@@ -831,10 +831,10 @@ static void parse_numa_data(struct json_object *obj, numaset_data_t *data)
831
831
832
832
static sched_data_t * parse_sched_data (struct json_object * obj , int def_policy )
833
833
{
834
- sched_data_t tmp_data ;
834
+ sched_data_t tmp_data = { . policy = same } ;
835
835
char * def_str_policy ;
836
836
char * policy ;
837
- int prior_def = -1 ;
837
+ int prior_def ;
838
838
839
839
/* Get default policy */
840
840
def_str_policy = policy_to_string (def_policy );
@@ -846,17 +846,28 @@ static sched_data_t *parse_sched_data(struct json_object *obj, int def_policy)
846
846
log_critical (PIN2 "Invalid policy %s" , policy );
847
847
exit (EXIT_INV_CONFIG );
848
848
}
849
- } else {
850
- tmp_data .policy = -1 ;
851
849
}
852
850
853
851
/* Get priority */
854
- if (tmp_data .policy == -1 )
852
+ switch (tmp_data .policy ) {
853
+ case same :
855
854
prior_def = THREAD_PRIORITY_UNCHANGED ;
856
- else if (tmp_data .policy == other || tmp_data .policy == idle )
855
+ break ;
856
+ case other :
857
+ case idle :
857
858
prior_def = DEFAULT_THREAD_NICE ;
858
- else
859
+ break ;
860
+ case fifo :
861
+ case rr :
859
862
prior_def = DEFAULT_THREAD_PRIORITY ;
863
+ break ;
864
+ case deadline :
865
+ prior_def = 0 ;
866
+ break ;
867
+ default :
868
+ /* unreachable due to string_to_policy() above */
869
+ exit (EXIT_INV_CONFIG );
870
+ }
860
871
861
872
tmp_data .prio = get_int_value_from (obj , "priority" , TRUE, prior_def );
862
873
@@ -877,7 +888,7 @@ static sched_data_t *parse_sched_data(struct json_object *obj, int def_policy)
877
888
exit (EXIT_INV_CONFIG );
878
889
}
879
890
880
- if (def_policy != -1 ) {
891
+ if (def_policy != same ) {
881
892
/* Support legacy grammar for thread object */
882
893
if (!tmp_data .runtime )
883
894
tmp_data .runtime = get_int_value_from (obj , "runtime" , TRUE, 0 );
@@ -939,8 +950,11 @@ static taskgroup_data_t *parse_taskgroup_data(struct json_object *obj)
939
950
940
951
static void check_taskgroup_policy_dep (phase_data_t * pdata , thread_data_t * tdata )
941
952
{
942
- /* Save sched_data as thread's current sched_data. */
943
- if (pdata -> sched_data )
953
+ /*
954
+ * Save sched_data as thread's current sched_data in case its policy_t is
955
+ * set to a valid scheduler policy.
956
+ */
957
+ if (pdata -> sched_data && pdata -> sched_data -> policy != same )
944
958
tdata -> curr_sched_data = pdata -> sched_data ;
945
959
946
960
/* Save taskgroup_data as thread's current taskgroup_data. */
@@ -949,13 +963,17 @@ static void check_taskgroup_policy_dep(phase_data_t *pdata, thread_data_t *tdata
949
963
950
964
/*
951
965
* Detect policy/taskgroup misconfiguration: a task which specifies a
952
- * taskgroup should not run in a policy other than SCHED_OTHER.
966
+ * taskgroup should not run in a policy other than SCHED_OTHER or
967
+ * SCHED_IDLE.
953
968
*/
954
- if (tdata -> curr_sched_data && tdata -> curr_sched_data -> policy != other &&
955
- tdata -> curr_taskgroup_data ) {
956
- log_critical (PIN2 "No taskgroup support for policy %s" ,
957
- policy_to_string (tdata -> curr_sched_data -> policy ));
958
- exit (EXIT_INV_CONFIG );
969
+ if (tdata -> curr_sched_data && tdata -> curr_taskgroup_data ) {
970
+ policy_t policy = tdata -> curr_sched_data -> policy ;
971
+
972
+ if (policy != other && policy != idle ) {
973
+ log_critical (PIN2 "No taskgroup support for policy %s" ,
974
+ policy_to_string (policy ));
975
+ exit (EXIT_INV_CONFIG );
976
+ }
959
977
}
960
978
}
961
979
@@ -1000,7 +1018,7 @@ parse_task_phase_data(struct json_object *obj,
1000
1018
}
1001
1019
parse_cpuset_data (obj , & data -> cpu_data );
1002
1020
parse_numa_data (obj , & data -> numa_data );
1003
- data -> sched_data = parse_sched_data (obj , -1 );
1021
+ data -> sched_data = parse_sched_data (obj , same );
1004
1022
data -> taskgroup_data = parse_taskgroup_data (obj );
1005
1023
}
1006
1024
0 commit comments