From 265697fc16b767fee5fae25a73d74ec4df20d94a Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 4 Oct 2021 16:35:15 -0600 Subject: [PATCH] t/io_uring: check for valid clock_index and finish state for stats 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 --- t/io_uring.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/t/io_uring.c b/t/io_uring.c index 2ae65bc1..ffdb5d3d 100644 --- a/t/io_uring.c +++ b/t/io_uring.c @@ -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 } -- 2.25.1