Commit 3d89bd12 authored by Yu Kuai's avatar Yu Kuai Committed by Jens Axboe

block, bfq: support to track if bfqq has pending requests

If entity belongs to bfqq, then entity->in_groups_with_pending_reqs
is not used currently. This patch use it to track if bfqq has pending
requests through callers of weights_tree insertion and removal.
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Acked-by: default avatarPaolo Valente <paolo.valente@linaro.org>
Link: https://lore.kernel.org/r/20220916071942.214222-2-yukuai1@huaweicloud.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 56c1ee92
...@@ -6261,6 +6261,7 @@ static void bfq_completed_request(struct bfq_queue *bfqq, struct bfq_data *bfqd) ...@@ -6261,6 +6261,7 @@ static void bfq_completed_request(struct bfq_queue *bfqq, struct bfq_data *bfqd)
*/ */
bfqq->budget_timeout = jiffies; bfqq->budget_timeout = jiffies;
bfq_del_bfqq_in_groups_with_pending_reqs(bfqq);
bfq_weights_tree_remove(bfqd, bfqq); bfq_weights_tree_remove(bfqd, bfqq);
} }
......
...@@ -1078,6 +1078,8 @@ void bfq_requeue_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, ...@@ -1078,6 +1078,8 @@ void bfq_requeue_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq,
bool expiration); bool expiration);
void bfq_del_bfqq_busy(struct bfq_queue *bfqq, bool expiration); void bfq_del_bfqq_busy(struct bfq_queue *bfqq, bool expiration);
void bfq_add_bfqq_busy(struct bfq_queue *bfqq); void bfq_add_bfqq_busy(struct bfq_queue *bfqq);
void bfq_add_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq);
void bfq_del_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq);
/* --------------- end of interface of B-WF2Q+ ---------------- */ /* --------------- end of interface of B-WF2Q+ ---------------- */
......
...@@ -1646,6 +1646,22 @@ void bfq_requeue_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, ...@@ -1646,6 +1646,22 @@ void bfq_requeue_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq,
bfqq == bfqd->in_service_queue, expiration); bfqq == bfqd->in_service_queue, expiration);
} }
void bfq_add_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq)
{
struct bfq_entity *entity = &bfqq->entity;
if (!entity->in_groups_with_pending_reqs)
entity->in_groups_with_pending_reqs = true;
}
void bfq_del_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq)
{
struct bfq_entity *entity = &bfqq->entity;
if (entity->in_groups_with_pending_reqs)
entity->in_groups_with_pending_reqs = false;
}
/* /*
* Called when the bfqq no longer has requests pending, remove it from * Called when the bfqq no longer has requests pending, remove it from
* the service tree. As a special case, it can be invoked during an * the service tree. As a special case, it can be invoked during an
...@@ -1668,8 +1684,10 @@ void bfq_del_bfqq_busy(struct bfq_queue *bfqq, bool expiration) ...@@ -1668,8 +1684,10 @@ void bfq_del_bfqq_busy(struct bfq_queue *bfqq, bool expiration)
bfq_deactivate_bfqq(bfqd, bfqq, true, expiration); bfq_deactivate_bfqq(bfqd, bfqq, true, expiration);
if (!bfqq->dispatched) if (!bfqq->dispatched) {
bfq_del_bfqq_in_groups_with_pending_reqs(bfqq);
bfq_weights_tree_remove(bfqd, bfqq); bfq_weights_tree_remove(bfqd, bfqq);
}
} }
/* /*
...@@ -1686,10 +1704,12 @@ void bfq_add_bfqq_busy(struct bfq_queue *bfqq) ...@@ -1686,10 +1704,12 @@ void bfq_add_bfqq_busy(struct bfq_queue *bfqq)
bfq_mark_bfqq_busy(bfqq); bfq_mark_bfqq_busy(bfqq);
bfqd->busy_queues[bfqq->ioprio_class - 1]++; bfqd->busy_queues[bfqq->ioprio_class - 1]++;
if (!bfqq->dispatched) if (!bfqq->dispatched) {
bfq_add_bfqq_in_groups_with_pending_reqs(bfqq);
if (bfqq->wr_coeff == 1) if (bfqq->wr_coeff == 1)
bfq_weights_tree_add(bfqd, bfqq, bfq_weights_tree_add(bfqd, bfqq,
&bfqd->queue_weights_tree); &bfqd->queue_weights_tree);
}
if (bfqq->wr_coeff > 1) if (bfqq->wr_coeff > 1)
bfqd->wr_busy_queues++; bfqd->wr_busy_queues++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment