From 6026f2deadaa913b91d78a30fe41aa7ae20bd222 Mon Sep 17 00:00:00 2001 From: Juri Lelli Date: Thu, 21 May 2015 12:33:57 +0100 Subject: rt-app: fix batch tasks A big run duration can cause load_count to overflow. Fix this issue by running the workload in bursts of 1 sec each. Signed-off-by: Juri Lelli Acked-by: Vincent Guittot --- src/rt-app.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/rt-app.c b/src/rt-app.c index 5a550eb..76a1f68 100644 --- a/src/rt-app.c +++ b/src/rt-app.c @@ -48,10 +48,11 @@ static ftrace_data_t ft_data = { * Function: to do some useless operation. * TODO: improve the waste loop with more heavy functions */ -void waste_cpu_cycles(int load_loops) +void waste_cpu_cycles(unsigned long long load_loops) { double param, result; - double n, i; + double n; + unsigned long long i; param = 0.95; n = 4; @@ -175,7 +176,24 @@ int calibrate_cpu_cycles(int clock) static inline unsigned long loadwait(unsigned long exec) { unsigned long load_count; + unsigned long secs; + int i; + + /* + * If exec is still too big, let's run it in bursts + * so that we don't overflow load_count. + */ + secs = exec / 1000000; + for (i = 0; i < secs; i++) { + load_count = 1000000000/p_load; + waste_cpu_cycles(load_count); + exec -= 1000000; + } + + /* + * Run for the remainig exec (if any). + */ load_count = (exec * 1000)/p_load; waste_cpu_cycles(load_count); -- cgit v1.2.3