Skip to content

Commit 6608808

Browse files
johnpgarryaxboe
authored andcommitted
block: BFQ: Refactor bfq_exit_icq() to silence sparse warning
Currently building for C=1 generates the following warning: block/bfq-iosched.c:5498:9: warning: context imbalance in 'bfq_exit_icq' - different lock contexts for basic block Refactor bfq_exit_icq() into a core part which loops for the actuators, and only lock calling this routine when necessary. Signed-off-by: John Garry <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent c3042a5 commit 6608808

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

block/bfq-iosched.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5463,40 +5463,42 @@ static void bfq_exit_icq_bfqq(struct bfq_io_cq *bic, bool is_sync,
54635463
}
54645464
}
54655465

5466+
static void _bfq_exit_icq(struct bfq_io_cq *bic, unsigned int num_actuators)
5467+
{
5468+
struct bfq_iocq_bfqq_data *bfqq_data = bic->bfqq_data;
5469+
unsigned int act_idx;
5470+
5471+
for (act_idx = 0; act_idx < num_actuators; act_idx++) {
5472+
if (bfqq_data[act_idx].stable_merge_bfqq)
5473+
bfq_put_stable_ref(bfqq_data[act_idx].stable_merge_bfqq);
5474+
5475+
bfq_exit_icq_bfqq(bic, true, act_idx);
5476+
bfq_exit_icq_bfqq(bic, false, act_idx);
5477+
}
5478+
}
5479+
54665480
static void bfq_exit_icq(struct io_cq *icq)
54675481
{
54685482
struct bfq_io_cq *bic = icq_to_bic(icq);
54695483
struct bfq_data *bfqd = bic_to_bfqd(bic);
54705484
unsigned long flags;
5471-
unsigned int act_idx;
5485+
54725486
/*
54735487
* If bfqd and thus bfqd->num_actuators is not available any
54745488
* longer, then cycle over all possible per-actuator bfqqs in
54755489
* next loop. We rely on bic being zeroed on creation, and
54765490
* therefore on its unused per-actuator fields being NULL.
5477-
*/
5478-
unsigned int num_actuators = BFQ_MAX_ACTUATORS;
5479-
struct bfq_iocq_bfqq_data *bfqq_data = bic->bfqq_data;
5480-
5481-
/*
5491+
*
54825492
* bfqd is NULL if scheduler already exited, and in that case
54835493
* this is the last time these queues are accessed.
54845494
*/
54855495
if (bfqd) {
54865496
spin_lock_irqsave(&bfqd->lock, flags);
5487-
num_actuators = bfqd->num_actuators;
5488-
}
5489-
5490-
for (act_idx = 0; act_idx < num_actuators; act_idx++) {
5491-
if (bfqq_data[act_idx].stable_merge_bfqq)
5492-
bfq_put_stable_ref(bfqq_data[act_idx].stable_merge_bfqq);
5493-
5494-
bfq_exit_icq_bfqq(bic, true, act_idx);
5495-
bfq_exit_icq_bfqq(bic, false, act_idx);
5496-
}
5497-
5498-
if (bfqd)
5497+
_bfq_exit_icq(bic, bfqd->num_actuators);
54995498
spin_unlock_irqrestore(&bfqd->lock, flags);
5499+
} else {
5500+
_bfq_exit_icq(bic, BFQ_MAX_ACTUATORS);
5501+
}
55005502
}
55015503

55025504
/*

0 commit comments

Comments
 (0)