@@ -557,6 +557,7 @@ static void bfq_pd_init(struct blkg_policy_data *pd)
*/
bfqg->bfqd = bfqd;
bfqg->active_entities = 0;
+ bfqg->num_entities_with_pending_reqs = 0;
bfqg->rq_pos_tree = RB_ROOT;
}
@@ -928,6 +928,13 @@ void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq,
inc_counter:
bfqq->weight_counter->num_active++;
bfqq->ref++;
+
+#ifdef CONFIG_BFQ_GROUP_IOSCHED
+ if (!entity->in_groups_with_pending_reqs) {
+ entity->in_groups_with_pending_reqs = true;
+ bfqq_group(bfqq)->num_entities_with_pending_reqs++;
+ }
+#endif
}
/*
@@ -944,6 +951,14 @@ void __bfq_weights_tree_remove(struct bfq_data *bfqd,
return;
bfqq->weight_counter->num_active--;
+
+#ifdef CONFIG_BFQ_GROUP_IOSCHED
+ if (bfqq->entity.in_groups_with_pending_reqs) {
+ bfqq->entity.in_groups_with_pending_reqs = false;
+ bfqq_group(bfqq)->num_entities_with_pending_reqs--;
+ }
+#endif
+
if (bfqq->weight_counter->num_active > 0)
goto reset_entity_pointer;
@@ -940,6 +940,7 @@ struct bfq_group {
struct bfq_entity *my_entity;
int active_entities;
+ int num_entities_with_pending_reqs;
struct rb_root rq_pos_tree;
Prepare to decrease 'num_groups_with_pending_reqs' earlier. bfqq will be inserted to weights_tree when new io is inserted to it, and bfqq will be removed from weights_tree when all the requests are completed. Thus use weights_tree insertion and removal to track how many queues have pending requests. Signed-off-by: Yu Kuai <yukuai3@huawei.com> --- block/bfq-cgroup.c | 1 + block/bfq-iosched.c | 15 +++++++++++++++ block/bfq-iosched.h | 1 + 3 files changed, 17 insertions(+)