Skip to content

Commit

Permalink
block, bfq: invoke flush_idle_tree after reparent_active_queues in pd…
Browse files Browse the repository at this point in the history
…_offline

commit 4d38a87fbb77fb9ff2ff4e914162a8ae6453eff5 upstream.

In bfq_pd_offline(), the function bfq_flush_idle_tree() is invoked to
flush the rb tree that contains all idle entities belonging to the pd
(cgroup) being destroyed. In particular, bfq_flush_idle_tree() is
invoked before bfq_reparent_active_queues(). Yet the latter may happen
to add some entities to the idle tree. It happens if, in some of the
calls to bfq_bfqq_move() performed by bfq_reparent_active_queues(),
the queue to move is empty and gets expired.

This commit simply reverses the invocation order between
bfq_flush_idle_tree() and bfq_reparent_active_queues().

Tested-by: cki-project@redhat.com
Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Algodev-github authored and gregkh committed Apr 23, 2020
1 parent 839b7cd commit a362482
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions block/bfq-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,13 +876,6 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)
for (i = 0; i < BFQ_IOPRIO_CLASSES; i++) {
st = bfqg->sched_data.service_tree + i;

/*
* The idle tree may still contain bfq_queues belonging
* to exited task because they never migrated to a different
* cgroup from the one being destroyed now.
*/
bfq_flush_idle_tree(st);

/*
* It may happen that some queues are still active
* (busy) upon group destruction (if the corresponding
Expand All @@ -896,6 +889,19 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)
* scheduler has taken no reference.
*/
bfq_reparent_active_queues(bfqd, bfqg, st, i);

/*
* The idle tree may still contain bfq_queues
* belonging to exited task because they never
* migrated to a different cgroup from the one being
* destroyed now. In addition, even
* bfq_reparent_active_queues() may happen to add some
* entities to the idle tree. It happens if, in some
* of the calls to bfq_bfqq_move() performed by
* bfq_reparent_active_queues(), the queue to move is
* empty and gets expired.
*/
bfq_flush_idle_tree(st);
}

__bfq_deactivate_entity(entity, false);
Expand Down

0 comments on commit a362482

Please sign in to comment.