t/io_uring: check for valid clock_index and finish state for stats
authorJens Axboe <axboe@kernel.dk>
Mon, 4 Oct 2021 22:35:15 +0000 (16:35 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 4 Oct 2021 22:35:15 +0000 (16:35 -0600)
If the clock_index isn't non-zero, it's not valid and we should disregard
the sample. Ditto if an exit signal has been sent, we're done at that
point and aren't interested in the last samples.

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

index 2ae65bc19bb1dc487bbe176274743f6eb87e0fe6..ffdb5d3db545130f1754466f50b9ae652cde6061 100644 (file)
@@ -309,10 +309,12 @@ static void add_stat(struct submitter *s, int clock_index, int nr)
        unsigned long cycles;
        unsigned int pidx;
 
-       cycles = get_cpu_clock();
-       cycles -= s->clock_batch[clock_index];
-       pidx = plat_val_to_idx(cycles);
-       s->plat[pidx] += nr;
+       if (!s->finish && clock_index) {
+               cycles = get_cpu_clock();
+               cycles -= s->clock_batch[clock_index];
+               pidx = plat_val_to_idx(cycles);
+               s->plat[pidx] += nr;
+       }
 #endif
 }