iowatcher: Add option to set action which should be displayed in the IO graph
authorJan Kara <jack@suse.cz>
Thu, 6 Sep 2012 16:23:05 +0000 (18:23 +0200)
committerChris Mason <chris.mason@oracle.com>
Tue, 11 Sep 2012 00:53:05 +0000 (20:53 -0400)
Sometimes this is useful to see how IO scheduler or storage itself
changes the IO submitted by the application.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
iowatcher/blkparse.c
iowatcher/blkparse.h
iowatcher/main.c

index ab7a637d06348b045eecf12e175569ec425a39fa..a0fb8c54034115c3d47e1edd318662496cf34fb1 100644 (file)
@@ -41,6 +41,7 @@
 static struct list_head io_hash_table[IO_HASH_TABLE_SIZE];
 static u64 ios_in_flight = 0;
 
+extern int plot_io_action;
 
 /*
  * Trace categories
@@ -613,8 +614,23 @@ static inline int tput_event(struct trace *trace)
        return __BLK_TA_COMPLETE;
 }
 
+int action_char_to_num(char action)
+{
+       switch (action) {
+       case 'Q':
+               return __BLK_TA_QUEUE;
+       case 'D':
+               return __BLK_TA_ISSUE;
+       case 'C':
+               return __BLK_TA_COMPLETE;
+       }
+       return -1;
+}
+
 static inline int io_event(struct trace *trace)
 {
+       if (plot_io_action)
+               return plot_io_action;
        if (trace->found_queue)
                return __BLK_TA_QUEUE;
        if (trace->found_issue)
index 2eff331c9f940e9fc9b0dcdde600a766e9c90ce6..6300ceda4a0a15ff88d92b746decc0e65751c145 100644 (file)
@@ -67,6 +67,7 @@ void find_extreme_offsets(struct trace *trace, u64 *min_ret, u64 *max_ret,
                          u64 *max_bank_ret, u64 *max_offset_ret);
 int filter_outliers(struct trace *trace, u64 min_offset, u64 max_offset,
                    u64 *yzoom_min, u64 *yzoom_max);
+int action_char_to_num(char action);
 void add_iop(struct trace *trace, struct graph_line_data *gld);
 void check_record(struct trace *trace);
 void add_completed_io(struct trace *trace,
index a3148acf73bdf6d14f7910c89c28f51816aaf5a6..6d112be8fbacdc90552549f262d13a0ddf500462 100644 (file)
@@ -59,6 +59,8 @@ static double max_time = DBL_MAX;
 static unsigned long long min_mb = 0;
 static unsigned long long max_mb = ULLONG_MAX >> 20;
 
+int plot_io_action = 0;
+
 /*
  * this doesn't include the IO graph,
  * but it counts the other graphs as they go out
@@ -1025,7 +1027,7 @@ enum {
        HELP_LONG_OPT = 1,
 };
 
-char *option_string = "T:t:o:l:r:O:N:d:p:m::h:w:c:x:y:";
+char *option_string = "T:t:o:l:r:O:N:d:p:m::h:w:c:x:y:a:";
 static struct option long_options[] = {
        {"columns", required_argument, 0, 'c'},
        {"title", required_argument, 0, 'T'},
@@ -1042,6 +1044,7 @@ static struct option long_options[] = {
        {"height", required_argument, 0, 'h'},
        {"xzoom", required_argument, 0, 'x'},
        {"yzoom", required_argument, 0, 'y'},
+       {"io-plot-action", required_argument, 0, 'a'},
        {"help", no_argument, 0, HELP_LONG_OPT},
        {0, 0, 0, 0}
 };
@@ -1065,6 +1068,7 @@ static void print_usage(void)
                "\t-c (--columns): numbers of columns in graph output\n"
                "\t-x (--xzoom): limit processed time to min:max\n"
                "\t-y (--yzoom): limit processed sectors to min:max\n"
+               "\t-a (--io-plot-action): plot given action (one of Q,D,C) in IO graph\n"
               );
        exit(1);
 }
@@ -1214,6 +1218,16 @@ static int parse_options(int ac, char **av)
                                exit(1);
                        }
                        break;
+               case 'a':
+                       if (strlen(optarg) != 1) {
+action_err:
+                               fprintf(stderr, "Action must be one of Q, D, C.");
+                               exit(1);
+                       }
+                       plot_io_action = action_char_to_num(optarg[0]);
+                       if (plot_io_action < 0)
+                               goto action_err;
+                       break;
                case '?':
                case HELP_LONG_OPT:
                        print_usage();