Lines Matching +full:field +full:- +full:even +full:- +full:active
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
60 * extraction of an entity into/from one of the active trees of
65 * reposition an entity in its active tree; see comments on
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()
160 * bfq_group's my_entity field is not NULL only if the group 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()
176 * service, according to the restrictive definition of the field
182 * about to become the in-service queue. This function then returns
186 * it is not a queue, and has more than one active child. In fact,
187 * even if one of its children is about to be set in service, other
188 * active children may still be the next to serve, for the parent
189 * entity, even according to the above definition. As a consequence, a
190 * non-queue entity is not a candidate for next-service only if it has
191 * only one active child. And only if this condition holds, then this
192 * function returns true for a non-queue entity.
204 * The field active_entities does not always contain the in bfq_no_longer_next_in_service()
205 * actual number of active children entities: it happens to in bfq_no_longer_next_in_service()
206 * not account for the in-service entity in case the latter is in bfq_no_longer_next_in_service()
207 * removed from its active tree (which may get done after in bfq_no_longer_next_in_service()
213 * actual number of active entities. in bfq_no_longer_next_in_service()
215 if (bfqg->active_entities == 1) in bfq_no_longer_next_in_service()
248 if (!entity->my_sched_data) in bfq_entity_to_bfqq()
256 * bfq_delta - map service into the virtual time domain.
266 * bfq_calc_finish - assign the finish time to an entity.
274 entity->finish = entity->start + in bfq_calc_finish()
275 bfq_delta(service, entity->weight); in bfq_calc_finish()
278 bfq_log_bfqq(bfqq->bfqd, bfqq, in bfq_calc_finish()
280 service, entity->weight); in bfq_calc_finish()
281 bfq_log_bfqq(bfqq->bfqd, bfqq, in bfq_calc_finish()
283 entity->start, entity->finish, in bfq_calc_finish()
284 bfq_delta(service, entity->weight)); in bfq_calc_finish()
289 * bfq_entity_of - get an entity from a node.
290 * @node: the node field of the entity.
308 * bfq_extract - remove an entity from a tree.
314 entity->tree = NULL; in bfq_extract()
315 rb_erase(&entity->rb_node, root); in bfq_extract()
319 * bfq_idle_extract - extract an entity from the idle tree.
329 if (entity == st->first_idle) { in bfq_idle_extract()
330 next = rb_next(&entity->rb_node); in bfq_idle_extract()
331 st->first_idle = bfq_entity_of(next); in bfq_idle_extract()
334 if (entity == st->last_idle) { in bfq_idle_extract()
335 next = rb_prev(&entity->rb_node); in bfq_idle_extract()
336 st->last_idle = bfq_entity_of(next); in bfq_idle_extract()
339 bfq_extract(&st->idle, entity); in bfq_idle_extract()
342 list_del(&bfqq->bfqq_list); in bfq_idle_extract()
346 * bfq_insert - generic tree insertion.
350 * This is used for the idle and the active tree, since they are both
356 struct rb_node **node = &root->rb_node; in bfq_insert()
363 if (bfq_gt(entry->finish, entity->finish)) in bfq_insert()
364 node = &parent->rb_left; in bfq_insert()
366 node = &parent->rb_right; in bfq_insert()
369 rb_link_node(&entity->rb_node, parent, node); in bfq_insert()
370 rb_insert_color(&entity->rb_node, root); in bfq_insert()
372 entity->tree = root; in bfq_insert()
376 * bfq_update_min - update the min_start field of a entity.
381 * min_start due to updates to the active tree. The function assumes
391 if (bfq_gt(entity->min_start, child->min_start)) in bfq_update_min()
392 entity->min_start = child->min_start; in bfq_update_min()
397 * bfq_update_active_node - recalculate min_start.
408 entity->min_start = entity->start; in bfq_update_active_node()
409 bfq_update_min(entity, node->rb_right); in bfq_update_active_node()
410 bfq_update_min(entity, node->rb_left); in bfq_update_active_node()
414 * bfq_update_active_tree - update min_start for the whole active tree.
434 if (node == parent->rb_left && parent->rb_right) in bfq_update_active_tree()
435 bfq_update_active_node(parent->rb_right); in bfq_update_active_tree()
436 else if (parent->rb_left) in bfq_update_active_tree()
437 bfq_update_active_node(parent->rb_left); in bfq_update_active_tree()
444 * bfq_active_insert - insert an entity in the active tree of its
449 * The active tree is ordered by finish time, but an extra key is kept
458 struct rb_node *node = &entity->rb_node; in bfq_active_insert()
465 bfq_insert(&st->active, entity); in bfq_active_insert()
467 if (node->rb_left) in bfq_active_insert()
468 node = node->rb_left; in bfq_active_insert()
469 else if (node->rb_right) in bfq_active_insert()
470 node = node->rb_right; in bfq_active_insert()
475 sd = entity->sched_data; in bfq_active_insert()
477 bfqd = (struct bfq_data *)bfqg->bfqd; in bfq_active_insert()
480 list_add(&bfqq->bfqq_list, &bfqq->bfqd->active_list); in bfq_active_insert()
482 if (bfqg != bfqd->root_group) in bfq_active_insert()
483 bfqg->active_entities++; in bfq_active_insert()
488 * bfq_ioprio_to_weight - calc a weight from an ioprio.
493 return (IOPRIO_NR_LEVELS - ioprio) * BFQ_WEIGHT_CONVERSION_COEFF; in bfq_ioprio_to_weight()
497 * bfq_weight_to_ioprio - calc an ioprio from a weight.
500 * To preserve as much as possible the old only-ioprio user interface,
507 IOPRIO_NR_LEVELS - weight / BFQ_WEIGHT_CONVERSION_COEFF); in bfq_weight_to_ioprio()
515 bfqq->ref++; in bfq_get_entity()
516 bfq_log_bfqq(bfqq->bfqd, bfqq, "get_entity: %p %d", in bfq_get_entity()
517 bfqq, bfqq->ref); in bfq_get_entity()
522 * bfq_find_deepest - find the deepest node that an extraction can modify.
534 if (!node->rb_right && !node->rb_left) in bfq_find_deepest()
536 else if (!node->rb_right) in bfq_find_deepest()
537 deepest = node->rb_left; in bfq_find_deepest()
538 else if (!node->rb_left) in bfq_find_deepest()
539 deepest = node->rb_right; in bfq_find_deepest()
542 if (deepest->rb_right) in bfq_find_deepest()
543 deepest = deepest->rb_right; in bfq_find_deepest()
552 * bfq_active_extract - remove an entity from the active tree.
567 node = bfq_find_deepest(&entity->rb_node); in bfq_active_extract()
568 bfq_extract(&st->active, entity); in bfq_active_extract()
574 sd = entity->sched_data; in bfq_active_extract()
576 bfqd = (struct bfq_data *)bfqg->bfqd; in bfq_active_extract()
579 list_del(&bfqq->bfqq_list); in bfq_active_extract()
581 if (bfqg != bfqd->root_group) in bfq_active_extract()
582 bfqg->active_entities--; in bfq_active_extract()
587 * bfq_idle_insert - insert an entity into the idle tree.
595 struct bfq_entity *first_idle = st->first_idle; in bfq_idle_insert()
596 struct bfq_entity *last_idle = st->last_idle; in bfq_idle_insert()
598 if (!first_idle || bfq_gt(first_idle->finish, entity->finish)) in bfq_idle_insert()
599 st->first_idle = entity; in bfq_idle_insert()
600 if (!last_idle || bfq_gt(entity->finish, last_idle->finish)) in bfq_idle_insert()
601 st->last_idle = entity; in bfq_idle_insert()
603 bfq_insert(&st->idle, entity); in bfq_idle_insert()
606 list_add(&bfqq->bfqq_list, &bfqq->bfqd->idle_list); in bfq_idle_insert()
610 * bfq_forget_entity - do not consider entity any longer for scheduling
613 * @is_in_service: true if entity is currently the in-service entity.
630 entity->on_st_or_in_serv = false; in bfq_forget_entity()
631 st->wsum -= entity->weight; in bfq_forget_entity()
637 * bfq_put_idle_entity - release the idle tree ref of an entity.
645 entity == entity->sched_data->in_service_entity); in bfq_put_idle_entity()
649 * bfq_forget_idle - update the idle tree if necessary.
657 struct bfq_entity *first_idle = st->first_idle; in bfq_forget_idle()
658 struct bfq_entity *last_idle = st->last_idle; in bfq_forget_idle()
660 if (RB_EMPTY_ROOT(&st->active) && last_idle && in bfq_forget_idle()
661 !bfq_gt(last_idle->finish, st->vtime)) { in bfq_forget_idle()
666 st->vtime = last_idle->finish; in bfq_forget_idle()
669 if (first_idle && !bfq_gt(first_idle->finish, st->vtime)) in bfq_forget_idle()
675 struct bfq_sched_data *sched_data = entity->sched_data; in bfq_entity_service_tree()
678 return sched_data->service_tree + idx; in bfq_entity_service_tree()
706 if (entity->prio_changed) { in __bfq_entity_update_weight_prio()
717 bfqd = bfqq->bfqd; in __bfq_entity_update_weight_prio()
720 sd = entity->my_sched_data; in __bfq_entity_update_weight_prio()
722 bfqd = (struct bfq_data *)bfqg->bfqd; in __bfq_entity_update_weight_prio()
728 old_st->wsum -= entity->weight; in __bfq_entity_update_weight_prio()
730 if (entity->new_weight != entity->orig_weight) { in __bfq_entity_update_weight_prio()
731 if (entity->new_weight < BFQ_MIN_WEIGHT || in __bfq_entity_update_weight_prio()
732 entity->new_weight > BFQ_MAX_WEIGHT) { in __bfq_entity_update_weight_prio()
734 entity->new_weight); in __bfq_entity_update_weight_prio()
735 if (entity->new_weight < BFQ_MIN_WEIGHT) in __bfq_entity_update_weight_prio()
736 entity->new_weight = BFQ_MIN_WEIGHT; in __bfq_entity_update_weight_prio()
738 entity->new_weight = BFQ_MAX_WEIGHT; in __bfq_entity_update_weight_prio()
740 entity->orig_weight = entity->new_weight; in __bfq_entity_update_weight_prio()
742 bfqq->ioprio = in __bfq_entity_update_weight_prio()
743 bfq_weight_to_ioprio(entity->orig_weight); in __bfq_entity_update_weight_prio()
747 bfqq->ioprio_class = bfqq->new_ioprio_class; in __bfq_entity_update_weight_prio()
753 if (!bfqq || bfqq->ioprio_class == bfqq->new_ioprio_class) in __bfq_entity_update_weight_prio()
754 entity->prio_changed = 0; in __bfq_entity_update_weight_prio()
761 * when entity->finish <= old_st->vtime). in __bfq_entity_update_weight_prio()
765 prev_weight = entity->weight; in __bfq_entity_update_weight_prio()
766 new_weight = entity->orig_weight * in __bfq_entity_update_weight_prio()
767 (bfqq ? bfqq->wr_coeff : 1); in __bfq_entity_update_weight_prio()
774 root = &bfqd->queue_weights_tree; in __bfq_entity_update_weight_prio()
777 entity->weight = new_weight; in __bfq_entity_update_weight_prio()
779 * Add the entity, if it is not a weight-raised queue, in __bfq_entity_update_weight_prio()
782 if (prev_weight != new_weight && bfqq && bfqq->wr_coeff == 1) { in __bfq_entity_update_weight_prio()
787 new_st->wsum += entity->weight; in __bfq_entity_update_weight_prio()
790 entity->start = new_st->vtime; in __bfq_entity_update_weight_prio()
797 * bfq_bfqq_served - update the scheduler status after selection for
808 struct bfq_entity *entity = &bfqq->entity; in bfq_bfqq_served()
811 if (!bfqq->service_from_backlogged) in bfq_bfqq_served()
812 bfqq->first_IO_time = jiffies; in bfq_bfqq_served()
814 if (bfqq->wr_coeff > 1) in bfq_bfqq_served()
815 bfqq->service_from_wr += served; in bfq_bfqq_served()
817 bfqq->service_from_backlogged += served; in bfq_bfqq_served()
821 entity->service += served; in bfq_bfqq_served()
823 st->vtime += bfq_delta(served, st->wsum); in bfq_bfqq_served()
826 bfq_log_bfqq(bfqq->bfqd, bfqq, "bfqq_served %d secs", served); in bfq_bfqq_served()
830 * bfq_bfqq_charge_time - charge an amount of service equivalent to the length
841 * goal is achieved through the BFQ scheduling engine, even if such an
859 struct bfq_entity *entity = &bfqq->entity; in bfq_bfqq_charge_time()
863 (bfqd->bfq_max_budget * bounded_time_ms) / timeout_ms; in bfq_bfqq_charge_time()
864 int tot_serv_to_charge = max(serv_to_charge_for_time, entity->service); in bfq_bfqq_charge_time()
867 if (tot_serv_to_charge > entity->budget) in bfq_bfqq_charge_time()
868 entity->budget = tot_serv_to_charge; in bfq_bfqq_charge_time()
871 max_t(int, 0, tot_serv_to_charge - entity->service)); in bfq_bfqq_charge_time()
886 bfq_calc_finish(entity, entity->budget); in bfq_update_fin_time_enqueue()
898 * idle, the system virtual time may be pushed-up to much in bfq_update_fin_time_enqueue()
913 * worst-case fairness guarantees. in bfq_update_fin_time_enqueue()
915 * As a special case, if bfqq is weight-raised, push up in bfq_update_fin_time_enqueue()
918 * weight-raised queues to become higher than the backshifted in bfq_update_fin_time_enqueue()
919 * finish timestamps of non weight-raised queues. in bfq_update_fin_time_enqueue()
921 if (backshifted && bfq_gt(st->vtime, entity->finish)) { in bfq_update_fin_time_enqueue()
922 unsigned long delta = st->vtime - entity->finish; in bfq_update_fin_time_enqueue()
925 delta /= bfqq->wr_coeff; in bfq_update_fin_time_enqueue()
927 entity->start += delta; in bfq_update_fin_time_enqueue()
928 entity->finish += delta; in bfq_update_fin_time_enqueue()
935 * __bfq_activate_entity - handle activation of entity.
939 * Called for a 'true' activation, i.e., if entity is not active and
943 * inserts entity into its active tree, after possibly extracting it
954 if (non_blocking_wait_rq && bfq_gt(st->vtime, entity->finish)) { in __bfq_activate_entity()
956 min_vstart = entity->finish; in __bfq_activate_entity()
958 min_vstart = st->vtime; in __bfq_activate_entity()
960 if (entity->tree == &st->idle) { in __bfq_activate_entity()
966 entity->start = bfq_gt(min_vstart, entity->finish) ? in __bfq_activate_entity()
967 min_vstart : entity->finish; in __bfq_activate_entity()
974 entity->start = min_vstart; in __bfq_activate_entity()
975 st->wsum += entity->weight; in __bfq_activate_entity()
984 entity->on_st_or_in_serv = true; in __bfq_activate_entity()
991 struct bfq_data *bfqd = bfqg->bfqd; in __bfq_activate_entity()
993 if (!entity->in_groups_with_pending_reqs) { in __bfq_activate_entity()
994 entity->in_groups_with_pending_reqs = true; in __bfq_activate_entity()
995 bfqd->num_groups_with_pending_reqs++; in __bfq_activate_entity()
1004 * __bfq_requeue_entity - handle requeueing or repositioning of an entity.
1013 * Basically, this function: 1) removes entity from its active tree if
1015 * entity back into its active tree (in the new, right position for
1020 struct bfq_sched_data *sd = entity->sched_data; in __bfq_requeue_entity()
1023 if (entity == sd->in_service_entity) { in __bfq_requeue_entity()
1025 * We are requeueing the current in-service entity, in __bfq_requeue_entity()
1028 * - entity represents the in-service queue, and the in __bfq_requeue_entity()
1029 * in-service queue is being requeued after an in __bfq_requeue_entity()
1031 * - entity represents a group, and its budget has in __bfq_requeue_entity()
1046 bfq_calc_finish(entity, entity->service); in __bfq_requeue_entity()
1047 entity->start = entity->finish; in __bfq_requeue_entity()
1051 * the active tree. This implies that the position of in __bfq_requeue_entity()
1052 * the entity in the active tree may need to be in __bfq_requeue_entity()
1061 if (entity->tree) in __bfq_requeue_entity()
1063 } else { /* The entity is already active, and not in service */ in __bfq_requeue_entity()
1071 * i.e., the position in the active tree, of this in __bfq_requeue_entity()
1076 * non-extracted-entity sub-case above. in __bfq_requeue_entity()
1090 if (sd->in_service_entity == entity || entity->tree == &st->active) in __bfq_activate_requeue_entity()
1092 * in service or already queued on the active tree, in __bfq_activate_requeue_entity()
1098 * Not in service and not queued on its active tree: in __bfq_activate_requeue_entity()
1106 * bfq_activate_requeue_entity - activate or requeue an entity representing a
1116 * of the in-service queue
1125 sd = entity->sched_data; in bfq_activate_requeue_entity()
1135 * __bfq_deactivate_entity - update sched_data and service trees for
1146 struct bfq_sched_data *sd = entity->sched_data; in __bfq_deactivate_entity()
1150 if (!entity->on_st_or_in_serv) /* in __bfq_deactivate_entity()
1157 * If we get here, then entity is active, which implies that in __bfq_deactivate_entity()
1159 * represented by entity. Therefore, the field in __bfq_deactivate_entity()
1160 * entity->sched_data has been set, and we can safely use it. in __bfq_deactivate_entity()
1163 is_in_service = entity == sd->in_service_entity; in __bfq_deactivate_entity()
1165 bfq_calc_finish(entity, entity->service); in __bfq_deactivate_entity()
1168 sd->in_service_entity = NULL; in __bfq_deactivate_entity()
1171 * Non in-service entity: nobody will take care of in __bfq_deactivate_entity()
1175 entity->service = 0; in __bfq_deactivate_entity()
1177 if (entity->tree == &st->active) in __bfq_deactivate_entity()
1179 else if (!is_in_service && entity->tree == &st->idle) in __bfq_deactivate_entity()
1182 if (!ins_into_idle_tree || !bfq_gt(entity->finish, st->vtime)) in __bfq_deactivate_entity()
1191 * bfq_deactivate_entity - deactivate an entity representing a bfq_queue.
1195 * of the in-service queue
1205 sd = entity->sched_data; in bfq_deactivate_entity()
1210 * this deactivation is a no-op, and there is in bfq_deactivate_entity()
1211 * nothing to change for upper-level entities in bfq_deactivate_entity()
1218 if (sd->next_in_service == entity) in bfq_deactivate_entity()
1226 if (sd->next_in_service || sd->in_service_entity) { in bfq_deactivate_entity()
1228 * The parent entity is still active, because in bfq_deactivate_entity()
1238 * active. This happens if 1) the entity in bfq_deactivate_entity()
1240 * active entity in the parent entity, and 2) in bfq_deactivate_entity()
1275 * Invoke __bfq_requeue_entity on entity, even if in bfq_deactivate_entity()
1276 * already active, to requeue/reposition it in the in bfq_deactivate_entity()
1277 * active tree (because sd->next_in_service has in bfq_deactivate_entity()
1282 sd = entity->sched_data; in bfq_deactivate_entity()
1287 * any change in entity->parent->sd, and no in bfq_deactivate_entity()
1296 * bfq_calc_vtime_jump - compute the value to which the vtime should jump,
1304 struct bfq_entity *root_entity = bfq_root_active_entity(&st->active); in bfq_calc_vtime_jump()
1306 if (bfq_gt(root_entity->min_start, st->vtime)) in bfq_calc_vtime_jump()
1307 return root_entity->min_start; in bfq_calc_vtime_jump()
1309 return st->vtime; in bfq_calc_vtime_jump()
1314 if (new_value > st->vtime) { in bfq_update_vtime()
1315 st->vtime = new_value; in bfq_update_vtime()
1321 * bfq_first_active_entity - find the eligible entity with
1336 struct rb_node *node = st->active.rb_node; in bfq_first_active_entity()
1341 if (!bfq_gt(entry->start, vtime)) in bfq_first_active_entity()
1344 if (node->rb_left) { in bfq_first_active_entity()
1345 entry = rb_entry(node->rb_left, in bfq_first_active_entity()
1347 if (!bfq_gt(entry->min_start, vtime)) { in bfq_first_active_entity()
1348 node = node->rb_left; in bfq_first_active_entity()
1354 node = node->rb_right; in bfq_first_active_entity()
1361 * __bfq_lookup_next_entity - return the first eligible entity in @st.
1363 * @in_service: whether or not there is an in-service entity for the sched_data
1364 * this active tree belongs to.
1366 * If there is no in-service entity for the sched_data st belongs to,
1376 * In contrast, if there is an in-service entity, then return the
1379 * in-service entity, on expiration,
1390 if (RB_EMPTY_ROOT(&st->active)) in __bfq_lookup_next_entity()
1400 * If there is no in-service entity for the sched_data this in __bfq_lookup_next_entity()
1401 * active tree belongs to, then push the system virtual time in __bfq_lookup_next_entity()
1403 * eligible. If, instead, there is an in-service entity, then in __bfq_lookup_next_entity()
1405 * eligible entity, namely the in-service one (even if the in __bfq_lookup_next_entity()
1418 * bfq_lookup_next_entity - return the first eligible entity in @sd.
1420 * @expiration: true if we are on the expiration path of the in-service queue
1429 struct bfq_service_tree *st = sd->service_tree; in bfq_lookup_next_entity()
1430 struct bfq_service_tree *idle_class_st = st + (BFQ_IOPRIO_CLASSES - 1); in bfq_lookup_next_entity()
1436 * bandwidth to this class (and if there is some active entity in bfq_lookup_next_entity()
1438 * priority-inversion problems in case a low priority task is in bfq_lookup_next_entity()
1441 if (time_is_before_jiffies(sd->bfq_class_idle_last_service + in bfq_lookup_next_entity()
1443 if (!RB_EMPTY_ROOT(&idle_class_st->active)) in bfq_lookup_next_entity()
1444 class_idx = BFQ_IOPRIO_CLASSES - 1; in bfq_lookup_next_entity()
1446 sd->bfq_class_idle_last_service = jiffies; in bfq_lookup_next_entity()
1450 * Find the next entity to serve for the highest-priority in bfq_lookup_next_entity()
1457 * of the in-service queue. In this case, even if in bfq_lookup_next_entity()
1458 * sd->in_service_entity is not NULL, in bfq_lookup_next_entity()
1459 * sd->in_service_entity at this point is actually not in bfq_lookup_next_entity()
1462 * tree. The reason why sd->in_service_entity is still in bfq_lookup_next_entity()
1463 * not NULL here, even if expiration is true, is that in bfq_lookup_next_entity()
1464 * sd->in_service_entity is reset as a last step in the in bfq_lookup_next_entity()
1467 * sd->in_service_entity. in bfq_lookup_next_entity()
1470 sd->in_service_entity && in bfq_lookup_next_entity()
1482 struct bfq_sched_data *sd = &bfqd->root_group->sched_data; in next_queue_may_preempt()
1484 return sd->next_in_service != sd->in_service_entity; in next_queue_may_preempt()
1504 sd = &bfqd->root_group->sched_data; in bfq_get_next_queue()
1505 for (; sd ; sd = entity->my_sched_data) { in bfq_get_next_queue()
1507 * WARNING. We are about to set the in-service entity in bfq_get_next_queue()
1508 * to sd->next_in_service, i.e., to the (cached) value in bfq_get_next_queue()
1516 * pointed to by sd->next_in_service. This rare event in bfq_get_next_queue()
1524 * service of the sd->next_in_service entity in bfq_get_next_queue()
1527 * exactly to update sd->next_in_service. in bfq_get_next_queue()
1531 entity = sd->next_in_service; in bfq_get_next_queue()
1532 sd->in_service_entity = entity; in bfq_get_next_queue()
1536 * service, then it must be extracted from its active in bfq_get_next_queue()
1547 * Even if entity is not to be extracted according to in bfq_get_next_queue()
1557 * the correct next-to-serve candidate entity for each in bfq_get_next_queue()
1560 * the next-to-serve leaf entity, we can discover in bfq_get_next_queue()
1562 * becomes the next-to-serve, and so on. in bfq_get_next_queue()
1569 * We can finally update all next-to-serve entities along the in bfq_get_next_queue()
1573 struct bfq_sched_data *sd = entity->sched_data; in bfq_get_next_queue()
1582 /* returns true if the in-service queue gets freed */
1585 struct bfq_queue *in_serv_bfqq = bfqd->in_service_queue; in __bfq_bfqd_reset_in_service()
1586 struct bfq_entity *in_serv_entity = &in_serv_bfqq->entity; in __bfq_bfqd_reset_in_service()
1590 hrtimer_try_to_cancel(&bfqd->idle_slice_timer); in __bfq_bfqd_reset_in_service()
1591 bfqd->in_service_queue = NULL; in __bfq_bfqd_reset_in_service()
1594 * When this function is called, all in-service entities have in __bfq_bfqd_reset_in_service()
1600 entity->sched_data->in_service_entity = NULL; in __bfq_bfqd_reset_in_service()
1607 if (!in_serv_entity->on_st_or_in_serv) { in __bfq_bfqd_reset_in_service()
1614 int ref = in_serv_bfqq->ref; in __bfq_bfqd_reset_in_service()
1626 struct bfq_entity *entity = &bfqq->entity; in bfq_deactivate_bfqq()
1633 struct bfq_entity *entity = &bfqq->entity; in bfq_activate_bfqq()
1643 struct bfq_entity *entity = &bfqq->entity; in bfq_requeue_bfqq()
1646 bfqq == bfqd->in_service_queue, expiration); in bfq_requeue_bfqq()
1656 struct bfq_data *bfqd = bfqq->bfqd; in bfq_del_bfqq_busy()
1662 bfqd->busy_queues[bfqq->ioprio_class - 1]--; in bfq_del_bfqq_busy()
1664 if (bfqq->wr_coeff > 1) in bfq_del_bfqq_busy()
1665 bfqd->wr_busy_queues--; in bfq_del_bfqq_busy()
1671 if (!bfqq->dispatched) in bfq_del_bfqq_busy()
1680 struct bfq_data *bfqd = bfqq->bfqd; in bfq_add_bfqq_busy()
1687 bfqd->busy_queues[bfqq->ioprio_class - 1]++; in bfq_add_bfqq_busy()
1689 if (!bfqq->dispatched) in bfq_add_bfqq_busy()
1690 if (bfqq->wr_coeff == 1) in bfq_add_bfqq_busy()
1692 &bfqd->queue_weights_tree); in bfq_add_bfqq_busy()
1694 if (bfqq->wr_coeff > 1) in bfq_add_bfqq_busy()
1695 bfqd->wr_busy_queues++; in bfq_add_bfqq_busy()
1698 if (!hlist_unhashed(&bfqq->woken_list_node) && in bfq_add_bfqq_busy()
1699 &bfqq->woken_list_node != bfqq->waker_bfqq->woken_list.first) { in bfq_add_bfqq_busy()
1700 hlist_del_init(&bfqq->woken_list_node); in bfq_add_bfqq_busy()
1701 hlist_add_head(&bfqq->woken_list_node, in bfq_add_bfqq_busy()
1702 &bfqq->waker_bfqq->woken_list); in bfq_add_bfqq_busy()