iowatcher: Calculate ios_in_flight per trace
authorIgor Pylypiv <ipylypiv@google.com>
Mon, 7 Oct 2024 21:12:43 +0000 (21:12 +0000)
committerJens Axboe <axboe@kernel.dk>
Tue, 8 Oct 2024 13:40:39 +0000 (07:40 -0600)
When multiple trace files are passed, the generated queue depth graph
ends up adding queue depths from previous traces.

iowatcher -t blktrace1 -t blktrace2

Assuming blktrace1 has a queue depth of 8 and blktrace2 has a queue depth
of 32, the resulting graph will display blktrace1 with a queue depth of 8
and blktrace2 with a queue depth of 40 instead of 32.

Replace global ios_in_flight with a per trace ios_in_flight to show
a correct queue depth for a given trace.

Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
Link: https://lore.kernel.org/r/20241007211243.1351143-1-ipylypiv@google.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
iowatcher/blkparse.c
iowatcher/blkparse.h

index 6203854bd49c548fc851c64005e718edb1561807..0518083a108964f4b4f049115692c99260330de1 100644 (file)
@@ -41,7 +41,6 @@
 #define IO_HASH_TABLE_BITS  11
 #define IO_HASH_TABLE_SIZE (1 << IO_HASH_TABLE_BITS)
 static struct list_head io_hash_table[IO_HASH_TABLE_SIZE];
-static u64 ios_in_flight = 0;
 
 #define PROCESS_HASH_TABLE_BITS 7
 #define PROCESS_HASH_TABLE_SIZE (1 << PROCESS_HASH_TABLE_BITS)
@@ -1037,8 +1036,8 @@ void add_pending_io(struct trace *trace, struct graph_line_data *gld)
                return;
        }
        if (action == __BLK_TA_REQUEUE) {
-               if (ios_in_flight > 0)
-                       ios_in_flight--;
+               if (trace->ios_in_flight > 0)
+                       trace->ios_in_flight--;
                return;
        }
        if (action != __BLK_TA_ISSUE)
@@ -1054,10 +1053,10 @@ void add_pending_io(struct trace *trace, struct graph_line_data *gld)
        }
 
 account_io:
-       ios_in_flight++;
+       trace->ios_in_flight++;
 
        seconds = SECONDS(io->time);
-       gld->data[seconds].sum += ios_in_flight;
+       gld->data[seconds].sum += trace->ios_in_flight;
        gld->data[seconds].count++;
 
        avg = (double)gld->data[seconds].sum / gld->data[seconds].count;
@@ -1088,8 +1087,8 @@ void add_completed_io(struct trace *trace,
        if (!pio)
                return;
 
-       if (ios_in_flight > 0)
-               ios_in_flight--;
+       if (trace->ios_in_flight > 0)
+               trace->ios_in_flight--;
        if (io->time >= pio->dispatch_time) {
                latency = io->time - pio->dispatch_time;
                latency_gld->data[seconds].sum += latency;
index fce9d01ed2c6be655d2bda50db76c951b74c0bd5..f82876325ed6e33282d9ed5b414bac6db49a9337 100644 (file)
@@ -57,6 +57,7 @@ struct trace {
        int mpstat_fd;
        int mpstat_seconds;
        int mpstat_num_cpus;
+       u64 ios_in_flight;
 
        char *fio_start;
        char *fio_cur;