summaryrefslogtreecommitdiff
path: root/block/mq-deadline.c
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2021-09-27 15:03:26 -0700
committerJens Axboe <axboe@kernel.dk>2021-10-18 06:17:02 -0600
commit32f64cad97187f4aed50aca3ed1b5a51a00f848b (patch)
tree625b78c6956618e99cec9bbd0c467c30b3761a0a /block/mq-deadline.c
parente2c7275dc0fe3cba6a3de5a5f4c98f923e3d9d14 (diff)
downloadlwn-32f64cad97187f4aed50aca3ed1b5a51a00f848b.tar.gz
lwn-32f64cad97187f4aed50aca3ed1b5a51a00f848b.zip
block/mq-deadline: Add an invariant check
Check a statistics invariant at module unload time. When running blktests, the invariant is verified every time a request queue is removed and hence is verified at least once per test. Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Reviewed-by: Niklas Cassel <Niklas.Cassel@wdc.com> Cc: Hannes Reinecke <hare@suse.de> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Link: https://lore.kernel.org/r/20210927220328.1410161-3-bvanassche@acm.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/mq-deadline.c')
-rw-r--r--block/mq-deadline.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/block/mq-deadline.c b/block/mq-deadline.c
index c27b4347ca91..2586b3f8c7e9 100644
--- a/block/mq-deadline.c
+++ b/block/mq-deadline.c
@@ -270,6 +270,12 @@ deadline_move_request(struct deadline_data *dd, struct dd_per_prio *per_prio,
deadline_remove_request(rq->q, per_prio, rq);
}
+/* Number of requests queued for a given priority level. */
+static u32 dd_queued(struct deadline_data *dd, enum dd_prio prio)
+{
+ return dd_sum(dd, inserted, prio) - dd_sum(dd, completed, prio);
+}
+
/*
* deadline_check_fifo returns 0 if there are no expired requests on the fifo,
* 1 otherwise. Requires !list_empty(&dd->fifo_list[data_dir])
@@ -539,6 +545,12 @@ static void dd_exit_sched(struct elevator_queue *e)
WARN_ON_ONCE(!list_empty(&per_prio->fifo_list[DD_READ]));
WARN_ON_ONCE(!list_empty(&per_prio->fifo_list[DD_WRITE]));
+ WARN_ONCE(dd_queued(dd, prio) != 0,
+ "statistics for priority %d: i %u m %u d %u c %u\n",
+ prio, dd_sum(dd, inserted, prio),
+ dd_sum(dd, merged, prio),
+ dd_sum(dd, dispatched, prio),
+ dd_sum(dd, completed, prio));
}
free_percpu(dd->stats);
@@ -950,12 +962,6 @@ static int dd_async_depth_show(void *data, struct seq_file *m)
return 0;
}
-/* Number of requests queued for a given priority level. */
-static u32 dd_queued(struct deadline_data *dd, enum dd_prio prio)
-{
- return dd_sum(dd, inserted, prio) - dd_sum(dd, completed, prio);
-}
-
static int dd_queued_show(void *data, struct seq_file *m)
{
struct request_queue *q = data;