Skip to content

Commit f718b09

Browse files
Algodev-githubaxboe
authored andcommitted
block, bfq: do not plug I/O for bfq_queues with no proc refs
Commit 478de33 ("block, bfq: deschedule empty bfq_queues not referred by any process") fixed commit 3726112 ("block, bfq: re-schedule empty queues if they deserve I/O plugging") by descheduling an empty bfq_queue when it remains with not process reference. Yet, this still left a case uncovered: an empty bfq_queue with not process reference that remains in service. This happens for an in-service sync bfq_queue that is deemed to deserve I/O-dispatch plugging when it remains empty. Yet no new requests will arrive for such a bfq_queue if no process sends requests to it any longer. Even worse, the bfq_queue may happen to be prematurely freed while still in service (because there may remain no reference to it any longer). This commit solves this problem by preventing I/O dispatch from being plugged for the in-service bfq_queue, if the latter has no process reference (the bfq_queue is then prevented from remaining in service). Fixes: 3726112 ("block, bfq: re-schedule empty queues if they deserve I/O plugging") Tested-by: Oleksandr Natalenko <[email protected]> Reported-by: Patrick Dung <[email protected]> Tested-by: Patrick Dung <[email protected]> Signed-off-by: Paolo Valente <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 49d08d5 commit f718b09

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

block/bfq-iosched.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3443,6 +3443,10 @@ static void bfq_dispatch_remove(struct request_queue *q, struct request *rq)
34433443
static bool idling_needed_for_service_guarantees(struct bfq_data *bfqd,
34443444
struct bfq_queue *bfqq)
34453445
{
3446+
/* No point in idling for bfqq if it won't get requests any longer */
3447+
if (unlikely(!bfqq_process_refs(bfqq)))
3448+
return false;
3449+
34463450
return (bfqq->wr_coeff > 1 &&
34473451
(bfqd->wr_busy_queues <
34483452
bfq_tot_busy_queues(bfqd) ||
@@ -4076,6 +4080,10 @@ static bool idling_boosts_thr_without_issues(struct bfq_data *bfqd,
40764080
bfqq_sequential_and_IO_bound,
40774081
idling_boosts_thr;
40784082

4083+
/* No point in idling for bfqq if it won't get requests any longer */
4084+
if (unlikely(!bfqq_process_refs(bfqq)))
4085+
return false;
4086+
40794087
bfqq_sequential_and_IO_bound = !BFQQ_SEEKY(bfqq) &&
40804088
bfq_bfqq_IO_bound(bfqq) && bfq_bfqq_has_short_ttime(bfqq);
40814089

@@ -4169,6 +4177,10 @@ static bool bfq_better_to_idle(struct bfq_queue *bfqq)
41694177
struct bfq_data *bfqd = bfqq->bfqd;
41704178
bool idling_boosts_thr_with_no_issue, idling_needed_for_service_guar;
41714179

4180+
/* No point in idling for bfqq if it won't get requests any longer */
4181+
if (unlikely(!bfqq_process_refs(bfqq)))
4182+
return false;
4183+
41724184
if (unlikely(bfqd->strict_guarantees))
41734185
return true;
41744186

0 commit comments

Comments
 (0)