From: Xunlei Pang pang.xunlei@linaro.org
Add new spreading-tasks.json in doc/examples.
It create 2 threads made of a 1st phase with small load (10% as an example) followed by a phase with a large load (70% as an example). Each phase lasts 6sec to let system stabilize.
Signed-off-by: Xunlei Pang pang.xunlei@linaro.org --- doc/examples/spreading-tasks.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 doc/examples/spreading-tasks.json
diff --git a/doc/examples/spreading-tasks.json b/doc/examples/spreading-tasks.json new file mode 100644 index 0000000..844db44 --- /dev/null +++ b/doc/examples/spreading-tasks.json @@ -0,0 +1,26 @@ +{ + "tasks" : { + "thread" : { + "instance" : 2, + "loop" : -1, + "phases" : { + "light" : { + "loop" : 600, + "run" : 1000, + "timer" : { "ref" : "unique", "period" : 10000 } + }, + "heavy" : { + "loop" : 600, + "run" : 7000, + "timer" : { "ref" : "unique", "period" : 10000 } + } + } + } + }, + "global" : { + "duration" : 60, + "default_policy" : "SCHED_OTHER", + "calibration" : "CPU0" + } +} +
From: Xunlei Pang pang.xunlei@linaro.org
Currently, timers are related to threads(instances), this may cause some problems: - For shared timers between phases of the same thread instance. see example1, "phase1" : { "timer": { "ref" : "shared", "period" : 10000 }, /* consume some time */ }, "phase2" : { "loop" : 100, "run" : 700, "timer": { "ref" : "shared", "period" : 1000 }, }
If we consume a little long time after the timer at phase1, then when running the timer at phase2, it will actually be disfunctional within the time consumed at "phase1", because "timer.t_next" is before "t_now".
- Moreover, if we define different unique timers(not shared) for each phase, the timers will be problematic when looping back to its phase, see example2, "loop" : -1, "phase1" : { "loop" : 600, "run" : 7000, "timer" : { "ref" : "uniqueA", "period" : 10000 }, }, "phase2" : { "loop" : 600, "run" : 1000, "timer" : { "ref" : "uniqueB", "period" : 10000 }, }
As we can learn from the above-mentioned scenarios, it makes more sense to relate timers to phases rather than to threads.
So, this patch removed _rtapp_timer::init, and initialized _rtapp_timer::t_next at the very beginning of its phase.
Signed-off-by: Xunlei Pang pang.xunlei@linaro.org --- src/rt-app.c | 14 ++++++-------- src/rt-app_parse_config.c | 1 - src/rt-app_types.h | 1 - 3 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/rt-app.c b/src/rt-app.c index 97aee0f..389cbcf 100644 --- a/src/rt-app.c +++ b/src/rt-app.c @@ -110,8 +110,8 @@ static inline loadwait(unsigned long exec) return load_count; }
-static int run_event(event_data_t *event, int dry_run, - unsigned long *perf, unsigned long *duration, rtapp_resource_t *resources) +static int run_event(event_data_t *event, int dry_run, unsigned long *perf, + unsigned long *duration, rtapp_resource_t *resources, int new_phase) { rtapp_resource_t *rdata = &(resources[event->res]); rtapp_resource_t *ddata = &(resources[event->dep]); @@ -175,10 +175,8 @@ static int run_event(event_data_t *event, int dry_run,
t_period = usec_to_timespec(event->duration);
- if (rdata->res.timer.init == 0) { - rdata->res.timer.init = 1; + if (new_phase) clock_gettime(CLOCK_MONOTONIC, &rdata->res.timer.t_next); - }
rdata->res.timer.t_next = timespec_add(&rdata->res.timer.t_next, &t_period); clock_gettime(CLOCK_MONOTONIC, &t_now); @@ -209,7 +207,7 @@ static int run_event(event_data_t *event, int dry_run,
int run(int ind, event_data_t *events, int nbevents, unsigned long *duration, - rtapp_resource_t *resources) + rtapp_resource_t *resources, int new_phase) { int i, lock = 0; unsigned long perf = 0; @@ -224,7 +222,7 @@ int run(int ind, event_data_t *events, log_ftrace(ft_data.marker_fd, "[%d] executing %d", ind, i); - lock += run_event(&events[i], !continue_running, &perf, duration, resources); + lock += run_event(&events[i], !continue_running, &perf, duration, resources, new_phase); }
return perf; @@ -418,7 +416,7 @@ void *thread_body(void *arg)
duration = 0; clock_gettime(CLOCK_MONOTONIC, &t_start); - perf = run(data->ind, pdata->events, pdata->nbevents, &duration, *(data->resources)); + perf = run(data->ind, pdata->events, pdata->nbevents, &duration, *(data->resources), (loop == 0)); clock_gettime(CLOCK_MONOTONIC, &t_end);
if (timings) diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c index 96e5517..bbd44ab 100644 --- a/src/rt-app_parse_config.c +++ b/src/rt-app_parse_config.c @@ -179,7 +179,6 @@ static int init_mutex_resource(rtapp_resource_t *data, const rtapp_options_t *op static int init_timer_resource(rtapp_resource_t *data, const rtapp_options_t *opts) { log_info(PIN3 "Init: %s timer", data->name); - data->res.timer.init = 0; }
static int init_cond_resource(rtapp_resource_t *data, const rtapp_options_t *opts) diff --git a/src/rt-app_types.h b/src/rt-app_types.h index 1075f64..cefb3a6 100644 --- a/src/rt-app_types.h +++ b/src/rt-app_types.h @@ -83,7 +83,6 @@ struct _rtapp_signal {
struct _rtapp_timer { struct timespec t_next; - int init; };
/* Shared resources */
On 15 April 2015 at 10:55, Xunlei Pang xlpang@126.com wrote:
From: Xunlei Pang pang.xunlei@linaro.org
Add new spreading-tasks.json in doc/examples.
It create 2 threads made of a 1st phase with small load (10% as an example) followed by a phase with a large load (70% as an example). Each phase lasts 6sec to let system stabilize.
Signed-off-by: Xunlei Pang pang.xunlei@linaro.org
doc/examples/spreading-tasks.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 doc/examples/spreading-tasks.json
diff --git a/doc/examples/spreading-tasks.json b/doc/examples/spreading-tasks.json new file mode 100644 index 0000000..844db44 --- /dev/null +++ b/doc/examples/spreading-tasks.json @@ -0,0 +1,26 @@ +{
"tasks" : {
"thread" : {
"instance" : 2,
"loop" : -1,
"phases" : {
"light" : {
"loop" : 600,
"run" : 1000,
"timer" : { "ref" : "unique", "period" : 10000 }
},
"heavy" : {
"loop" : 600,
"run" : 7000,
"timer" : { "ref" : "unique", "period" : 10000 }
}
}
}
},
"global" : {
"duration" : 60,
"default_policy" : "SCHED_OTHER",
"calibration" : "CPU0"
}
+}
Acked-by: Vincent Guittot vincent.guittot@linaro.org
-- 1.9.1