mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
block, bfq: record how many queues have pending requests
Prepare to refactor the counting of 'num_groups_with_pending_reqs'. Add a counter in bfq_group, update it while tracking if bfqq have pending requests and when bfq_bfqq_move() is called. 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-3-yukuai1@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
@@ -552,6 +552,7 @@ static void bfq_pd_init(struct blkg_policy_data *pd)
|
|||||||
*/
|
*/
|
||||||
bfqg->bfqd = bfqd;
|
bfqg->bfqd = bfqd;
|
||||||
bfqg->active_entities = 0;
|
bfqg->active_entities = 0;
|
||||||
|
bfqg->num_queues_with_pending_reqs = 0;
|
||||||
bfqg->online = true;
|
bfqg->online = true;
|
||||||
bfqg->rq_pos_tree = RB_ROOT;
|
bfqg->rq_pos_tree = RB_ROOT;
|
||||||
}
|
}
|
||||||
@@ -641,6 +642,7 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
|
|||||||
{
|
{
|
||||||
struct bfq_entity *entity = &bfqq->entity;
|
struct bfq_entity *entity = &bfqq->entity;
|
||||||
struct bfq_group *old_parent = bfqq_group(bfqq);
|
struct bfq_group *old_parent = bfqq_group(bfqq);
|
||||||
|
bool has_pending_reqs = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No point to move bfqq to the same group, which can happen when
|
* No point to move bfqq to the same group, which can happen when
|
||||||
@@ -661,6 +663,11 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
|
|||||||
*/
|
*/
|
||||||
bfqq->ref++;
|
bfqq->ref++;
|
||||||
|
|
||||||
|
if (entity->in_groups_with_pending_reqs) {
|
||||||
|
has_pending_reqs = true;
|
||||||
|
bfq_del_bfqq_in_groups_with_pending_reqs(bfqq);
|
||||||
|
}
|
||||||
|
|
||||||
/* If bfqq is empty, then bfq_bfqq_expire also invokes
|
/* If bfqq is empty, then bfq_bfqq_expire also invokes
|
||||||
* bfq_del_bfqq_busy, thereby removing bfqq and its entity
|
* bfq_del_bfqq_busy, thereby removing bfqq and its entity
|
||||||
* from data structures related to current group. Otherwise we
|
* from data structures related to current group. Otherwise we
|
||||||
@@ -688,6 +695,9 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
|
|||||||
/* pin down bfqg and its associated blkg */
|
/* pin down bfqg and its associated blkg */
|
||||||
bfqg_and_blkg_get(bfqg);
|
bfqg_and_blkg_get(bfqg);
|
||||||
|
|
||||||
|
if (has_pending_reqs)
|
||||||
|
bfq_add_bfqq_in_groups_with_pending_reqs(bfqq);
|
||||||
|
|
||||||
if (bfq_bfqq_busy(bfqq)) {
|
if (bfq_bfqq_busy(bfqq)) {
|
||||||
if (unlikely(!bfqd->nonrot_with_queueing))
|
if (unlikely(!bfqd->nonrot_with_queueing))
|
||||||
bfq_pos_tree_add_move(bfqd, bfqq);
|
bfq_pos_tree_add_move(bfqd, bfqq);
|
||||||
|
|||||||
@@ -939,6 +939,7 @@ struct bfq_group {
|
|||||||
struct bfq_entity *my_entity;
|
struct bfq_entity *my_entity;
|
||||||
|
|
||||||
int active_entities;
|
int active_entities;
|
||||||
|
int num_queues_with_pending_reqs;
|
||||||
|
|
||||||
struct rb_root rq_pos_tree;
|
struct rb_root rq_pos_tree;
|
||||||
|
|
||||||
|
|||||||
@@ -1650,16 +1650,24 @@ void bfq_add_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq)
|
|||||||
{
|
{
|
||||||
struct bfq_entity *entity = &bfqq->entity;
|
struct bfq_entity *entity = &bfqq->entity;
|
||||||
|
|
||||||
if (!entity->in_groups_with_pending_reqs)
|
if (!entity->in_groups_with_pending_reqs) {
|
||||||
entity->in_groups_with_pending_reqs = true;
|
entity->in_groups_with_pending_reqs = true;
|
||||||
|
#ifdef CONFIG_BFQ_GROUP_IOSCHED
|
||||||
|
bfqq_group(bfqq)->num_queues_with_pending_reqs++;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bfq_del_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq)
|
void bfq_del_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq)
|
||||||
{
|
{
|
||||||
struct bfq_entity *entity = &bfqq->entity;
|
struct bfq_entity *entity = &bfqq->entity;
|
||||||
|
|
||||||
if (entity->in_groups_with_pending_reqs)
|
if (entity->in_groups_with_pending_reqs) {
|
||||||
entity->in_groups_with_pending_reqs = false;
|
entity->in_groups_with_pending_reqs = false;
|
||||||
|
#ifdef CONFIG_BFQ_GROUP_IOSCHED
|
||||||
|
bfqq_group(bfqq)->num_queues_with_pending_reqs--;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user