Whamcloud - gitweb
LU-1023 utils: Time counting fix for obdfilter-survey
authorwangdi <di.wang@whamcloud.com>
Tue, 24 Jan 2012 03:56:09 +0000 (19:56 -0800)
committerOleg Drokin <green@whamcloud.com>
Sun, 5 Feb 2012 02:30:33 +0000 (21:30 -0500)
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 <di.wang@whamcloud.com>
Change-Id: I58c13bde299c254ed10e1405bfed3e1dce4ef216
Reviewed-on: http://review.whamcloud.com/1999
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre-iokit/obdfilter-survey/obdfilter-survey
lustre/utils/obd.c

index 2a43d7f..896808e 100755 (executable)
@@ -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;\
index 52e5e67..f821810 100644 (file)
@@ -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;
 }