From 2e562ab4ad1c9b73c99ec7473a997a0e57ac8392 Mon Sep 17 00:00:00 2001 From: wangdi Date: Mon, 23 Jan 2012 19:56:09 -0800 Subject: [PATCH] LU-1023 utils: Time counting fix for obdfilter-survey 1. Assigning the start and end time of test_brw so it can get correct time usage. 2. In mds_survey, it adds a new output line for threas utils, (Total: total xxxx threads X sec ...), and we should skip this line in get_stats(obdfilter-survey), so it can get correct min/max time. Signed-off-by: Wang Di Change-Id: I58c13bde299c254ed10e1405bfed3e1dce4ef216 Reviewed-on: http://review.whamcloud.com/1999 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre-iokit/obdfilter-survey/obdfilter-survey | 1 + lustre/utils/obd.c | 51 +++++++++++++++----------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/lustre-iokit/obdfilter-survey/obdfilter-survey b/lustre-iokit/obdfilter-survey/obdfilter-survey index 2a43d7f..896808e 100755 --- a/lustre-iokit/obdfilter-survey/obdfilter-survey +++ b/lustre-iokit/obdfilter-survey/obdfilter-survey @@ -135,6 +135,7 @@ get_stats () { gawk < $rfile \ '/^Selected device [0-9]+$/ {n = 0; next}\ /error/ {n = -1; exit}\ + /^Total/ {next}\ /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ {n++; v=strtonum($3); \ if (n == 1 || v < min) min = v;\ if (n == 1 || v > max) max = v;\ diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 52e5e67..f821810 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -631,6 +631,25 @@ static int shmem_running(void) { return (shared_data == NULL || !shared_data->stopping); } + +static void shmem_end_time_locked(void) +{ + shared_data->body.stop_barrier--; + if (shared_data->body.stop_barrier == 0) + gettimeofday(&shared_data->body.end_time, NULL); +} + +static void shmem_start_time_locked(void) +{ + shared_data->body.start_barrier--; + if (shared_data->body.start_barrier == 0) { + shmem_wakeup_all(); + gettimeofday(&shared_data->body.start_time, NULL); + } else { + shmem_wait(); + } +} + #else static int shmem_setup(void) { @@ -1334,16 +1353,7 @@ int jt_obd_md_common(int argc, char **argv, int cmd) child_base_id += (thread - 1) * \ (MAX_BASE_ID / nthreads); - shared_data->body.start_barrier--; - if (shared_data->body.start_barrier == 0) { - shmem_wakeup_all(); - - gettimeofday(&shared_data->body.start_time, NULL); - printf("%s: start at %s", jt_cmdname(argv[0]), - ctime(&shared_data->body.start_time.tv_sec)); - } else { - shmem_wait(); - } + shmem_start_time_locked(); shmem_unlock(); } #endif @@ -1472,12 +1482,7 @@ int jt_obd_md_common(int argc, char **argv, int cmd) #ifdef MAX_THREADS if (thread) { shmem_lock(); - shared_data->body.stop_barrier--; - if (shared_data->body.stop_barrier == 0) { - gettimeofday(&shared_data->body.end_time, NULL); - printf("%s: end at %s", jt_cmdname(argv[0]), - ctime(&shared_data->body.end_time.tv_sec)); - } + shmem_end_time_locked(); shmem_unlock(); } #endif @@ -2119,12 +2124,7 @@ int jt_obd_test_brw(int argc, char **argv) thr_offset += (thread - 1) * len; } - shared_data->body.start_barrier--; - if (shared_data->body.start_barrier == 0) - shmem_wakeup_all(); - else - shmem_wait(); - + shmem_start_time_locked(); shmem_unlock (); } #endif @@ -2207,6 +2207,13 @@ int jt_obd_test_brw(int argc, char **argv) ctime(&end.tv_sec)); } +#ifdef MAX_THREADS + if (thread) { + shmem_lock(); + shmem_end_time_locked(); + shmem_unlock(); + } +#endif return rc; } -- 1.8.3.1