t/io_uring: fix latency stats for depth == 1
authorJens Axboe <axboe@kernel.dk>
Sat, 9 Oct 2021 18:56:11 +0000 (12:56 -0600)
committerJens Axboe <axboe@kernel.dk>
Sat, 9 Oct 2021 18:56:11 +0000 (12:56 -0600)
Two issues here:

- Stat increment accounting was off-by-one, causing no stats added
  for depth == 1
- The stat batch count should be a minimum of 2, since it's really
  a mask.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/io_uring.c

index 2c9fd08c07668e3aa8a712db97fcdde82a364b76..cdd15986360ba475db3ce4afec8315784052b3b6 100644 (file)
@@ -531,8 +531,8 @@ static int reap_events_uring(struct submitter *s)
                                        stat_nr = 0;
                                }
                                last_idx = clock_index;
-                       } else if (clock_index)
-                               stat_nr++;
+                       }
+                       stat_nr++;
                }
                reaped++;
                head++;
@@ -562,6 +562,8 @@ static int submitter_init(struct submitter *s)
 
        if (stats) {
                nr_batch = roundup_pow2(depth / batch_submit);
+               if (nr_batch < 2)
+                       nr_batch = 2;
                s->clock_batch = calloc(nr_batch, sizeof(unsigned long));
                s->clock_index = 1;
 
@@ -637,8 +639,8 @@ static int reap_events_aio(struct submitter *s, struct io_event *events, int evs
                                        stat_nr = 0;
                                }
                                last_idx = clock_index;
-                       } else if (clock_index)
-                               stat_nr++;
+                       }
+                       stat_nr++;
                }
                reaped++;
                evs--;