Skip to content

Commit 98fa7a3

Browse files
TheJenaaxboe
authored andcommitted
block, bfq: fix asymmetric scenarios detection
Since commit 2d29c9f ("block, bfq: improve asymmetric scenarios detection"), a scenario is defined asymmetric when one of the following conditions holds: - active bfq_queues have different weights - one or more group of entities (bfq_queue or other groups of entities) are active bfq grants fairness and low latency also in such asymmetric scenarios, by plugging the dispatching of I/O if the bfq_queue in service happens to be temporarily idle. This plugging may lower throughput, so it is important to do it only when strictly needed. By mistake, in commit '2d29c9f89fcd' ("block, bfq: improve asymmetric scenarios detection") the num_active_groups counter was firstly incremented and subsequently decremented at any entity (group or bfq_queue) weight change. This is useless, because only transitions from active to inactive and vice versa matter for that counter. Unfortunately this is also incorrect in the following case: the entity at issue is a bfq_queue and it is under weight raising. In fact in this case there is a spurious increment of the num_active_groups counter. This spurious increment may cause scenarios to be wrongly detected as asymmetric, thus causing useless plugging and loss of throughput. This commit fixes this issue by simply removing the above useless and wrong increments and decrements. Fixes: 2d29c9f ("block, bfq: improve asymmetric scenarios detection") Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name> Signed-off-by: Federico Motta <federico@willer.it> Signed-off-by: Paolo Valente <paolo.valente@linaro.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 0a40a93 commit 98fa7a3

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

block/bfq-wf2q.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -792,24 +792,18 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st,
792792
* queue, remove the entity from its old weight counter (if
793793
* there is a counter associated with the entity).
794794
*/
795-
if (prev_weight != new_weight) {
796-
if (bfqq) {
797-
root = &bfqd->queue_weights_tree;
798-
__bfq_weights_tree_remove(bfqd, bfqq, root);
799-
} else
800-
bfqd->num_active_groups--;
795+
if (prev_weight != new_weight && bfqq) {
796+
root = &bfqd->queue_weights_tree;
797+
__bfq_weights_tree_remove(bfqd, bfqq, root);
801798
}
802799
entity->weight = new_weight;
803800
/*
804801
* Add the entity, if it is not a weight-raised queue,
805802
* to the counter associated with its new weight.
806803
*/
807-
if (prev_weight != new_weight) {
808-
if (bfqq && bfqq->wr_coeff == 1) {
809-
/* If we get here, root has been initialized. */
810-
bfq_weights_tree_add(bfqd, bfqq, root);
811-
} else
812-
bfqd->num_active_groups++;
804+
if (prev_weight != new_weight && bfqq && bfqq->wr_coeff == 1) {
805+
/* If we get here, root has been initialized. */
806+
bfq_weights_tree_add(bfqd, bfqq, root);
813807
}
814808

815809
new_st->wsum += entity->weight;

0 commit comments

Comments
 (0)