Signed-off-by: Vincent Guittot vincent.guittot@linaro.org --- src/rt-app.c | 73 ++++++++++++++++++++++++----------------------- src/rt-app_args.c | 43 ++++++++++++++-------------- src/rt-app_parse_config.c | 2 +- 3 files changed, 60 insertions(+), 58 deletions(-)
diff --git a/src/rt-app.c b/src/rt-app.c index e1604b5..a7c1d97 100644 --- a/src/rt-app.c +++ b/src/rt-app.c @@ -181,13 +181,12 @@ void *thread_body(void *arg) }
log_notice("[%d] starting thread with period: %lu, exec: %lu," - "deadline: %lu, priority: %d", - data->ind, - timespec_to_usec(&data->period), - timespec_to_usec(&data->min_et), - timespec_to_usec(&data->deadline), - data->sched_prio - ); + "deadline: %lu, priority: %d", + data->ind, + timespec_to_usec(&data->period), + timespec_to_usec(&data->min_et), + timespec_to_usec(&data->deadline), + data->sched_prio); break;
case other: @@ -196,37 +195,39 @@ void *thread_body(void *arg) /* add priority setting */
log_notice("[%d] starting thread with period: %lu, exec: %lu," - "deadline: %lu", - data->ind, - timespec_to_usec(&data->period), - timespec_to_usec(&data->min_et), - timespec_to_usec(&data->deadline) - ); + "deadline: %lu", + data->ind, + timespec_to_usec(&data->period), + timespec_to_usec(&data->min_et), + timespec_to_usec(&data->deadline)); + data->lock_pages = 0; /* forced off for SCHED_OTHER */ break;
#ifdef AQUOSA case aquosa: fprintf(data->log_handler, "# Policy : AQUOSA\n"); - data->params.Q_min = round((timespec_to_usec(&data->min_et) * (( 100.0 + data->sched_prio ) / 100)) / (data->fragment * 1.0)); - data->params.Q = round((timespec_to_usec(&data->max_et) * (( 100.0 + data->sched_prio ) / 100)) / (data->fragment * 1.0)); - data->params.P = round(timespec_to_usec(&data->period) / (data->fragment * 1.0)); + data->params.Q_min = round((timespec_to_usec(&data->min_et) + * (( 100.0 + data->sched_prio ) / 100)) / (data->fragment * 1.0)); + data->params.Q = round((timespec_to_usec(&data->max_et) + * (( 100.0 + data->sched_prio ) / 100)) / (data->fragment * 1.0)); + data->params.P = round(timespec_to_usec(&data->period) + / (data->fragment * 1.0)); data->params.flags = 0;
log_notice("[%d] Creating QRES Server with Q=%ld, P=%ld", - data->ind,data->params.Q, data->params.P); + data->ind,data->params.Q, data->params.P);
qos_chk_ok_exit(qres_init()); qos_chk_ok_exit(qres_create_server(&data->params, &data->sid)); log_notice("[%d] AQuoSA server ID: %d", data->ind, data->sid); log_notice("[%d] attaching thread (deadline: %lu) to server %d", - data->ind, - timespec_to_usec(&data->deadline), - data->sid - ); - qos_chk_ok_exit(qres_attach_thread(data->sid, 0, 0)); + data->ind, + timespec_to_usec(&data->deadline), + data->sid);
+ qos_chk_ok_exit(qres_attach_thread(data->sid, 0, 0)); break; #endif
@@ -239,16 +240,16 @@ void *thread_body(void *arg) attr.sched_policy = SCHED_DEADLINE; attr.sched_priority = 0; attr.sched_runtime = timespec_to_nsec(&data->max_et) + - (timespec_to_nsec(&data->max_et) /100) * BUDGET_OVERP; + (timespec_to_nsec(&data->max_et) /100) * BUDGET_OVERP; attr.sched_deadline = timespec_to_nsec(&data->period); attr.sched_period = timespec_to_nsec(&data->period); - break; #endif
default: log_error("Unknown scheduling policy %d", - data->sched_policy); + data->sched_policy); + exit(EXIT_FAILURE); }
@@ -282,9 +283,9 @@ void *thread_body(void *arg) timings = NULL; if (data->duration > 0) { my_duration_usec = (data->duration * 10e6) - - (data->wait_before_start * 1000); + (data->wait_before_start * 1000); nperiods = (int) ceil( my_duration_usec / - (double) timespec_to_usec(&data->period)); + (double) timespec_to_usec(&data->period)); timings = malloc ( nperiods * sizeof(timing_point_t)); }
@@ -293,19 +294,19 @@ void *thread_body(void *arg) "\tBudget\tUsed Budget\n");
#ifdef DLSCHED + /* TODO find a better way to handle that constraint */ /* * Set the task to SCHED_DEADLINE as far as possible touching its * budget as little as possible for the first iteration. */ if (data->sched_policy == SCHED_DEADLINE) { log_notice("[%d] starting thread with period: %lu, exec: %lu," - "deadline: %lu, priority: %d", - data->ind, - attr.sched_period / 1000, - attr.sched_runtime / 1000, - attr.sched_deadline / 1000, - attr.sched_priority - ); + "deadline: %lu, priority: %d", + data->ind, + attr.sched_period / 1000, + attr.sched_runtime / 1000, + attr.sched_deadline / 1000, + attr.sched_priority);
ret = sched_setattr(tid, &attr, flags); if (ret != 0) { @@ -363,7 +364,7 @@ void *thread_body(void *arg) &abs_used_budget, NULL); curr_timing->used_budget = - abs_used_budget - prev_abs_used_budget; + abs_used_budget - prev_abs_used_budget; prev_abs_used_budget = abs_used_budget;
} else { @@ -554,7 +555,7 @@ int main(int argc, char* argv[]) fclose(gnuplot_script);
snprintf(tmp, PATH_LENGTH, "%s/%s-slack.plot", - opts.logdir, opts.logbasename); + opts.logdir, opts.logbasename); gnuplot_script = fopen(tmp, "w+"); snprintf(tmp, PATH_LENGTH, "%s-slack.eps", opts.logbasename); diff --git a/src/rt-app_args.c b/src/rt-app_args.c index b7dcb21..cda1034 100644 --- a/src/rt-app_args.c +++ b/src/rt-app_args.c @@ -28,7 +28,7 @@ usage (const char* msg, int ex_code) "rt-app <taskset.json>\nOR\n"); #endif printf("rt-app [options] -t <period>:<exec>[:policy" - "[:CPU affinity[:prio[:deadline]]]] -t ...\n\n"); + "[:CPU affinity[:prio[:deadline]]]] -t ...\n\n"); printf("-h, --help\t\t:\tshow this help\n"); printf("-f, --fifo\t\t:\tset default policy for threads to SCHED_FIFO\n"); printf("-r, --rr\t\t:\tset default policy fior threads to SCHED_RR\n"); @@ -228,24 +228,25 @@ parse_command_line_options(int argc, char **argv, rtapp_options_t *opts) #endif
static struct option long_options[] = { - {"help", 0, 0, 'h'}, - {"fifo", 0, 0, 'f'}, - {"rr", 0, 0, 'r'}, - {"thread", 1, 0, 't'}, - {"spacing", 1, 0, 's'}, - {"logdir", 1, 0, 'l'}, - {"baselog", 1, 0, 'b'}, - {"gnuplot", 1, 0, 'G'}, - {"duration", 1, 0, 'D'}, - {"ftrace", 0, 0, 'T'}, - {"pi_enabled", 0, 0, 'T'}, - {"die_on_dmiss", 0, 0, 'M'}, + {"help", 0, 0, 'h'}, + {"fifo", 0, 0, 'f'}, + {"rr", 0, 0, 'r'}, + {"thread", 1, 0, 't'}, + {"spacing", 1, 0, 's'}, + {"logdir", 1, 0, 'l'}, + {"baselog", 1, 0, 'b'}, + {"gnuplot", 1, 0, 'G'}, + {"duration", 1, 0, 'D'}, + {"ftrace", 0, 0, 'T'}, + {"pi_enabled", 0, 0, 'T'}, + {"die_on_dmiss", 0, 0, 'M'}, #ifdef AQUOSA - {"qos", 0, 0, 'q'}, - {"frag",1, 0, 'g'}, + {"qos", 0, 0, 'q'}, + {"frag",1, 0, 'g'}, #endif - {0, 0, 0, 0} - }; + {0, 0, 0, 0} + }; + #ifdef AQUOSA while (( ch = getopt_long(argc,argv,"D:GKhfrb:s:l:qg:t:TM", long_options, &longopt_idx)) != -1) @@ -293,13 +294,13 @@ parse_command_line_options(int argc, char **argv, rtapp_options_t *opts) if (opts->nthreads > 0) { opts->threads_data = realloc( - opts->threads_data, - (opts->nthreads+1) * \ + opts->threads_data, + (opts->nthreads+1) * \ sizeof(thread_data_t)); } parse_thread_args(optarg, opts->nthreads, - &opts->threads_data[opts->nthreads], - opts->policy); + &opts->threads_data[opts->nthreads], + opts->policy); opts->nthreads++; break; case 'G': diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c index 5ca684b..fde6f9e 100644 --- a/src/rt-app_parse_config.c +++ b/src/rt-app_parse_config.c @@ -318,7 +318,7 @@ parse_thread_resources(const rtapp_options_t *opts, struct json_object *locks, data->blockages[i].usage = usec_to_timespec(usage_usec); } log_info(PIN "res %d, usage: %d acl: %s", cur_res_idx, - usage_usec, debug_msg); + usage_usec, debug_msg); } }