From cc4a31beeb50751875e0394672372e13eb4475aa Mon Sep 17 00:00:00 2001 From: Juri Lelli Date: Tue, 10 Jan 2017 12:53:43 +0000 Subject: [PATCH] rt-app: add support for SCHED_DEADLINE bandwidth reclaiming Mainline got support for SCHED_DEADLINE bandwidth reclaming. Make that feature available to rt-app. Signed-off-by: Juri Lelli --- doc/examples/deadline.json | 27 ++++++++++++++++++++++++ doc/examples/deadline_no_reclaim-1.json | 28 +++++++++++++++++++++++++ doc/examples/deadline_reclaim-1.json | 28 +++++++++++++++++++++++++ libdl/dl_syscalls.h | 9 +------- src/rt-app.c | 3 +++ src/rt-app_parse_config.c | 1 + src/rt-app_types.h | 1 + 7 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 doc/examples/deadline.json create mode 100644 doc/examples/deadline_no_reclaim-1.json create mode 100644 doc/examples/deadline_reclaim-1.json diff --git a/doc/examples/deadline.json b/doc/examples/deadline.json new file mode 100644 index 00000000..35ac9f8f --- /dev/null +++ b/doc/examples/deadline.json @@ -0,0 +1,27 @@ +{ + /* + * Simple use case which creates 10% load + * until the use case is stopped with Ctrl+C + */ + "tasks" : { + "thread0" : { + "instance" : 1, + "loop" : -1, + "run" : 10000, + "timer" : { "ref" : "unique", "period" : 100000 }, + "dl-runtime" : 12000, + "dl-period" : 100000, + } + }, + "global" : { + "duration" : 2, + "calibration" : "CPU0", + "default_policy" : "SCHED_DEADLINE", + "pi_enabled" : false, + "lock_pages" : false, + "logdir" : "./", + "log_basename" : "rt-app2", + "ftrace" : true, + "gnuplot" : false + } +} diff --git a/doc/examples/deadline_no_reclaim-1.json b/doc/examples/deadline_no_reclaim-1.json new file mode 100644 index 00000000..62435138 --- /dev/null +++ b/doc/examples/deadline_no_reclaim-1.json @@ -0,0 +1,28 @@ +{ + /* + * Simple use case which creates 10% load + * until the use case is stopped with Ctrl+C + */ + "tasks" : { + "thread0" : { + "instance" : 1, + "loop" : -1, + "run" : 15000, + "timer" : { "ref" : "unique", "period" : 100000 }, + "dl-runtime" : 12000, + "dl-period" : 100000, + "dl-reclaim" : false + } + }, + "global" : { + "duration" : 2, + "calibration" : "CPU0", + "default_policy" : "SCHED_DEADLINE", + "pi_enabled" : false, + "lock_pages" : false, + "logdir" : "./", + "log_basename" : "rt-app2", + "ftrace" : true, + "gnuplot" : false + } +} diff --git a/doc/examples/deadline_reclaim-1.json b/doc/examples/deadline_reclaim-1.json new file mode 100644 index 00000000..c9e10b04 --- /dev/null +++ b/doc/examples/deadline_reclaim-1.json @@ -0,0 +1,28 @@ +{ + /* + * Simple use case which creates 10% load + * until the use case is stopped with Ctrl+C + */ + "tasks" : { + "thread0" : { + "instance" : 1, + "loop" : -1, + "run" : 15000, + "timer" : { "ref" : "unique", "period" : 100000 }, + "dl-runtime" : 12000, + "dl-period" : 100000, + "dl-reclaim" : true + } + }, + "global" : { + "duration" : 2, + "calibration" : "CPU0", + "default_policy" : "SCHED_DEADLINE", + "pi_enabled" : false, + "lock_pages" : false, + "logdir" : "./", + "log_basename" : "rt-app2", + "ftrace" : true, + "gnuplot" : false + } +} diff --git a/libdl/dl_syscalls.h b/libdl/dl_syscalls.h index ca07503e..ac214f2d 100644 --- a/libdl/dl_syscalls.h +++ b/libdl/dl_syscalls.h @@ -65,14 +65,7 @@ #endif #endif -#define SF_SIG_RORUN 2 -#define SF_SIG_DMISS 4 -#define SF_BWRECL_DL 8 -#define SF_BWRECL_RT 16 -#define SF_BWRECL_OTH 32 - -#define RLIMIT_DLDLINE 16 -#define RLIMIT_DLRTIME 17 +#define SCHED_FLAG_RECLAIM 0x02 struct sched_attr { __u32 size; diff --git a/src/rt-app.c b/src/rt-app.c index 471edff5..a6c2e516 100644 --- a/src/rt-app.c +++ b/src/rt-app.c @@ -679,6 +679,9 @@ static void set_thread_priority(thread_data_t *data, sched_data_t *sched_data) dl_params.sched_deadline = sched_data->deadline; dl_params.sched_period = sched_data->period; + if (sched_data->reclaim) + dl_params.sched_flags |= SCHED_FLAG_RECLAIM; + ret = sched_setattr(tid, &dl_params, flags); if (ret != 0) { log_critical("[%d] sched_setattr " diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c index ca3684a1..e8d3dff1 100644 --- a/src/rt-app_parse_config.c +++ b/src/rt-app_parse_config.c @@ -718,6 +718,7 @@ static sched_data_t *parse_sched_data(struct json_object *obj, int def_policy) tmp_data.runtime = get_int_value_from(obj, "dl-runtime", TRUE, 0); tmp_data.period = get_int_value_from(obj, "dl-period", TRUE, tmp_data.runtime); tmp_data.deadline = get_int_value_from(obj, "dl-deadline", TRUE, tmp_data.period); + tmp_data.reclaim = get_bool_value_from(obj, "dl-reclaim", TRUE, 0); if (def_policy != -1) { diff --git a/src/rt-app_types.h b/src/rt-app_types.h index 35fef9dd..de538b6e 100644 --- a/src/rt-app_types.h +++ b/src/rt-app_types.h @@ -154,6 +154,7 @@ typedef struct _sched_data_t { unsigned long runtime; unsigned long deadline; unsigned long period; + int reclaim; } sched_data_t; typedef struct _phase_data_t {