]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - block/bfq-wf2q.c
arc: remove redundant GCC version checks
[linux.git] / block / bfq-wf2q.c
index 4498c43245e2d4d4168d6bb133c65980db83345c..ae52bff43ce4ff1697fdfdbc0c9c10fb4148c69e 100644 (file)
@@ -130,10 +130,14 @@ static bool bfq_update_next_in_service(struct bfq_sched_data *sd,
        if (!change_without_lookup) /* lookup needed */
                next_in_service = bfq_lookup_next_entity(sd, expiration);
 
-       if (next_in_service)
-               parent_sched_may_change = !sd->next_in_service ||
+       if (next_in_service) {
+               bool new_budget_triggers_change =
                        bfq_update_parent_budget(next_in_service);
 
+               parent_sched_may_change = !sd->next_in_service ||
+                       new_budget_triggers_change;
+       }
+
        sd->next_in_service = next_in_service;
 
        if (!next_in_service)
@@ -499,9 +503,6 @@ static void bfq_active_insert(struct bfq_service_tree *st,
        if (bfqq)
                list_add(&bfqq->bfqq_list, &bfqq->bfqd->active_list);
 #ifdef CONFIG_BFQ_GROUP_IOSCHED
-       else /* bfq_group */
-               bfq_weights_tree_add(bfqd, entity, &bfqd->group_weights_tree);
-
        if (bfqg != bfqd->root_group)
                bfqg->active_entities++;
 #endif
@@ -601,10 +602,6 @@ static void bfq_active_extract(struct bfq_service_tree *st,
        if (bfqq)
                list_del(&bfqq->bfqq_list);
 #ifdef CONFIG_BFQ_GROUP_IOSCHED
-       else /* bfq_group */
-               bfq_weights_tree_remove(bfqd, entity,
-                                       &bfqd->group_weights_tree);
-
        if (bfqg != bfqd->root_group)
                bfqg->active_entities--;
 #endif
@@ -799,7 +796,7 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st,
                if (prev_weight != new_weight) {
                        root = bfqq ? &bfqd->queue_weights_tree :
                                      &bfqd->group_weights_tree;
-                       bfq_weights_tree_remove(bfqd, entity, root);
+                       __bfq_weights_tree_remove(bfqd, entity, root);
                }
                entity->weight = new_weight;
                /*
@@ -884,15 +881,11 @@ void bfq_bfqq_charge_time(struct bfq_data *bfqd, struct bfq_queue *bfqq,
                          unsigned long time_ms)
 {
        struct bfq_entity *entity = &bfqq->entity;
-       int tot_serv_to_charge = entity->service;
-       unsigned int timeout_ms = jiffies_to_msecs(bfq_timeout);
-
-       if (time_ms > 0 && time_ms < timeout_ms)
-               tot_serv_to_charge =
-                       (bfqd->bfq_max_budget * time_ms) / timeout_ms;
-
-       if (tot_serv_to_charge < entity->service)
-               tot_serv_to_charge = entity->service;
+       unsigned long timeout_ms = jiffies_to_msecs(bfq_timeout);
+       unsigned long bounded_time_ms = min(time_ms, timeout_ms);
+       int serv_to_charge_for_time =
+               (bfqd->bfq_max_budget * bounded_time_ms) / timeout_ms;
+       int tot_serv_to_charge = max(serv_to_charge_for_time, entity->service);
 
        /* Increase budget to avoid inconsistencies */
        if (tot_serv_to_charge > entity->budget)
@@ -971,7 +964,7 @@ static void bfq_update_fin_time_enqueue(struct bfq_entity *entity,
  * one of its children receives a new request.
  *
  * Basically, this function updates the timestamps of entity and
- * inserts entity into its active tree, ater possibly extracting it
+ * inserts entity into its active tree, after possibly extracting it
  * from its idle tree.
  */
 static void __bfq_activate_entity(struct bfq_entity *entity,
@@ -1015,6 +1008,16 @@ static void __bfq_activate_entity(struct bfq_entity *entity,
                entity->on_st = true;
        }
 
+#ifdef BFQ_GROUP_IOSCHED_ENABLED
+       if (!bfq_entity_to_bfqq(entity)) { /* bfq_group */
+               struct bfq_group *bfqg =
+                       container_of(entity, struct bfq_group, entity);
+
+               bfq_weights_tree_add(bfqg->bfqd, entity,
+                                    &bfqd->group_weights_tree);
+       }
+#endif
+
        bfq_update_fin_time_enqueue(entity, st, backshifted);
 }
 
@@ -1541,12 +1544,6 @@ struct bfq_queue *bfq_get_next_queue(struct bfq_data *bfqd)
                entity = sd->next_in_service;
                sd->in_service_entity = entity;
 
-               /*
-                * Reset the accumulator of the amount of service that
-                * the entity is about to receive.
-                */
-               entity->service = 0;
-
                /*
                 * If entity is no longer a candidate for next
                 * service, then it must be extracted from its active
@@ -1664,8 +1661,7 @@ void bfq_del_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq,
        bfqd->busy_queues--;
 
        if (!bfqq->dispatched)
-               bfq_weights_tree_remove(bfqd, &bfqq->entity,
-                                       &bfqd->queue_weights_tree);
+               bfq_weights_tree_remove(bfqd, bfqq);
 
        if (bfqq->wr_coeff > 1)
                bfqd->wr_busy_queues--;