OSDN Git Service

Add an option to explicitly specify blockdev.
authorMohan Srinivasan <srmohan@google.com>
Wed, 12 Jul 2017 21:03:16 +0000 (14:03 -0700)
committerMohan Srinivasan <srmohan@google.com>
Wed, 12 Jul 2017 21:04:14 +0000 (14:04 -0700)
Add a -b option, that allows user to explicitly specify a blockdev
that we want to get stats out of. For example, this allows us to
specify the userdata partition (on which IOshark runs). Or in the rare
case where support for a new device has not been added yet, we can
still run IOshark on it by using this option.

Test: Run IOshark with the -b option passed in and verify that the
device stats reported match with /proc/diskstats.

Change-Id: Ic835697a6aae4484c95537e7d489a9c1fefc0110
Signed-off-by: Mohan Srinivasan <srmohan@google.com>
ioshark/README
ioshark/ioshark_bench.c
ioshark/ioshark_bench_subr.c

index 0c50fec..f71a260 100644 (file)
@@ -19,6 +19,8 @@ files into a wl.tar file.
 device (on /data/local/tmp say). Explode the tarfile.
 - Run the tester. "ioshark_bench *.wl" runs the test with default
 options. Supported ioshark_bench options :
+-b : Explicitly specify a blockdev (to get IO stats from from
+/proc/diskstats).
 -d : Preserve the delays between successive filesystem syscalls as
 seen in the original straces.
 -n <N> : Run for N iterations
index f44e73e..7593394 100644 (file)
@@ -68,6 +68,7 @@ int do_delay = 0;
 int verbose = 0;
 int summary_mode = 0;
 int quick_mode = 0;
+char *blockdev_name = NULL;    /* if user would like to specify blockdev */
 
 #if 0
 static long gettid()
@@ -78,7 +79,7 @@ static long gettid()
 
 void usage()
 {
-       fprintf(stderr, "%s [-d preserve_delays] [-n num_iterations] [-t num_threads] -q -v | -s <list of parsed input files>\n",
+       fprintf(stderr, "%s [-b blockdev_name] [-d preserve_delays] [-n num_iterations] [-t num_threads] -q -v | -s <list of parsed input files>\n",
                progname);
        fprintf(stderr, "%s -s, -v are mutually exclusive\n",
                progname);
@@ -661,8 +662,11 @@ main(int argc, char **argv)
        struct thread_state_s *state;
 
        progname = argv[0];
-        while ((c = getopt(argc, argv, "dn:st:qv")) != EOF) {
+        while ((c = getopt(argc, argv, "b:dn:st:qv")) != EOF) {
                 switch (c) {
+                case 'b':
+                       blockdev_name = strdup(optarg);
+                       break;
                 case 'd':
                        do_delay = 1;
                        break;
index 4280a5a..e8e93c9 100644 (file)
@@ -375,6 +375,8 @@ get_cores(void)
 }
 #endif
 
+extern char *blockdev_name;
+
 static void
 get_blockdev_name(char *bdev)
 {
@@ -402,9 +404,11 @@ get_blockdev_name(char *bdev)
        } else if (strncmp(dev_name, "marlin", strlen("marlin")) == 0 ||
                   strncmp(dev_name, "sailfish", strlen("sailfish")) == 0) {
                strcpy(bdev, "sda");
+       } else if (blockdev_name != NULL) {
+               strcpy(bdev, blockdev_name);
        } else {
                fprintf(stderr,
-                       "%s: Unknown device %s\n",
+                       "%s: Unknown device %s, please specify block device name with -b\n",
                        progname, dev_name);
                exit(1);
        }