diff options
author | Vincent Guittot <vincent.guittot@linaro.org> | 2014-11-14 14:53:30 +0100 |
---|---|---|
committer | Vincent Guittot <vincent.guittot@linaro.org> | 2014-11-14 14:53:30 +0100 |
commit | 6b1debaab5731b70e5656b37ecdb94e15d8a37be (patch) | |
tree | 7b2be3c1109a63c93e247f12af162e145dd2361f /src | |
parent | 869b5c6f42549459cba12856ce62312c9cae73cb (diff) |
rt-app: fix log file value
times values overflow after something like 1h15mn on ARM. This value
is what can be handled by a 32bits variable for a usec unit.
use u64 instead of unsigned long which varies with architecture
also removed unused function
Reported-by: Larry Bassel <larry.bassel@linaro.org>
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/rt-app.c | 12 | ||||
-rw-r--r-- | src/rt-app_types.h | 6 | ||||
-rw-r--r-- | src/rt-app_utils.c | 20 | ||||
-rw-r--r-- | src/rt-app_utils.h | 9 |
4 files changed, 18 insertions, 29 deletions
diff --git a/src/rt-app.c b/src/rt-app.c index de91ff1..3cd601d 100644 --- a/src/rt-app.c +++ b/src/rt-app.c @@ -404,7 +404,7 @@ void *thread_body(void *arg) i = j = loop = 0; while (continue_running && (i != data->loop)) { - struct timespec t_diff; + struct timespec t_diff, t_rel_start; if (opts.ftrace) log_ftrace(ft_data.marker_fd, "[%d] begins loop %d phase %d step %d", data->ind, i, j, loop); @@ -421,14 +421,12 @@ void *thread_body(void *arg) curr_timing = &tmp_timing; t_diff = timespec_sub(&t_end, &t_start); - - t_start_usec = timespec_to_usec(&t_start); + t_rel_start = timespec_sub(&t_start, &data->main_app_start); curr_timing->ind = data->ind; - curr_timing->rel_start_time = - t_start_usec - timespec_to_usec(&data->main_app_start); - curr_timing->start_time = t_start_usec; - curr_timing->end_time = timespec_to_usec(&t_end); + curr_timing->rel_start_time = timespec_to_usec_ull(&t_rel_start); + curr_timing->start_time = timespec_to_usec_ull(&t_start); + curr_timing->end_time = timespec_to_usec_ull(&t_end); curr_timing->period = timespec_to_usec(&t_diff); curr_timing->duration = duration; curr_timing->perf = perf; diff --git a/src/rt-app_types.h b/src/rt-app_types.h index fd29a06..cefb3a6 100644 --- a/src/rt-app_types.h +++ b/src/rt-app_types.h @@ -172,9 +172,9 @@ typedef struct _timing_point_t { unsigned long perf; unsigned long duration; unsigned long period; - unsigned long start_time; - unsigned long end_time; - unsigned long rel_start_time; + __u64 start_time; + __u64 end_time; + __u64 rel_start_time; } timing_point_t; #endif // _RTAPP_TYPES_H_ diff --git a/src/rt-app_utils.c b/src/rt-app_utils.c index af3ce71..c4840db 100644 --- a/src/rt-app_utils.c +++ b/src/rt-app_utils.c @@ -21,22 +21,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "rt-app_utils.h" -unsigned int -timespec_to_msec(struct timespec *ts) -{ - return (ts->tv_sec * 1E9 + ts->tv_nsec) / 1000000; -} - -long -timespec_to_lusec(struct timespec *ts) +unsigned long +timespec_to_usec(struct timespec *ts) { - return round((ts->tv_sec * 1E9 + ts->tv_nsec) / 1000.0); + return lround((ts->tv_sec * 1E9 + ts->tv_nsec) / 1000.0); } -unsigned long -timespec_to_usec(struct timespec *ts) +unsigned long long +timespec_to_usec_ull(struct timespec *ts) { - return round((ts->tv_sec * 1E9 + ts->tv_nsec) / 1000.0); + return llround((ts->tv_sec * 1E9 + ts->tv_nsec) / 1000.0); } #ifdef DLSCHED @@ -138,7 +132,7 @@ void log_timing(FILE *handler, timing_point_t *t) { fprintf(handler, - "%d\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu", + "%d\t%lu\t%lu\t%lu\t%llu\t%llu\t%llu", t->ind, t->perf, t->duration, diff --git a/src/rt-app_utils.h b/src/rt-app_utils.h index a8b66cc..64f97f6 100644 --- a/src/rt-app_utils.h +++ b/src/rt-app_utils.h @@ -83,15 +83,12 @@ do { \ rtapp_log_to(stderr, LOG_LEVEL_CRITICAL, "<crit> ", msg, ##args); \ } while (0); -unsigned int -timespec_to_msec(struct timespec *ts); - -long -timespec_to_lusec(struct timespec *ts); - unsigned long timespec_to_usec(struct timespec *ts); +unsigned long long +timespec_to_usec_ull(struct timespec *ts); + struct timespec usec_to_timespec(unsigned long usec); |