block: BFQ: Add several invariant checks
Subsystems (2)
PATCH 1/1 block: BFQ: Add several invariant checks
If anything goes wrong with the counters that track the number of requests, I/O locks up. Make such scenarios easier to debug by adding invariant checks for the request counters. Additionally, check that BFQ queues are empty before these are freed.
--- block/bfq-iosched.c | 9 +++++++++ 1 file changed, 9 insertions(+)
block/bfq-iosched.c +9 -0
@@ -5403,6 +5403,9 @@ void bfq_put_queue(struct bfq_queue *bfqq)if (bfqq->bfqd->last_completed_rq_bfqq == bfqq) bfqq->bfqd->last_completed_rq_bfqq =NULL ; +WARN_ON_ONCE (!list_empty (&bfqq->fifo)); +WARN_ON_ONCE (!RB_EMPTY_ROOT (&bfqq->sort_list)); +kmem_cache_free (bfq_pool, bfqq);bfqg_and_blkg_put (bfqg); }
@@ -7135,6 +7138,7 @@ static void bfq_exit_queue(struct elevator_queue *e) {struct bfq_data *bfqd = e->elevator_data;struct bfq_queue *bfqq, *n; +unsigned int actuator;hrtimer_cancel (&bfqd->idle_slice_timer);
@@ -7143,6 +7147,11 @@ static void bfq_exit_queue(struct elevator_queue *e)bfq_deactivate_bfqq (bfqd, bfqq, false, false);spin_unlock_irq (&bfqd->lock); +for (actuator =0 ; actuator < bfqd->num_actuators; actuator++) +WARN_ON_ONCE (bfqd->rq_in_driver[actuator]); +WARN_ON_ONCE (bfqd->tot_rq_in_driver); +WARN_ON_ONCE (bfqq->dispatched); +hrtimer_cancel (&bfqd->idle_slice_timer);/* release oom-queue reference to root group */
Hi,
Quoted 4 lines · Bart Van Assche
If anything goes wrong with the counters that track the number of requests, I/O locks up. Make such scenarios easier to debug by adding invariant checks for the request counters. Additionally, check that BFQ queues are empty before these are freed.
Is there any real problems related to those counters?
Thanks,
Kuai
Quoted 45 lines
Cc Jan Kara <[email protected]>Cc Yu Kuai <[email protected]>Signed-off-by Bart Van Assche <[email protected]>--- block/bfq-iosched.c | 9 +++++++++ 1 file changed, 9 insertions(+)block/bfq-iosched.c +9
-0@@ -5403,6 +5403,9 @@ void bfq_put_queue(struct bfq_queue *bfqq)if (bfqq->bfqd->last_completed_rq_bfqq == bfqq) bfqq->bfqd->last_completed_rq_bfqq =NULL ; +WARN_ON_ONCE (!list_empty (&bfqq->fifo)); +WARN_ON_ONCE (!RB_EMPTY_ROOT (&bfqq->sort_list)); +kmem_cache_free (bfq_pool, bfqq);bfqg_and_blkg_put (bfqg); }@@ -7135,6 +7138,7 @@ static void bfq_exit_queue(struct elevator_queue *e) {struct bfq_data *bfqd = e->elevator_data;struct bfq_queue *bfqq, *n; +unsigned int actuator;hrtimer_cancel (&bfqd->idle_slice_timer);@@ -7143,6 +7147,11 @@ static void bfq_exit_queue(struct elevator_queue *e)bfq_deactivate_bfqq (bfqd, bfqq, false, false);spin_unlock_irq (&bfqd->lock); +for (actuator =0 ; actuator < bfqd->num_actuators; actuator++) +WARN_ON_ONCE (bfqd->rq_in_driver[actuator]); +WARN_ON_ONCE (bfqd->tot_rq_in_driver); +WARN_ON_ONCE (bfqq->dispatched); +hrtimer_cancel (&bfqd->idle_slice_timer);/* release oom-queue reference to root group */ .
Quoted 7 lines · Yu Kuai
Quoted 4 lines · Bart Van Assche
If anything goes wrong with the counters that track the number of requests, I/O locks up. Make such scenarios easier to debug by adding invariant checks for the request counters. Additionally, check that BFQ queues are empty before these are freed.
Is there any real problems related to those counters?
No, but I encountered an I/O lockup in BFQ while modifying the block layer core. This code was helpful while analyzing the lockup. All that is needed to reproduce the lockup is to call bfq_dispatch_request() and bfq_insert_requests() without calling bfq_finish_requeue_request() between these two calls.
Bart.
Quoted 6 lines · Bart Van Assche
If anything goes wrong with the counters that track the number of requests, I/O locks up. Make such scenarios easier to debug by adding invariant checks for the request counters. Additionally, check that BFQ queues are empty before these are freed.
Applied, thanks!
[1/1] block: BFQ: Add several invariant checks
commit: 3e49c1e4a6152b6ad758a28ecce8fb470f46f6ed
Best regards,
Signature · 1 line
Jens Axboe