Skip to content

Commit

Permalink
UPSTREAM: block/mq-deadline: Add an invariant check
Browse files Browse the repository at this point in the history
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.

Bug: 293845137
(cherry picked from commit 32f64cad97187f4aed50aca3ed1b5a51a00f848b)
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Niklas Cassel <Niklas.Cassel@wdc.com>
Cc: Hannes Reinecke <hare@suse.de>
Change-Id: I9bff99de736f0b18a49be9512d9123bf50a82fac
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>
Signed-off-by: Xiuhong Wang <xiuhong.wang@unisoc.com>
  • Loading branch information
bvanassche authored and drosen-google committed Sep 12, 2023
1 parent b7deb97 commit 2a8fbb9
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions block/mq-deadline.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,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])
Expand Down Expand Up @@ -598,6 +604,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);
Expand Down Expand Up @@ -1021,12 +1033,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;
Expand Down

0 comments on commit 2a8fbb9

Please sign in to comment.