Lines Matching +full:charging +full:- +full:algorithm

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Hierarchical Budget Worst-case Fair Weighted Fair Queueing
4 * (B-WF2Q+): hierarchical scheduling algorithm by which the BFQ I/O
9 #include "bfq-iosched.h"
12 * bfq_gt - compare two timestamps.
20 return (s64)(a - b) > 0; in bfq_gt()
25 struct rb_node *node = tree->rb_node; in bfq_root_active_entity()
34 return bfqq ? bfqq->ioprio_class - 1 : in bfq_class_idx()
35 BFQ_DEFAULT_GRP_CLASS - 1; in bfq_class_idx()
40 return bfqd->busy_queues[0] + bfqd->busy_queues[1] + in bfq_tot_busy_queues()
41 bfqd->busy_queues[2]; in bfq_tot_busy_queues()
50 * bfq_update_next_in_service - update sd->next_in_service
56 * expiration of the in-service entity
58 * This function is called to update sd->next_in_service, which, in
67 * both the last two activation sub-cases, new_entity points to the
70 * Returns true if sd->next_in_service changes in such a way that
71 * entity->parent may become the next_in_service for its parent
78 struct bfq_entity *next_in_service = sd->next_in_service; in bfq_update_next_in_service()
85 * sd->next_in_service, then a full lookup in the active tree in bfq_update_next_in_service()
87 * just-modified entity has the same priority as in bfq_update_next_in_service()
88 * sd->next_in_service, is eligible and has a lower virtual in bfq_update_next_in_service()
89 * finish time than sd->next_in_service. If this compound in bfq_update_next_in_service()
93 if (new_entity && new_entity != sd->next_in_service) { in bfq_update_next_in_service()
96 * sd->next_in_service with new_entity. Tentatively in bfq_update_next_in_service()
98 * sd->next_in_service is NULL. in bfq_update_next_in_service()
105 * to replace sd->service_tree with new_entity. in bfq_update_next_in_service()
111 sd->service_tree + new_entity_class_idx; in bfq_update_next_in_service()
117 !bfq_gt(new_entity->start, st->vtime) in bfq_update_next_in_service()
119 bfq_gt(next_in_service->finish, in bfq_update_next_in_service()
120 new_entity->finish)); in bfq_update_next_in_service()
134 parent_sched_may_change = !sd->next_in_service || in bfq_update_next_in_service()
138 sd->next_in_service = next_in_service; in bfq_update_next_in_service()
146 * Returns true if this budget changes may let next_in_service->parent
156 group_sd = next_in_service->sched_data; in bfq_update_parent_budget()
162 * as it must never become an in-service entity. in bfq_update_parent_budget()
164 bfqg_entity = bfqg->my_entity; in bfq_update_parent_budget()
166 if (bfqg_entity->budget > next_in_service->budget) in bfq_update_parent_budget()
168 bfqg_entity->budget = next_in_service->budget; in bfq_update_parent_budget()
182 * about to become the in-service queue. This function then returns
190 * non-queue entity is not a candidate for next-service only if it has
192 * function returns true for a non-queue entity.
206 * not account for the in-service entity in case the latter is in bfq_no_longer_next_in_service()
215 if (bfqg->active_entities == 1) in bfq_no_longer_next_in_service()
223 struct bfq_sched_data *sd = entity->sched_data; in bfq_inc_active_entities()
226 if (bfqg != bfqg->bfqd->root_group) in bfq_inc_active_entities()
227 bfqg->active_entities++; in bfq_inc_active_entities()
232 struct bfq_sched_data *sd = entity->sched_data; in bfq_dec_active_entities()
235 if (bfqg != bfqg->bfqd->root_group) in bfq_dec_active_entities()
236 bfqg->active_entities--; in bfq_dec_active_entities()
274 if (!entity->my_sched_data) in bfq_entity_to_bfqq()
282 * bfq_delta - map service into the virtual time domain.
292 * bfq_calc_finish - assign the finish time to an entity.
300 entity->finish = entity->start + in bfq_calc_finish()
301 bfq_delta(service, entity->weight); in bfq_calc_finish()
304 bfq_log_bfqq(bfqq->bfqd, bfqq, in bfq_calc_finish()
306 service, entity->weight); in bfq_calc_finish()
307 bfq_log_bfqq(bfqq->bfqd, bfqq, in bfq_calc_finish()
309 entity->start, entity->finish, in bfq_calc_finish()
310 bfq_delta(service, entity->weight)); in bfq_calc_finish()
315 * bfq_entity_of - get an entity from a node.
334 * bfq_extract - remove an entity from a tree.
340 entity->tree = NULL; in bfq_extract()
341 rb_erase(&entity->rb_node, root); in bfq_extract()
345 * bfq_idle_extract - extract an entity from the idle tree.
355 if (entity == st->first_idle) { in bfq_idle_extract()
356 next = rb_next(&entity->rb_node); in bfq_idle_extract()
357 st->first_idle = bfq_entity_of(next); in bfq_idle_extract()
360 if (entity == st->last_idle) { in bfq_idle_extract()
361 next = rb_prev(&entity->rb_node); in bfq_idle_extract()
362 st->last_idle = bfq_entity_of(next); in bfq_idle_extract()
365 bfq_extract(&st->idle, entity); in bfq_idle_extract()
368 list_del(&bfqq->bfqq_list); in bfq_idle_extract()
372 * bfq_insert - generic tree insertion.
382 struct rb_node **node = &root->rb_node; in bfq_insert()
389 if (bfq_gt(entry->finish, entity->finish)) in bfq_insert()
390 node = &parent->rb_left; in bfq_insert()
392 node = &parent->rb_right; in bfq_insert()
395 rb_link_node(&entity->rb_node, parent, node); in bfq_insert()
396 rb_insert_color(&entity->rb_node, root); in bfq_insert()
398 entity->tree = root; in bfq_insert()
402 * bfq_update_min - update the min_start field of a entity.
417 if (bfq_gt(entity->min_start, child->min_start)) in bfq_update_min()
418 entity->min_start = child->min_start; in bfq_update_min()
423 * bfq_update_active_node - recalculate min_start.
434 entity->min_start = entity->start; in bfq_update_active_node()
435 bfq_update_min(entity, node->rb_right); in bfq_update_active_node()
436 bfq_update_min(entity, node->rb_left); in bfq_update_active_node()
440 * bfq_update_active_tree - update min_start for the whole active tree.
460 if (node == parent->rb_left && parent->rb_right) in bfq_update_active_tree()
461 bfq_update_active_node(parent->rb_right); in bfq_update_active_tree()
462 else if (parent->rb_left) in bfq_update_active_tree()
463 bfq_update_active_node(parent->rb_left); in bfq_update_active_tree()
470 * bfq_active_insert - insert an entity in the active tree of its
484 struct rb_node *node = &entity->rb_node; in bfq_active_insert()
486 bfq_insert(&st->active, entity); in bfq_active_insert()
488 if (node->rb_left) in bfq_active_insert()
489 node = node->rb_left; in bfq_active_insert()
490 else if (node->rb_right) in bfq_active_insert()
491 node = node->rb_right; in bfq_active_insert()
496 list_add(&bfqq->bfqq_list, &bfqq->bfqd->active_list[bfqq->actuator_idx]); in bfq_active_insert()
502 * bfq_ioprio_to_weight - calc a weight from an ioprio.
507 return (IOPRIO_NR_LEVELS - ioprio) * BFQ_WEIGHT_CONVERSION_COEFF; in bfq_ioprio_to_weight()
511 * bfq_weight_to_ioprio - calc an ioprio from a weight.
514 * To preserve as much as possible the old only-ioprio user interface,
521 IOPRIO_NR_LEVELS - weight / BFQ_WEIGHT_CONVERSION_COEFF); in bfq_weight_to_ioprio()
529 bfqq->ref++; in bfq_get_entity()
530 bfq_log_bfqq(bfqq->bfqd, bfqq, "get_entity: %p %d", in bfq_get_entity()
531 bfqq, bfqq->ref); in bfq_get_entity()
536 * bfq_find_deepest - find the deepest node that an extraction can modify.
548 if (!node->rb_right && !node->rb_left) in bfq_find_deepest()
550 else if (!node->rb_right) in bfq_find_deepest()
551 deepest = node->rb_left; in bfq_find_deepest()
552 else if (!node->rb_left) in bfq_find_deepest()
553 deepest = node->rb_right; in bfq_find_deepest()
556 if (deepest->rb_right) in bfq_find_deepest()
557 deepest = deepest->rb_right; in bfq_find_deepest()
566 * bfq_active_extract - remove an entity from the active tree.
576 node = bfq_find_deepest(&entity->rb_node); in bfq_active_extract()
577 bfq_extract(&st->active, entity); in bfq_active_extract()
582 list_del(&bfqq->bfqq_list); in bfq_active_extract()
588 * bfq_idle_insert - insert an entity into the idle tree.
596 struct bfq_entity *first_idle = st->first_idle; in bfq_idle_insert()
597 struct bfq_entity *last_idle = st->last_idle; in bfq_idle_insert()
599 if (!first_idle || bfq_gt(first_idle->finish, entity->finish)) in bfq_idle_insert()
600 st->first_idle = entity; in bfq_idle_insert()
601 if (!last_idle || bfq_gt(entity->finish, last_idle->finish)) in bfq_idle_insert()
602 st->last_idle = entity; in bfq_idle_insert()
604 bfq_insert(&st->idle, entity); in bfq_idle_insert()
607 list_add(&bfqq->bfqq_list, &bfqq->bfqd->idle_list); in bfq_idle_insert()
611 * bfq_forget_entity - do not consider entity any longer for scheduling
614 * @is_in_service: true if entity is currently the in-service entity.
631 entity->on_st_or_in_serv = false; in bfq_forget_entity()
632 st->wsum -= entity->weight; in bfq_forget_entity()
638 * bfq_put_idle_entity - release the idle tree ref of an entity.
646 entity == entity->sched_data->in_service_entity); in bfq_put_idle_entity()
650 * bfq_forget_idle - update the idle tree if necessary.
658 struct bfq_entity *first_idle = st->first_idle; in bfq_forget_idle()
659 struct bfq_entity *last_idle = st->last_idle; in bfq_forget_idle()
661 if (RB_EMPTY_ROOT(&st->active) && last_idle && in bfq_forget_idle()
662 !bfq_gt(last_idle->finish, st->vtime)) { in bfq_forget_idle()
667 st->vtime = last_idle->finish; in bfq_forget_idle()
670 if (first_idle && !bfq_gt(first_idle->finish, st->vtime)) in bfq_forget_idle()
676 struct bfq_sched_data *sched_data = entity->sched_data; in bfq_entity_service_tree()
679 return sched_data->service_tree + idx; in bfq_entity_service_tree()
707 if (entity->prio_changed) { in __bfq_entity_update_weight_prio()
713 old_st->wsum -= entity->weight; in __bfq_entity_update_weight_prio()
715 if (entity->new_weight != entity->orig_weight) { in __bfq_entity_update_weight_prio()
716 if (entity->new_weight < BFQ_MIN_WEIGHT || in __bfq_entity_update_weight_prio()
717 entity->new_weight > BFQ_MAX_WEIGHT) { in __bfq_entity_update_weight_prio()
719 entity->new_weight); in __bfq_entity_update_weight_prio()
720 if (entity->new_weight < BFQ_MIN_WEIGHT) in __bfq_entity_update_weight_prio()
721 entity->new_weight = BFQ_MIN_WEIGHT; in __bfq_entity_update_weight_prio()
723 entity->new_weight = BFQ_MAX_WEIGHT; in __bfq_entity_update_weight_prio()
725 entity->orig_weight = entity->new_weight; in __bfq_entity_update_weight_prio()
727 bfqq->ioprio = in __bfq_entity_update_weight_prio()
728 bfq_weight_to_ioprio(entity->orig_weight); in __bfq_entity_update_weight_prio()
732 bfqq->ioprio_class = bfqq->new_ioprio_class; in __bfq_entity_update_weight_prio()
738 if (!bfqq || bfqq->ioprio_class == bfqq->new_ioprio_class) in __bfq_entity_update_weight_prio()
739 entity->prio_changed = 0; in __bfq_entity_update_weight_prio()
746 * when entity->finish <= old_st->vtime). in __bfq_entity_update_weight_prio()
750 prev_weight = entity->weight; in __bfq_entity_update_weight_prio()
751 new_weight = entity->orig_weight * in __bfq_entity_update_weight_prio()
752 (bfqq ? bfqq->wr_coeff : 1); in __bfq_entity_update_weight_prio()
760 entity->weight = new_weight; in __bfq_entity_update_weight_prio()
762 * Add the entity, if it is not a weight-raised queue, in __bfq_entity_update_weight_prio()
765 if (prev_weight != new_weight && bfqq && bfqq->wr_coeff == 1) in __bfq_entity_update_weight_prio()
768 new_st->wsum += entity->weight; in __bfq_entity_update_weight_prio()
771 entity->start = new_st->vtime; in __bfq_entity_update_weight_prio()
778 * bfq_bfqq_served - update the scheduler status after selection for
789 struct bfq_entity *entity = &bfqq->entity; in bfq_bfqq_served()
792 if (!bfqq->service_from_backlogged) in bfq_bfqq_served()
793 bfqq->first_IO_time = jiffies; in bfq_bfqq_served()
795 if (bfqq->wr_coeff > 1) in bfq_bfqq_served()
796 bfqq->service_from_wr += served; in bfq_bfqq_served()
798 bfqq->service_from_backlogged += served; in bfq_bfqq_served()
802 entity->service += served; in bfq_bfqq_served()
804 st->vtime += bfq_delta(served, st->wsum); in bfq_bfqq_served()
807 bfq_log_bfqq(bfqq->bfqd, bfqq, "bfqq_served %d secs", served); in bfq_bfqq_served()
811 * bfq_bfqq_charge_time - charge an amount of service equivalent to the length
824 * is charging these queues with an inflated amount of service, equal
840 struct bfq_entity *entity = &bfqq->entity; in bfq_bfqq_charge_time()
844 (bfqd->bfq_max_budget * bounded_time_ms) / timeout_ms; in bfq_bfqq_charge_time()
845 int tot_serv_to_charge = max(serv_to_charge_for_time, entity->service); in bfq_bfqq_charge_time()
848 if (tot_serv_to_charge > entity->budget) in bfq_bfqq_charge_time()
849 entity->budget = tot_serv_to_charge; in bfq_bfqq_charge_time()
852 max_t(int, 0, tot_serv_to_charge - entity->service)); in bfq_bfqq_charge_time()
867 bfq_calc_finish(entity, entity->budget); in bfq_update_fin_time_enqueue()
879 * idle, the system virtual time may be pushed-up to much in bfq_update_fin_time_enqueue()
894 * worst-case fairness guarantees. in bfq_update_fin_time_enqueue()
896 * As a special case, if bfqq is weight-raised, push up in bfq_update_fin_time_enqueue()
899 * weight-raised queues to become higher than the backshifted in bfq_update_fin_time_enqueue()
900 * finish timestamps of non weight-raised queues. in bfq_update_fin_time_enqueue()
902 if (backshifted && bfq_gt(st->vtime, entity->finish)) { in bfq_update_fin_time_enqueue()
903 unsigned long delta = st->vtime - entity->finish; in bfq_update_fin_time_enqueue()
906 delta /= bfqq->wr_coeff; in bfq_update_fin_time_enqueue()
908 entity->start += delta; in bfq_update_fin_time_enqueue()
909 entity->finish += delta; in bfq_update_fin_time_enqueue()
916 * __bfq_activate_entity - handle activation of entity.
935 if (non_blocking_wait_rq && bfq_gt(st->vtime, entity->finish)) { in __bfq_activate_entity()
937 min_vstart = entity->finish; in __bfq_activate_entity()
939 min_vstart = st->vtime; in __bfq_activate_entity()
941 if (entity->tree == &st->idle) { in __bfq_activate_entity()
947 entity->start = bfq_gt(min_vstart, entity->finish) ? in __bfq_activate_entity()
948 min_vstart : entity->finish; in __bfq_activate_entity()
955 entity->start = min_vstart; in __bfq_activate_entity()
956 st->wsum += entity->weight; in __bfq_activate_entity()
965 entity->on_st_or_in_serv = true; in __bfq_activate_entity()
972 * __bfq_requeue_entity - handle requeueing or repositioning of an entity.
988 struct bfq_sched_data *sd = entity->sched_data; in __bfq_requeue_entity()
991 if (entity == sd->in_service_entity) { in __bfq_requeue_entity()
993 * We are requeueing the current in-service entity, in __bfq_requeue_entity()
996 * - entity represents the in-service queue, and the in __bfq_requeue_entity()
997 * in-service queue is being requeued after an in __bfq_requeue_entity()
999 * - entity represents a group, and its budget has in __bfq_requeue_entity()
1014 bfq_calc_finish(entity, entity->service); in __bfq_requeue_entity()
1015 entity->start = entity->finish; in __bfq_requeue_entity()
1029 if (entity->tree) in __bfq_requeue_entity()
1044 * non-extracted-entity sub-case above. in __bfq_requeue_entity()
1057 if (entity->sched_data->in_service_entity == entity || in __bfq_activate_requeue_entity()
1058 entity->tree == &st->active) in __bfq_activate_requeue_entity()
1074 * bfq_activate_requeue_entity - activate or requeue an entity representing a
1084 * of the in-service queue
1092 if (!bfq_update_next_in_service(entity->sched_data, entity, in bfq_activate_requeue_entity()
1099 * __bfq_deactivate_entity - update sched_data and service trees for
1110 struct bfq_sched_data *sd = entity->sched_data; in __bfq_deactivate_entity()
1114 if (!entity->on_st_or_in_serv) /* in __bfq_deactivate_entity()
1124 * entity->sched_data has been set, and we can safely use it. in __bfq_deactivate_entity()
1127 is_in_service = entity == sd->in_service_entity; in __bfq_deactivate_entity()
1129 bfq_calc_finish(entity, entity->service); in __bfq_deactivate_entity()
1132 sd->in_service_entity = NULL; in __bfq_deactivate_entity()
1135 * Non in-service entity: nobody will take care of in __bfq_deactivate_entity()
1139 entity->service = 0; in __bfq_deactivate_entity()
1141 if (entity->tree == &st->active) in __bfq_deactivate_entity()
1143 else if (!is_in_service && entity->tree == &st->idle) in __bfq_deactivate_entity()
1146 if (!ins_into_idle_tree || !bfq_gt(entity->finish, st->vtime)) in __bfq_deactivate_entity()
1155 * bfq_deactivate_entity - deactivate an entity representing a bfq_queue.
1159 * of the in-service queue
1169 sd = entity->sched_data; in bfq_deactivate_entity()
1174 * this deactivation is a no-op, and there is in bfq_deactivate_entity()
1175 * nothing to change for upper-level entities in bfq_deactivate_entity()
1182 if (sd->next_in_service == entity) in bfq_deactivate_entity()
1190 if (sd->next_in_service || sd->in_service_entity) { in bfq_deactivate_entity()
1241 * active tree (because sd->next_in_service has in bfq_deactivate_entity()
1246 sd = entity->sched_data; in bfq_deactivate_entity()
1251 * any change in entity->parent->sd, and no in bfq_deactivate_entity()
1260 * bfq_calc_vtime_jump - compute the value to which the vtime should jump,
1268 struct bfq_entity *root_entity = bfq_root_active_entity(&st->active); in bfq_calc_vtime_jump()
1270 if (bfq_gt(root_entity->min_start, st->vtime)) in bfq_calc_vtime_jump()
1271 return root_entity->min_start; in bfq_calc_vtime_jump()
1273 return st->vtime; in bfq_calc_vtime_jump()
1278 if (new_value > st->vtime) { in bfq_update_vtime()
1279 st->vtime = new_value; in bfq_update_vtime()
1285 * bfq_first_active_entity - find the eligible entity with
1300 struct rb_node *node = st->active.rb_node; in bfq_first_active_entity()
1305 if (!bfq_gt(entry->start, vtime)) in bfq_first_active_entity()
1308 if (node->rb_left) { in bfq_first_active_entity()
1309 entry = rb_entry(node->rb_left, in bfq_first_active_entity()
1311 if (!bfq_gt(entry->min_start, vtime)) { in bfq_first_active_entity()
1312 node = node->rb_left; in bfq_first_active_entity()
1318 node = node->rb_right; in bfq_first_active_entity()
1325 * __bfq_lookup_next_entity - return the first eligible entity in @st.
1327 * @in_service: whether or not there is an in-service entity for the sched_data
1330 * If there is no in-service entity for the sched_data st belongs to,
1340 * In contrast, if there is an in-service entity, then return the
1343 * in-service entity, on expiration,
1354 if (RB_EMPTY_ROOT(&st->active)) in __bfq_lookup_next_entity()
1364 * If there is no in-service entity for the sched_data this in __bfq_lookup_next_entity()
1367 * eligible. If, instead, there is an in-service entity, then in __bfq_lookup_next_entity()
1369 * eligible entity, namely the in-service one (even if the in __bfq_lookup_next_entity()
1382 * bfq_lookup_next_entity - return the first eligible entity in @sd.
1384 * @expiration: true if we are on the expiration path of the in-service queue
1393 struct bfq_service_tree *st = sd->service_tree; in bfq_lookup_next_entity()
1394 struct bfq_service_tree *idle_class_st = st + (BFQ_IOPRIO_CLASSES - 1); in bfq_lookup_next_entity()
1402 * priority-inversion problems in case a low priority task is in bfq_lookup_next_entity()
1405 if (time_is_before_jiffies(sd->bfq_class_idle_last_service + in bfq_lookup_next_entity()
1407 if (!RB_EMPTY_ROOT(&idle_class_st->active)) in bfq_lookup_next_entity()
1408 class_idx = BFQ_IOPRIO_CLASSES - 1; in bfq_lookup_next_entity()
1410 sd->bfq_class_idle_last_service = jiffies; in bfq_lookup_next_entity()
1414 * Find the next entity to serve for the highest-priority in bfq_lookup_next_entity()
1421 * of the in-service queue. In this case, even if in bfq_lookup_next_entity()
1422 * sd->in_service_entity is not NULL, in bfq_lookup_next_entity()
1423 * sd->in_service_entity at this point is actually not in bfq_lookup_next_entity()
1426 * tree. The reason why sd->in_service_entity is still in bfq_lookup_next_entity()
1428 * sd->in_service_entity is reset as a last step in the in bfq_lookup_next_entity()
1431 * sd->in_service_entity. in bfq_lookup_next_entity()
1434 sd->in_service_entity && in bfq_lookup_next_entity()
1446 struct bfq_sched_data *sd = &bfqd->root_group->sched_data; in next_queue_may_preempt()
1448 return sd->next_in_service != sd->in_service_entity; in next_queue_may_preempt()
1468 sd = &bfqd->root_group->sched_data; in bfq_get_next_queue()
1469 for (; sd ; sd = entity->my_sched_data) { in bfq_get_next_queue()
1471 * WARNING. We are about to set the in-service entity in bfq_get_next_queue()
1472 * to sd->next_in_service, i.e., to the (cached) value in bfq_get_next_queue()
1480 * pointed to by sd->next_in_service. This rare event in bfq_get_next_queue()
1488 * service of the sd->next_in_service entity in bfq_get_next_queue()
1491 * exactly to update sd->next_in_service. in bfq_get_next_queue()
1495 entity = sd->next_in_service; in bfq_get_next_queue()
1496 sd->in_service_entity = entity; in bfq_get_next_queue()
1521 * the correct next-to-serve candidate entity for each in bfq_get_next_queue()
1524 * the next-to-serve leaf entity, we can discover in bfq_get_next_queue()
1526 * becomes the next-to-serve, and so on. in bfq_get_next_queue()
1533 * We can finally update all next-to-serve entities along the in bfq_get_next_queue()
1537 struct bfq_sched_data *sd = entity->sched_data; in bfq_get_next_queue()
1546 /* returns true if the in-service queue gets freed */
1549 struct bfq_queue *in_serv_bfqq = bfqd->in_service_queue; in __bfq_bfqd_reset_in_service()
1550 struct bfq_entity *in_serv_entity = &in_serv_bfqq->entity; in __bfq_bfqd_reset_in_service()
1554 hrtimer_try_to_cancel(&bfqd->idle_slice_timer); in __bfq_bfqd_reset_in_service()
1555 bfqd->in_service_queue = NULL; in __bfq_bfqd_reset_in_service()
1558 * When this function is called, all in-service entities have in __bfq_bfqd_reset_in_service()
1564 entity->sched_data->in_service_entity = NULL; in __bfq_bfqd_reset_in_service()
1571 if (!in_serv_entity->on_st_or_in_serv) { in __bfq_bfqd_reset_in_service()
1578 int ref = in_serv_bfqq->ref; in __bfq_bfqd_reset_in_service()
1590 struct bfq_entity *entity = &bfqq->entity; in bfq_deactivate_bfqq()
1597 struct bfq_entity *entity = &bfqq->entity; in bfq_activate_bfqq()
1607 struct bfq_entity *entity = &bfqq->entity; in bfq_requeue_bfqq()
1610 bfqq == bfqd->in_service_queue, expiration); in bfq_requeue_bfqq()
1616 struct bfq_entity *entity = &bfqq->entity; in bfq_add_bfqq_in_groups_with_pending_reqs()
1618 if (!entity->in_groups_with_pending_reqs) { in bfq_add_bfqq_in_groups_with_pending_reqs()
1619 entity->in_groups_with_pending_reqs = true; in bfq_add_bfqq_in_groups_with_pending_reqs()
1620 if (!(bfqq_group(bfqq)->num_queues_with_pending_reqs++)) in bfq_add_bfqq_in_groups_with_pending_reqs()
1621 bfqq->bfqd->num_groups_with_pending_reqs++; in bfq_add_bfqq_in_groups_with_pending_reqs()
1629 struct bfq_entity *entity = &bfqq->entity; in bfq_del_bfqq_in_groups_with_pending_reqs()
1631 if (entity->in_groups_with_pending_reqs) { in bfq_del_bfqq_in_groups_with_pending_reqs()
1632 entity->in_groups_with_pending_reqs = false; in bfq_del_bfqq_in_groups_with_pending_reqs()
1633 if (!(--bfqq_group(bfqq)->num_queues_with_pending_reqs)) in bfq_del_bfqq_in_groups_with_pending_reqs()
1634 bfqq->bfqd->num_groups_with_pending_reqs--; in bfq_del_bfqq_in_groups_with_pending_reqs()
1646 struct bfq_data *bfqd = bfqq->bfqd; in bfq_del_bfqq_busy()
1652 bfqd->busy_queues[bfqq->ioprio_class - 1]--; in bfq_del_bfqq_busy()
1654 if (bfqq->wr_coeff > 1) in bfq_del_bfqq_busy()
1655 bfqd->wr_busy_queues--; in bfq_del_bfqq_busy()
1661 if (!bfqq->dispatched) { in bfq_del_bfqq_busy()
1676 struct bfq_data *bfqd = bfqq->bfqd; in bfq_add_bfqq_busy()
1683 bfqd->busy_queues[bfqq->ioprio_class - 1]++; in bfq_add_bfqq_busy()
1685 if (!bfqq->dispatched) { in bfq_add_bfqq_busy()
1687 if (bfqq->wr_coeff == 1) in bfq_add_bfqq_busy()
1691 if (bfqq->wr_coeff > 1) in bfq_add_bfqq_busy()
1692 bfqd->wr_busy_queues++; in bfq_add_bfqq_busy()
1695 if (!hlist_unhashed(&bfqq->woken_list_node) && in bfq_add_bfqq_busy()
1696 &bfqq->woken_list_node != bfqq->waker_bfqq->woken_list.first) { in bfq_add_bfqq_busy()
1697 hlist_del_init(&bfqq->woken_list_node); in bfq_add_bfqq_busy()
1698 hlist_add_head(&bfqq->woken_list_node, in bfq_add_bfqq_busy()
1699 &bfqq->waker_bfqq->woken_list); in bfq_add_bfqq_busy()