Skip to content

Commit 37667fe

Browse files
authored
Merge pull request #107 from deggeman/taskgroups_and_deadline_fixes
Taskgroups and deadline fixes
2 parents eadb1f6 + a6cef8b commit 37667fe

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

doc/tutorial.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ and don't do anything otherwise.
326326
*** taskgroups
327327

328328
* taskgroup: String. Can be specified at task level or phase level. Currently
329-
only SCHED_OTHER tasks are supported to contain taskgroup data. Tasks with a
330-
policy other than SCHED_OTHER and without taskgroup data can coexist in the
329+
only SCHED_OTHER and SCHED_IDLE tasks are supported to contain taskgroup data.
330+
Tasks with a different policy and without taskgroup data can coexist in the
331331
setup. An empty taskgroup ("") is allowed and is interpreted as if there is
332332
no taskgroup data given. Pre-existing parts of a taskgroup are preserved.
333333
They are not removed during rt-app teardown.

src/rt-app_parse_config.c

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -831,10 +831,10 @@ static void parse_numa_data(struct json_object *obj, numaset_data_t *data)
831831

832832
static sched_data_t *parse_sched_data(struct json_object *obj, int def_policy)
833833
{
834-
sched_data_t tmp_data;
834+
sched_data_t tmp_data = { .policy = same };
835835
char *def_str_policy;
836836
char *policy;
837-
int prior_def = -1;
837+
int prior_def;
838838

839839
/* Get default policy */
840840
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)
846846
log_critical(PIN2 "Invalid policy %s", policy);
847847
exit(EXIT_INV_CONFIG);
848848
}
849-
} else {
850-
tmp_data.policy = -1;
851849
}
852850

853851
/* Get priority */
854-
if (tmp_data.policy == -1)
852+
switch (tmp_data.policy) {
853+
case same:
855854
prior_def = THREAD_PRIORITY_UNCHANGED;
856-
else if (tmp_data.policy == other || tmp_data.policy == idle)
855+
break;
856+
case other:
857+
case idle:
857858
prior_def = DEFAULT_THREAD_NICE;
858-
else
859+
break;
860+
case fifo:
861+
case rr:
859862
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+
}
860871

861872
tmp_data.prio = get_int_value_from(obj, "priority", TRUE, prior_def);
862873

@@ -877,7 +888,7 @@ static sched_data_t *parse_sched_data(struct json_object *obj, int def_policy)
877888
exit(EXIT_INV_CONFIG);
878889
}
879890

880-
if (def_policy != -1) {
891+
if (def_policy != same) {
881892
/* Support legacy grammar for thread object */
882893
if (!tmp_data.runtime)
883894
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)
939950

940951
static void check_taskgroup_policy_dep(phase_data_t *pdata, thread_data_t *tdata)
941952
{
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)
944958
tdata->curr_sched_data = pdata->sched_data;
945959

946960
/* 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
949963

950964
/*
951965
* 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.
953968
*/
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+
}
959977
}
960978
}
961979

@@ -1000,7 +1018,7 @@ parse_task_phase_data(struct json_object *obj,
10001018
}
10011019
parse_cpuset_data(obj, &data->cpu_data);
10021020
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);
10041022
data->taskgroup_data = parse_taskgroup_data(obj);
10051023
}
10061024

0 commit comments

Comments
 (0)