mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-09-01 06:39:05 +00:00
block, bfq: cleanup bfq_weights_tree add/remove apis
The 'bfq_data' and 'rb_root_cached' can both be accessed through 'bfq_queue', thus only pass 'bfq_queue' as parameter. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Acked-by: Paolo Valente <paolo.valente@linaro.org> Link: https://lore.kernel.org/r/20220916071942.214222-6-yukuai1@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
eed3ecc991
commit
afdba14612
@ -870,9 +870,9 @@ static bool bfq_asymmetric_scenario(struct bfq_data *bfqd,
|
|||||||
* In most scenarios, the rate at which nodes are created/destroyed
|
* In most scenarios, the rate at which nodes are created/destroyed
|
||||||
* should be low too.
|
* should be low too.
|
||||||
*/
|
*/
|
||||||
void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq,
|
void bfq_weights_tree_add(struct bfq_queue *bfqq)
|
||||||
struct rb_root_cached *root)
|
|
||||||
{
|
{
|
||||||
|
struct rb_root_cached *root = &bfqq->bfqd->queue_weights_tree;
|
||||||
struct bfq_entity *entity = &bfqq->entity;
|
struct bfq_entity *entity = &bfqq->entity;
|
||||||
struct rb_node **new = &(root->rb_root.rb_node), *parent = NULL;
|
struct rb_node **new = &(root->rb_root.rb_node), *parent = NULL;
|
||||||
bool leftmost = true;
|
bool leftmost = true;
|
||||||
@ -944,13 +944,14 @@ void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq,
|
|||||||
* See the comments to the function bfq_weights_tree_add() for considerations
|
* See the comments to the function bfq_weights_tree_add() for considerations
|
||||||
* about overhead.
|
* about overhead.
|
||||||
*/
|
*/
|
||||||
void __bfq_weights_tree_remove(struct bfq_data *bfqd,
|
void __bfq_weights_tree_remove(struct bfq_queue *bfqq)
|
||||||
struct bfq_queue *bfqq,
|
|
||||||
struct rb_root_cached *root)
|
|
||||||
{
|
{
|
||||||
|
struct rb_root_cached *root;
|
||||||
|
|
||||||
if (!bfqq->weight_counter)
|
if (!bfqq->weight_counter)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
root = &bfqq->bfqd->queue_weights_tree;
|
||||||
bfqq->weight_counter->num_active--;
|
bfqq->weight_counter->num_active--;
|
||||||
if (bfqq->weight_counter->num_active > 0)
|
if (bfqq->weight_counter->num_active > 0)
|
||||||
goto reset_entity_pointer;
|
goto reset_entity_pointer;
|
||||||
@ -967,11 +968,9 @@ void __bfq_weights_tree_remove(struct bfq_data *bfqd,
|
|||||||
* Invoke __bfq_weights_tree_remove on bfqq and decrement the number
|
* Invoke __bfq_weights_tree_remove on bfqq and decrement the number
|
||||||
* of active groups for each queue's inactive parent entity.
|
* of active groups for each queue's inactive parent entity.
|
||||||
*/
|
*/
|
||||||
void bfq_weights_tree_remove(struct bfq_data *bfqd,
|
void bfq_weights_tree_remove(struct bfq_queue *bfqq)
|
||||||
struct bfq_queue *bfqq)
|
|
||||||
{
|
{
|
||||||
__bfq_weights_tree_remove(bfqd, bfqq,
|
__bfq_weights_tree_remove(bfqq);
|
||||||
&bfqd->queue_weights_tree);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6220,7 +6219,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_del_bfqq_in_groups_with_pending_reqs(bfqq);
|
||||||
bfq_weights_tree_remove(bfqd, bfqq);
|
bfq_weights_tree_remove(bfqq);
|
||||||
}
|
}
|
||||||
|
|
||||||
now_ns = ktime_get_ns();
|
now_ns = ktime_get_ns();
|
||||||
|
@ -969,13 +969,9 @@ struct bfq_queue *bic_to_bfqq(struct bfq_io_cq *bic, bool is_sync);
|
|||||||
void bic_set_bfqq(struct bfq_io_cq *bic, struct bfq_queue *bfqq, bool is_sync);
|
void bic_set_bfqq(struct bfq_io_cq *bic, struct bfq_queue *bfqq, bool is_sync);
|
||||||
struct bfq_data *bic_to_bfqd(struct bfq_io_cq *bic);
|
struct bfq_data *bic_to_bfqd(struct bfq_io_cq *bic);
|
||||||
void bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq);
|
void bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq);
|
||||||
void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq,
|
void bfq_weights_tree_add(struct bfq_queue *bfqq);
|
||||||
struct rb_root_cached *root);
|
void __bfq_weights_tree_remove(struct bfq_queue *bfqq);
|
||||||
void __bfq_weights_tree_remove(struct bfq_data *bfqd,
|
void bfq_weights_tree_remove(struct bfq_queue *bfqq);
|
||||||
struct bfq_queue *bfqq,
|
|
||||||
struct rb_root_cached *root);
|
|
||||||
void bfq_weights_tree_remove(struct bfq_data *bfqd,
|
|
||||||
struct bfq_queue *bfqq);
|
|
||||||
void bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq,
|
void bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq,
|
||||||
bool compensate, enum bfqq_expiration reason);
|
bool compensate, enum bfqq_expiration reason);
|
||||||
void bfq_put_queue(struct bfq_queue *bfqq);
|
void bfq_put_queue(struct bfq_queue *bfqq);
|
||||||
|
@ -707,7 +707,6 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st,
|
|||||||
struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity);
|
struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity);
|
||||||
unsigned int prev_weight, new_weight;
|
unsigned int prev_weight, new_weight;
|
||||||
struct bfq_data *bfqd = NULL;
|
struct bfq_data *bfqd = NULL;
|
||||||
struct rb_root_cached *root;
|
|
||||||
#ifdef CONFIG_BFQ_GROUP_IOSCHED
|
#ifdef CONFIG_BFQ_GROUP_IOSCHED
|
||||||
struct bfq_sched_data *sd;
|
struct bfq_sched_data *sd;
|
||||||
struct bfq_group *bfqg;
|
struct bfq_group *bfqg;
|
||||||
@ -770,19 +769,15 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st,
|
|||||||
* queue, remove the entity from its old weight counter (if
|
* queue, remove the entity from its old weight counter (if
|
||||||
* there is a counter associated with the entity).
|
* there is a counter associated with the entity).
|
||||||
*/
|
*/
|
||||||
if (prev_weight != new_weight && bfqq) {
|
if (prev_weight != new_weight && bfqq)
|
||||||
root = &bfqd->queue_weights_tree;
|
__bfq_weights_tree_remove(bfqq);
|
||||||
__bfq_weights_tree_remove(bfqd, bfqq, root);
|
|
||||||
}
|
|
||||||
entity->weight = new_weight;
|
entity->weight = new_weight;
|
||||||
/*
|
/*
|
||||||
* Add the entity, if it is not a weight-raised queue,
|
* Add the entity, if it is not a weight-raised queue,
|
||||||
* to the counter associated with its new weight.
|
* to the counter associated with its new weight.
|
||||||
*/
|
*/
|
||||||
if (prev_weight != new_weight && bfqq && bfqq->wr_coeff == 1) {
|
if (prev_weight != new_weight && bfqq && bfqq->wr_coeff == 1)
|
||||||
/* If we get here, root has been initialized. */
|
bfq_weights_tree_add(bfqq);
|
||||||
bfq_weights_tree_add(bfqd, bfqq, root);
|
|
||||||
}
|
|
||||||
|
|
||||||
new_st->wsum += entity->weight;
|
new_st->wsum += entity->weight;
|
||||||
|
|
||||||
@ -1687,7 +1682,7 @@ void bfq_del_bfqq_busy(struct bfq_queue *bfqq, bool expiration)
|
|||||||
* Next function is invoked last, because it causes bfqq to be
|
* Next function is invoked last, because it causes bfqq to be
|
||||||
* freed. DO NOT use bfqq after the next function invocation.
|
* freed. DO NOT use bfqq after the next function invocation.
|
||||||
*/
|
*/
|
||||||
bfq_weights_tree_remove(bfqd, bfqq);
|
bfq_weights_tree_remove(bfqq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1708,8 +1703,7 @@ void bfq_add_bfqq_busy(struct bfq_queue *bfqq)
|
|||||||
if (!bfqq->dispatched) {
|
if (!bfqq->dispatched) {
|
||||||
bfq_add_bfqq_in_groups_with_pending_reqs(bfqq);
|
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(bfqq);
|
||||||
&bfqd->queue_weights_tree);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bfqq->wr_coeff > 1)
|
if (bfqq->wr_coeff > 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user