Lines Matching refs:bfqd
232 #define BFQ_RQ_SEEKY(bfqd, last_pos, rq) \ argument
235 (!blk_queue_nonrot(bfqd->queue) || \
475 void bfq_schedule_dispatch(struct bfq_data *bfqd) in bfq_schedule_dispatch() argument
477 lockdep_assert_held(&bfqd->lock); in bfq_schedule_dispatch()
479 if (bfqd->queued != 0) { in bfq_schedule_dispatch()
480 bfq_log(bfqd, "schedule dispatch"); in bfq_schedule_dispatch()
481 blk_mq_run_hw_queues(bfqd->queue, true); in bfq_schedule_dispatch()
494 static struct request *bfq_choose_req(struct bfq_data *bfqd, in bfq_choose_req() argument
525 back_max = bfqd->bfq_back_max * 2; in bfq_choose_req()
535 d1 = (last - s1) * bfqd->bfq_back_penalty; in bfq_choose_req()
542 d2 = (last - s2) * bfqd->bfq_back_penalty; in bfq_choose_req()
588 struct bfq_data *bfqd = bfqq->bfqd; in bfqq_request_over_limit() local
602 spin_lock_irq(&bfqd->lock); in bfqq_request_over_limit()
606 spin_unlock_irq(&bfqd->lock); in bfqq_request_over_limit()
654 bfq_log_bfqq(bfqq->bfqd, bfqq, in bfqq_request_over_limit()
662 spin_unlock_irq(&bfqd->lock); in bfqq_request_over_limit()
691 struct bfq_data *bfqd = data->q->elevator->elevator_data; in bfq_limit_depth() local
701 depth = bfqd->word_depths[!!bfqd->wr_busy_queues][op_is_sync(opf)]; in bfq_limit_depth()
702 limit = (limit * depth) >> bfqd->full_depth_shift; in bfq_limit_depth()
705 for (act_idx = 0; bic && act_idx < bfqd->num_actuators; act_idx++) { in bfq_limit_depth()
720 bfq_log(bfqd, "[%s] wr_busy %d sync %d depth %u", in bfq_limit_depth()
721 __func__, bfqd->wr_busy_queues, op_is_sync(opf), depth); in bfq_limit_depth()
727 bfq_rq_pos_tree_lookup(struct bfq_data *bfqd, struct rb_root *root, in bfq_rq_pos_tree_lookup() argument
760 bfq_log(bfqd, "rq_pos_tree_lookup %llu: returning %d", in bfq_rq_pos_tree_lookup()
783 bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_pos_tree_add_move() argument
794 if (bfqq == &bfqd->oom_bfqq) in bfq_pos_tree_add_move()
811 __bfqq = bfq_rq_pos_tree_lookup(bfqd, bfqq->pos_root, in bfq_pos_tree_add_move()
853 static bool bfq_asymmetric_scenario(struct bfq_data *bfqd, in bfq_asymmetric_scenario() argument
860 rb_first_cached(&bfqd->queue_weights_tree), in bfq_asymmetric_scenario()
869 !RB_EMPTY_ROOT(&bfqd->queue_weights_tree.rb_root) && in bfq_asymmetric_scenario()
870 (bfqd->queue_weights_tree.rb_root.rb_node->rb_left || in bfq_asymmetric_scenario()
871 bfqd->queue_weights_tree.rb_root.rb_node->rb_right); in bfq_asymmetric_scenario()
874 (bfqd->busy_queues[0] && bfqd->busy_queues[1]) || in bfq_asymmetric_scenario()
875 (bfqd->busy_queues[0] && bfqd->busy_queues[2]) || in bfq_asymmetric_scenario()
876 (bfqd->busy_queues[1] && bfqd->busy_queues[2]); in bfq_asymmetric_scenario()
880 || bfqd->num_groups_with_pending_reqs > 1 in bfq_asymmetric_scenario()
900 struct rb_root_cached *root = &bfqq->bfqd->queue_weights_tree; in bfq_weights_tree_add()
979 root = &bfqq->bfqd->queue_weights_tree; in bfq_weights_tree_remove()
1010 bfq_log_bfqq(bfqq->bfqd, bfqq, "check_fifo: returned %p", rq); in bfq_check_fifo()
1014 static struct request *bfq_find_next_rq(struct bfq_data *bfqd, in bfq_find_next_rq() argument
1038 return bfq_choose_req(bfqd, next, prev, blk_rq_pos(last)); in bfq_find_next_rq()
1046 bfq_asymmetric_scenario(bfqq->bfqd, bfqq)) in bfq_serv_to_charge()
1063 static void bfq_updated_next_req(struct bfq_data *bfqd, in bfq_updated_next_req() argument
1073 if (bfqq == bfqd->in_service_queue) in bfq_updated_next_req()
1086 bfq_log_bfqq(bfqd, bfqq, "updated next rq: new budget %lu", in bfq_updated_next_req()
1088 bfq_requeue_bfqq(bfqd, bfqq, false); in bfq_updated_next_req()
1092 static unsigned int bfq_wr_duration(struct bfq_data *bfqd) in bfq_wr_duration() argument
1096 dur = bfqd->rate_dur_prod; in bfq_wr_duration()
1097 do_div(dur, bfqd->peak_rate); in bfq_wr_duration()
1124 struct bfq_data *bfqd) in switch_back_to_interactive_wr() argument
1126 bfqq->wr_coeff = bfqd->bfq_wr_coeff; in switch_back_to_interactive_wr()
1127 bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); in switch_back_to_interactive_wr()
1132 bfq_bfqq_resume_state(struct bfq_queue *bfqq, struct bfq_data *bfqd, in bfq_bfqq_resume_state() argument
1161 if (bfqd->low_latency) { in bfq_bfqq_resume_state()
1174 if (bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time && in bfq_bfqq_resume_state()
1177 bfq_wr_duration(bfqd))) { in bfq_bfqq_resume_state()
1178 switch_back_to_interactive_wr(bfqq, bfqd); in bfq_bfqq_resume_state()
1181 bfq_log_bfqq(bfqq->bfqd, bfqq, in bfq_bfqq_resume_state()
1193 bfqd->wr_busy_queues++; in bfq_bfqq_resume_state()
1195 bfqd->wr_busy_queues--; in bfq_bfqq_resume_state()
1206 static void bfq_reset_burst_list(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_reset_burst_list() argument
1211 hlist_for_each_entry_safe(item, n, &bfqd->burst_list, burst_list_node) in bfq_reset_burst_list()
1219 if (bfq_tot_busy_queues(bfqd) == 0) { in bfq_reset_burst_list()
1220 hlist_add_head(&bfqq->burst_list_node, &bfqd->burst_list); in bfq_reset_burst_list()
1221 bfqd->burst_size = 1; in bfq_reset_burst_list()
1223 bfqd->burst_size = 0; in bfq_reset_burst_list()
1225 bfqd->burst_parent_entity = bfqq->entity.parent; in bfq_reset_burst_list()
1229 static void bfq_add_to_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_add_to_burst() argument
1232 bfqd->burst_size++; in bfq_add_to_burst()
1234 if (bfqd->burst_size == bfqd->bfq_large_burst_thresh) { in bfq_add_to_burst()
1242 bfqd->large_burst = true; in bfq_add_to_burst()
1248 hlist_for_each_entry(bfqq_item, &bfqd->burst_list, in bfq_add_to_burst()
1260 hlist_for_each_entry_safe(pos, n, &bfqd->burst_list, in bfq_add_to_burst()
1269 hlist_add_head(&bfqq->burst_list_node, &bfqd->burst_list); in bfq_add_to_burst()
1381 static void bfq_handle_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_handle_burst() argument
1411 if (time_is_before_jiffies(bfqd->last_ins_in_burst + in bfq_handle_burst()
1412 bfqd->bfq_burst_interval) || in bfq_handle_burst()
1413 bfqq->entity.parent != bfqd->burst_parent_entity) { in bfq_handle_burst()
1414 bfqd->large_burst = false; in bfq_handle_burst()
1415 bfq_reset_burst_list(bfqd, bfqq); in bfq_handle_burst()
1424 if (bfqd->large_burst) { in bfq_handle_burst()
1434 bfq_add_to_burst(bfqd, bfqq); in bfq_handle_burst()
1444 bfqd->last_ins_in_burst = jiffies; in bfq_handle_burst()
1459 static int bfq_max_budget(struct bfq_data *bfqd) in bfq_max_budget() argument
1461 if (bfqd->budgets_assigned < bfq_stats_min_budgets) in bfq_max_budget()
1464 return bfqd->bfq_max_budget; in bfq_max_budget()
1471 static int bfq_min_budget(struct bfq_data *bfqd) in bfq_min_budget() argument
1473 if (bfqd->budgets_assigned < bfq_stats_min_budgets) in bfq_min_budget()
1476 return bfqd->bfq_max_budget / 32; in bfq_min_budget()
1583 static bool bfq_bfqq_update_budg_for_activation(struct bfq_data *bfqd, in bfq_bfqq_update_budg_for_activation() argument
1652 static void bfq_update_bfqq_wr_on_rq_arrival(struct bfq_data *bfqd, in bfq_update_bfqq_wr_on_rq_arrival() argument
1664 bfqq->wr_coeff = bfqd->bfq_wr_coeff; in bfq_update_bfqq_wr_on_rq_arrival()
1665 bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); in bfq_update_bfqq_wr_on_rq_arrival()
1680 bfqq->wr_coeff = bfqd->bfq_wr_coeff * in bfq_update_bfqq_wr_on_rq_arrival()
1683 bfqd->bfq_wr_rt_max_time; in bfq_update_bfqq_wr_on_rq_arrival()
1697 2 * bfq_min_budget(bfqd)); in bfq_update_bfqq_wr_on_rq_arrival()
1700 bfqq->wr_coeff = bfqd->bfq_wr_coeff; in bfq_update_bfqq_wr_on_rq_arrival()
1701 bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); in bfq_update_bfqq_wr_on_rq_arrival()
1735 bfqd->bfq_wr_rt_max_time) { in bfq_update_bfqq_wr_on_rq_arrival()
1740 bfqd->bfq_wr_rt_max_time; in bfq_update_bfqq_wr_on_rq_arrival()
1741 bfqq->wr_coeff = bfqd->bfq_wr_coeff * in bfq_update_bfqq_wr_on_rq_arrival()
1749 static bool bfq_bfqq_idle_for_long_time(struct bfq_data *bfqd, in bfq_bfqq_idle_for_long_time() argument
1755 bfqd->bfq_wr_min_idle_time); in bfq_bfqq_idle_for_long_time()
1791 static unsigned int bfq_actuator_index(struct bfq_data *bfqd, struct bio *bio) in bfq_actuator_index() argument
1797 if (bfqd->num_actuators == 1) in bfq_actuator_index()
1803 for (i = 0; i < bfqd->num_actuators; i++) { in bfq_actuator_index()
1804 if (end >= bfqd->sector[i] && in bfq_actuator_index()
1805 end < bfqd->sector[i] + bfqd->nr_sectors[i]) in bfq_actuator_index()
1817 static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, in bfq_bfqq_handle_idle_busy_switch() argument
1825 idle_for_long_time = bfq_bfqq_idle_for_long_time(bfqd, bfqq), in bfq_bfqq_handle_idle_busy_switch()
1833 bfqd->bfq_slice_idle * 3; in bfq_bfqq_handle_idle_busy_switch()
1834 unsigned int act_idx = bfq_actuator_index(bfqd, rq->bio); in bfq_bfqq_handle_idle_busy_switch()
1848 soft_rt = bfqd->bfq_wr_max_softrt_rate > 0 && in bfq_bfqq_handle_idle_busy_switch()
1868 wr_or_deserves_wr = bfqd->low_latency && in bfq_bfqq_handle_idle_busy_switch()
1878 bfq_bfqq_update_budg_for_activation(bfqd, bfqq, in bfq_bfqq_handle_idle_busy_switch()
1905 if (bfqd->low_latency) { in bfq_bfqq_handle_idle_busy_switch()
1909 jiffies - bfqd->bfq_wr_min_idle_time - 1; in bfq_bfqq_handle_idle_busy_switch()
1912 bfqd->bfq_wr_min_idle_time)) { in bfq_bfqq_handle_idle_busy_switch()
1913 bfq_update_bfqq_wr_on_rq_arrival(bfqd, bfqq, in bfq_bfqq_handle_idle_busy_switch()
1974 if (bfqd->in_service_queue && in bfq_bfqq_handle_idle_busy_switch()
1976 bfqq->wr_coeff >= bfqd->in_service_queue->wr_coeff) || in bfq_bfqq_handle_idle_busy_switch()
1977 bfq_bfqq_higher_class_or_weight(bfqq, bfqd->in_service_queue) || in bfq_bfqq_handle_idle_busy_switch()
1978 !bfq_better_to_idle(bfqd->in_service_queue)) && in bfq_bfqq_handle_idle_busy_switch()
1979 next_queue_may_preempt(bfqd)) in bfq_bfqq_handle_idle_busy_switch()
1980 bfq_bfqq_expire(bfqd, bfqd->in_service_queue, in bfq_bfqq_handle_idle_busy_switch()
1984 static void bfq_reset_inject_limit(struct bfq_data *bfqd, in bfq_reset_inject_limit() argument
1994 bfqd->waited_rq = NULL; in bfq_reset_inject_limit()
2131 static void bfq_check_waker(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_check_waker() argument
2136 if (!bfqd->last_completed_rq_bfqq || in bfq_check_waker()
2137 bfqd->last_completed_rq_bfqq == bfqq || in bfq_check_waker()
2139 now_ns - bfqd->last_completion >= 4 * NSEC_PER_MSEC || in bfq_check_waker()
2140 bfqd->last_completed_rq_bfqq == &bfqd->oom_bfqq || in bfq_check_waker()
2141 bfqq == &bfqd->oom_bfqq) in bfq_check_waker()
2150 if (bfqd->last_completed_rq_bfqq != in bfq_check_waker()
2153 128 * (u64)bfqd->bfq_slice_idle) { in bfq_check_waker()
2160 bfqd->last_completed_rq_bfqq; in bfq_check_waker()
2165 bfq_log_bfqq(bfqd, bfqq, "set tentative waker %s", waker_name); in bfq_check_waker()
2170 bfqq->waker_bfqq = bfqd->last_completed_rq_bfqq; in bfq_check_waker()
2174 bfq_log_bfqq(bfqd, bfqq, "set waker %s", waker_name); in bfq_check_waker()
2199 &bfqd->last_completed_rq_bfqq->woken_list); in bfq_check_waker()
2206 struct bfq_data *bfqd = bfqq->bfqd; in bfq_add_request() local
2212 bfq_log_bfqq(bfqd, bfqq, "add_request %d", rq_is_sync(rq)); in bfq_add_request()
2218 WRITE_ONCE(bfqd->queued, bfqd->queued + 1); in bfq_add_request()
2221 bfq_check_waker(bfqd, bfqq, now_ns); in bfq_add_request()
2231 bfq_reset_inject_limit(bfqd, bfqq); in bfq_add_request()
2258 if (bfqq == bfqd->in_service_queue && in bfq_add_request()
2259 (bfqd->tot_rq_in_driver == 0 || in bfq_add_request()
2261 bfqd->rqs_injected && bfqd->tot_rq_in_driver > 0)) && in bfq_add_request()
2264 bfqd->last_empty_occupied_ns = ktime_get_ns(); in bfq_add_request()
2271 bfqd->wait_dispatch = true; in bfq_add_request()
2285 if (bfqd->tot_rq_in_driver == 0) in bfq_add_request()
2286 bfqd->rqs_injected = false; in bfq_add_request()
2299 next_rq = bfq_choose_req(bfqd, bfqq->next_rq, rq, bfqd->last_position); in bfq_add_request()
2306 if (unlikely(!bfqd->nonrot_with_queueing && prev != bfqq->next_rq)) in bfq_add_request()
2307 bfq_pos_tree_add_move(bfqd, bfqq); in bfq_add_request()
2310 bfq_bfqq_handle_idle_busy_switch(bfqd, bfqq, old_wr_coeff, in bfq_add_request()
2313 if (bfqd->low_latency && old_wr_coeff == 1 && !rq_is_sync(rq) && in bfq_add_request()
2316 bfqd->bfq_wr_min_inter_arr_async)) { in bfq_add_request()
2317 bfqq->wr_coeff = bfqd->bfq_wr_coeff; in bfq_add_request()
2318 bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); in bfq_add_request()
2320 bfqd->wr_busy_queues++; in bfq_add_request()
2324 bfq_updated_next_req(bfqd, bfqq); in bfq_add_request()
2353 if (bfqd->low_latency && in bfq_add_request()
2358 static struct request *bfq_find_rq_fmerge(struct bfq_data *bfqd, in bfq_find_rq_fmerge() argument
2362 struct bfq_queue *bfqq = bfqd->bio_bfqq; in bfq_find_rq_fmerge()
2383 struct bfq_data *bfqd = bfqq->bfqd; in bfq_remove_request() local
2387 bfqq->next_rq = bfq_find_next_rq(bfqd, bfqq, rq); in bfq_remove_request()
2388 bfq_updated_next_req(bfqd, bfqq); in bfq_remove_request()
2398 WRITE_ONCE(bfqd->queued, bfqd->queued - 1); in bfq_remove_request()
2408 if (bfq_bfqq_busy(bfqq) && bfqq != bfqd->in_service_queue) { in bfq_remove_request()
2435 if (unlikely(!bfqd->nonrot_with_queueing)) in bfq_remove_request()
2436 bfq_pos_tree_add_move(bfqd, bfqq); in bfq_remove_request()
2447 struct bfq_data *bfqd = q->elevator->elevator_data; in bfq_bio_merge() local
2459 spin_lock_irq(&bfqd->lock); in bfq_bio_merge()
2468 bfqd->bio_bfqq = bic_to_bfqq(bic, op_is_sync(bio->bi_opf), in bfq_bio_merge()
2469 bfq_actuator_index(bfqd, bio)); in bfq_bio_merge()
2471 bfqd->bio_bfqq = NULL; in bfq_bio_merge()
2473 bfqd->bio_bic = bic; in bfq_bio_merge()
2477 spin_unlock_irq(&bfqd->lock); in bfq_bio_merge()
2487 struct bfq_data *bfqd = q->elevator->elevator_data; in bfq_request_merge() local
2490 __rq = bfq_find_rq_fmerge(bfqd, bio, q); in bfq_request_merge()
2511 struct bfq_data *bfqd; in bfq_request_merged() local
2517 bfqd = bfqq->bfqd; in bfq_request_merged()
2525 next_rq = bfq_choose_req(bfqd, bfqq->next_rq, req, in bfq_request_merged()
2526 bfqd->last_position); in bfq_request_merged()
2534 bfq_updated_next_req(bfqd, bfqq); in bfq_request_merged()
2539 if (unlikely(!bfqd->nonrot_with_queueing)) in bfq_request_merged()
2540 bfq_pos_tree_add_move(bfqd, bfqq); in bfq_request_merged()
2617 bfqq->bfqd->bfq_wr_rt_max_time) in bfq_bfqq_end_wr()
2621 bfqq->bfqd->wr_busy_queues--; in bfq_bfqq_end_wr()
2632 void bfq_end_wr_async_queues(struct bfq_data *bfqd, in bfq_end_wr_async_queues() argument
2637 for (k = 0; k < bfqd->num_actuators; k++) { in bfq_end_wr_async_queues()
2647 static void bfq_end_wr(struct bfq_data *bfqd) in bfq_end_wr() argument
2652 spin_lock_irq(&bfqd->lock); in bfq_end_wr()
2654 for (i = 0; i < bfqd->num_actuators; i++) { in bfq_end_wr()
2655 list_for_each_entry(bfqq, &bfqd->active_list[i], bfqq_list) in bfq_end_wr()
2658 list_for_each_entry(bfqq, &bfqd->idle_list, bfqq_list) in bfq_end_wr()
2660 bfq_end_wr_async(bfqd); in bfq_end_wr()
2662 spin_unlock_irq(&bfqd->lock); in bfq_end_wr()
2680 static struct bfq_queue *bfqq_find_close(struct bfq_data *bfqd, in bfqq_find_close() argument
2695 __bfqq = bfq_rq_pos_tree_lookup(bfqd, root, sector, &parent, NULL); in bfqq_find_close()
2722 static struct bfq_queue *bfq_find_close_cooperator(struct bfq_data *bfqd, in bfq_find_close_cooperator() argument
2735 bfqq = bfqq_find_close(bfqd, cur_bfqq, sector); in bfq_find_close_cooperator()
2781 bfq_log_bfqq(bfqq->bfqd, bfqq, "scheduling merge with queue %d", in bfq_setup_merge()
2847 static bool idling_boosts_thr_without_issues(struct bfq_data *bfqd,
2851 bfq_setup_stable_merge(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_setup_stable_merge() argument
2860 if (idling_boosts_thr_without_issues(bfqd, bfqq) || proc_ref == 0) in bfq_setup_stable_merge()
2905 bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_setup_cooperator() argument
2925 if (unlikely(!bfqd->nonrot_with_queueing)) { in bfq_setup_cooperator()
2941 return bfq_setup_stable_merge(bfqd, bfqq, in bfq_setup_cooperator()
2984 if (likely(bfqd->nonrot_with_queueing)) in bfq_setup_cooperator()
3001 if (!io_struct || unlikely(bfqq == &bfqd->oom_bfqq)) in bfq_setup_cooperator()
3005 if (bfq_tot_busy_queues(bfqd) == 1) in bfq_setup_cooperator()
3008 in_service_bfqq = bfqd->in_service_queue; in bfq_setup_cooperator()
3011 likely(in_service_bfqq != &bfqd->oom_bfqq) && in bfq_setup_cooperator()
3013 bfqd->in_serv_last_pos) && in bfq_setup_cooperator()
3025 new_bfqq = bfq_find_close_cooperator(bfqd, bfqq, in bfq_setup_cooperator()
3028 if (new_bfqq && likely(new_bfqq != &bfqd->oom_bfqq) && in bfq_setup_cooperator()
3066 bfqq->bfqd->low_latency)) { in bfq_bfqq_save_state()
3076 bfqq_data->saved_wr_coeff = bfqq->bfqd->bfq_wr_coeff; in bfq_bfqq_save_state()
3080 bfq_wr_duration(bfqq->bfqd); in bfq_bfqq_save_state()
3101 else if (cur_bfqq->bfqd && cur_bfqq->bfqd->last_bfqq_created == cur_bfqq) in bfq_reassign_last_bfqq()
3102 cur_bfqq->bfqd->last_bfqq_created = new_bfqq; in bfq_reassign_last_bfqq()
3105 void bfq_release_process_ref(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_release_process_ref() argument
3119 bfqq != bfqd->in_service_queue) in bfq_release_process_ref()
3128 bfq_merge_bfqqs(struct bfq_data *bfqd, struct bfq_io_cq *bic, in bfq_merge_bfqqs() argument
3131 bfq_log_bfqq(bfqd, bfqq, "merging with queue %lu", in bfq_merge_bfqqs()
3179 bfqd->wr_busy_queues++; in bfq_merge_bfqqs()
3187 bfqd->wr_busy_queues--; in bfq_merge_bfqqs()
3190 bfq_log_bfqq(bfqd, new_bfqq, "merge_bfqqs: wr_busy %d", in bfq_merge_bfqqs()
3191 bfqd->wr_busy_queues); in bfq_merge_bfqqs()
3223 bfq_release_process_ref(bfqd, bfqq); in bfq_merge_bfqqs()
3229 struct bfq_data *bfqd = q->elevator->elevator_data; in bfq_allow_bio_merge() local
3231 struct bfq_queue *bfqq = bfqd->bio_bfqq, *new_bfqq; in bfq_allow_bio_merge()
3250 new_bfqq = bfq_setup_cooperator(bfqd, bfqq, bio, false, bfqd->bio_bic); in bfq_allow_bio_merge()
3259 bfq_merge_bfqqs(bfqd, bfqd->bio_bic, bfqq, in bfq_allow_bio_merge()
3274 bfqd->bio_bfqq = bfqq; in bfq_allow_bio_merge()
3286 static void bfq_set_budget_timeout(struct bfq_data *bfqd, in bfq_set_budget_timeout() argument
3291 if (bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time) in bfq_set_budget_timeout()
3296 bfqd->last_budget_start = ktime_get(); in bfq_set_budget_timeout()
3299 bfqd->bfq_timeout * timeout_coeff; in bfq_set_budget_timeout()
3302 static void __bfq_set_in_service_queue(struct bfq_data *bfqd, in __bfq_set_in_service_queue() argument
3308 bfqd->budgets_assigned = (bfqd->budgets_assigned * 7 + 256) / 8; in __bfq_set_in_service_queue()
3312 bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time && in __bfq_set_in_service_queue()
3346 bfq_set_budget_timeout(bfqd, bfqq); in __bfq_set_in_service_queue()
3347 bfq_log_bfqq(bfqd, bfqq, in __bfq_set_in_service_queue()
3352 bfqd->in_service_queue = bfqq; in __bfq_set_in_service_queue()
3353 bfqd->in_serv_last_pos = 0; in __bfq_set_in_service_queue()
3359 static struct bfq_queue *bfq_set_in_service_queue(struct bfq_data *bfqd) in bfq_set_in_service_queue() argument
3361 struct bfq_queue *bfqq = bfq_get_next_queue(bfqd); in bfq_set_in_service_queue()
3363 __bfq_set_in_service_queue(bfqd, bfqq); in bfq_set_in_service_queue()
3367 static void bfq_arm_slice_timer(struct bfq_data *bfqd) in bfq_arm_slice_timer() argument
3369 struct bfq_queue *bfqq = bfqd->in_service_queue; in bfq_arm_slice_timer()
3379 sl = bfqd->bfq_slice_idle; in bfq_arm_slice_timer()
3391 !bfq_asymmetric_scenario(bfqd, bfqq)) in bfq_arm_slice_timer()
3396 bfqd->last_idling_start = ktime_get(); in bfq_arm_slice_timer()
3397 bfqd->last_idling_start_jiffies = jiffies; in bfq_arm_slice_timer()
3399 hrtimer_start(&bfqd->idle_slice_timer, ns_to_ktime(sl), in bfq_arm_slice_timer()
3411 static unsigned long bfq_calc_max_budget(struct bfq_data *bfqd) in bfq_calc_max_budget() argument
3413 return (u64)bfqd->peak_rate * USEC_PER_MSEC * in bfq_calc_max_budget()
3414 jiffies_to_msecs(bfqd->bfq_timeout)>>BFQ_RATE_SHIFT; in bfq_calc_max_budget()
3422 static void update_thr_responsiveness_params(struct bfq_data *bfqd) in update_thr_responsiveness_params() argument
3424 if (bfqd->bfq_user_max_budget == 0) { in update_thr_responsiveness_params()
3425 bfqd->bfq_max_budget = in update_thr_responsiveness_params()
3426 bfq_calc_max_budget(bfqd); in update_thr_responsiveness_params()
3427 bfq_log(bfqd, "new max_budget = %d", bfqd->bfq_max_budget); in update_thr_responsiveness_params()
3431 static void bfq_reset_rate_computation(struct bfq_data *bfqd, in bfq_reset_rate_computation() argument
3435 bfqd->last_dispatch = bfqd->first_dispatch = ktime_get_ns(); in bfq_reset_rate_computation()
3436 bfqd->peak_rate_samples = 1; in bfq_reset_rate_computation()
3437 bfqd->sequential_samples = 0; in bfq_reset_rate_computation()
3438 bfqd->tot_sectors_dispatched = bfqd->last_rq_max_size = in bfq_reset_rate_computation()
3441 bfqd->peak_rate_samples = 0; /* full re-init on next disp. */ in bfq_reset_rate_computation()
3443 bfq_log(bfqd, in bfq_reset_rate_computation()
3445 bfqd->peak_rate_samples, bfqd->sequential_samples, in bfq_reset_rate_computation()
3446 bfqd->tot_sectors_dispatched); in bfq_reset_rate_computation()
3449 static void bfq_update_rate_reset(struct bfq_data *bfqd, struct request *rq) in bfq_update_rate_reset() argument
3461 if (bfqd->peak_rate_samples < BFQ_RATE_MIN_SAMPLES || in bfq_update_rate_reset()
3462 bfqd->delta_from_first < BFQ_RATE_MIN_INTERVAL) in bfq_update_rate_reset()
3471 bfqd->delta_from_first = in bfq_update_rate_reset()
3472 max_t(u64, bfqd->delta_from_first, in bfq_update_rate_reset()
3473 bfqd->last_completion - bfqd->first_dispatch); in bfq_update_rate_reset()
3479 rate = div64_ul(bfqd->tot_sectors_dispatched<<BFQ_RATE_SHIFT, in bfq_update_rate_reset()
3480 div_u64(bfqd->delta_from_first, NSEC_PER_USEC)); in bfq_update_rate_reset()
3488 if ((bfqd->sequential_samples < (3 * bfqd->peak_rate_samples)>>2 && in bfq_update_rate_reset()
3489 rate <= bfqd->peak_rate) || in bfq_update_rate_reset()
3516 weight = (9 * bfqd->sequential_samples) / bfqd->peak_rate_samples; in bfq_update_rate_reset()
3523 div_u64(weight * bfqd->delta_from_first, in bfq_update_rate_reset()
3537 bfqd->peak_rate *= divisor-1; in bfq_update_rate_reset()
3538 bfqd->peak_rate /= divisor; in bfq_update_rate_reset()
3541 bfqd->peak_rate += rate; in bfq_update_rate_reset()
3550 bfqd->peak_rate = max_t(u32, 1, bfqd->peak_rate); in bfq_update_rate_reset()
3552 update_thr_responsiveness_params(bfqd); in bfq_update_rate_reset()
3555 bfq_reset_rate_computation(bfqd, rq); in bfq_update_rate_reset()
3590 static void bfq_update_peak_rate(struct bfq_data *bfqd, struct request *rq) in bfq_update_peak_rate() argument
3594 if (bfqd->peak_rate_samples == 0) { /* first dispatch */ in bfq_update_peak_rate()
3595 bfq_log(bfqd, "update_peak_rate: goto reset, samples %d", in bfq_update_peak_rate()
3596 bfqd->peak_rate_samples); in bfq_update_peak_rate()
3597 bfq_reset_rate_computation(bfqd, rq); in bfq_update_peak_rate()
3613 if (now_ns - bfqd->last_dispatch > 100*NSEC_PER_MSEC && in bfq_update_peak_rate()
3614 bfqd->tot_rq_in_driver == 0) in bfq_update_peak_rate()
3618 bfqd->peak_rate_samples++; in bfq_update_peak_rate()
3620 if ((bfqd->tot_rq_in_driver > 0 || in bfq_update_peak_rate()
3621 now_ns - bfqd->last_completion < BFQ_MIN_TT) in bfq_update_peak_rate()
3622 && !BFQ_RQ_SEEKY(bfqd, bfqd->last_position, rq)) in bfq_update_peak_rate()
3623 bfqd->sequential_samples++; in bfq_update_peak_rate()
3625 bfqd->tot_sectors_dispatched += blk_rq_sectors(rq); in bfq_update_peak_rate()
3628 if (likely(bfqd->peak_rate_samples % 32)) in bfq_update_peak_rate()
3629 bfqd->last_rq_max_size = in bfq_update_peak_rate()
3630 max_t(u32, blk_rq_sectors(rq), bfqd->last_rq_max_size); in bfq_update_peak_rate()
3632 bfqd->last_rq_max_size = blk_rq_sectors(rq); in bfq_update_peak_rate()
3634 bfqd->delta_from_first = now_ns - bfqd->first_dispatch; in bfq_update_peak_rate()
3637 if (bfqd->delta_from_first < BFQ_RATE_REF_INTERVAL) in bfq_update_peak_rate()
3641 bfq_update_rate_reset(bfqd, rq); in bfq_update_peak_rate()
3643 bfqd->last_position = blk_rq_pos(rq) + blk_rq_sectors(rq); in bfq_update_peak_rate()
3644 if (RQ_BFQQ(rq) == bfqd->in_service_queue) in bfq_update_peak_rate()
3645 bfqd->in_serv_last_pos = bfqd->last_position; in bfq_update_peak_rate()
3646 bfqd->last_dispatch = now_ns; in bfq_update_peak_rate()
3875 static bool idling_needed_for_service_guarantees(struct bfq_data *bfqd, in idling_needed_for_service_guarantees() argument
3878 int tot_busy_queues = bfq_tot_busy_queues(bfqd); in idling_needed_for_service_guarantees()
3885 (bfqd->wr_busy_queues < tot_busy_queues || in idling_needed_for_service_guarantees()
3886 bfqd->tot_rq_in_driver >= bfqq->dispatched + 4)) || in idling_needed_for_service_guarantees()
3887 bfq_asymmetric_scenario(bfqd, bfqq) || in idling_needed_for_service_guarantees()
3891 static bool __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq, in __bfq_bfqq_expire() argument
3918 idling_needed_for_service_guarantees(bfqd, bfqq))) { in __bfq_bfqq_expire()
3930 bfq_requeue_bfqq(bfqd, bfqq, true); in __bfq_bfqq_expire()
3935 if (unlikely(!bfqd->nonrot_with_queueing && in __bfq_bfqq_expire()
3937 bfq_pos_tree_add_move(bfqd, bfqq); in __bfq_bfqq_expire()
3947 return __bfq_bfqd_reset_in_service(bfqd); in __bfq_bfqq_expire()
3959 static void __bfq_bfqq_recalc_budget(struct bfq_data *bfqd, in __bfq_bfqq_recalc_budget() argument
3966 min_budget = bfq_min_budget(bfqd); in __bfq_bfqq_recalc_budget()
3978 bfq_log_bfqq(bfqd, bfqq, "recalc_budg: last budg %d, budg left %d", in __bfq_bfqq_recalc_budget()
3980 bfq_log_bfqq(bfqd, bfqq, "recalc_budg: last max_budg %d, min budg %d", in __bfq_bfqq_recalc_budget()
3981 budget, bfq_min_budget(bfqd)); in __bfq_bfqq_recalc_budget()
3982 bfq_log_bfqq(bfqd, bfqq, "recalc_budg: sync %d, seeky %d", in __bfq_bfqq_recalc_budget()
3983 bfq_bfqq_sync(bfqq), BFQQ_SEEKY(bfqd->in_service_queue)); in __bfq_bfqq_recalc_budget()
4017 budget = min(budget * 2, bfqd->bfq_max_budget); in __bfq_bfqq_recalc_budget()
4032 budget = min(budget * 2, bfqd->bfq_max_budget); in __bfq_bfqq_recalc_budget()
4044 budget = min(budget * 4, bfqd->bfq_max_budget); in __bfq_bfqq_recalc_budget()
4091 budget = bfqd->bfq_max_budget; in __bfq_bfqq_recalc_budget()
4096 if (bfqd->budgets_assigned >= bfq_stats_min_budgets && in __bfq_bfqq_recalc_budget()
4097 !bfqd->bfq_user_max_budget) in __bfq_bfqq_recalc_budget()
4098 bfqq->max_budget = min(bfqq->max_budget, bfqd->bfq_max_budget); in __bfq_bfqq_recalc_budget()
4115 bfq_log_bfqq(bfqd, bfqq, "head sect: %u, new budget %d", in __bfq_bfqq_recalc_budget()
4151 static bool bfq_bfqq_is_slow(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_bfqq_is_slow() argument
4162 delta_ktime = bfqd->last_idling_start; in bfq_bfqq_is_slow()
4165 delta_ktime = ktime_sub(delta_ktime, bfqd->last_budget_start); in bfq_bfqq_is_slow()
4170 if (blk_queue_nonrot(bfqd->queue)) in bfq_bfqq_is_slow()
4199 slow = bfqq->entity.service < bfqd->bfq_max_budget / 2; in bfq_bfqq_is_slow()
4202 bfq_log_bfqq(bfqd, bfqq, "bfq_bfqq_is_slow: slow %d", slow); in bfq_bfqq_is_slow()
4300 static unsigned long bfq_bfqq_softrt_next_start(struct bfq_data *bfqd, in bfq_bfqq_softrt_next_start() argument
4306 bfqd->bfq_wr_max_softrt_rate, in bfq_bfqq_softrt_next_start()
4307 jiffies + nsecs_to_jiffies(bfqq->bfqd->bfq_slice_idle) + 4); in bfq_bfqq_softrt_next_start()
4336 void bfq_bfqq_expire(struct bfq_data *bfqd, in bfq_bfqq_expire() argument
4348 slow = bfq_bfqq_is_slow(bfqd, bfqq, compensate, &delta); in bfq_bfqq_expire()
4369 bfq_bfqq_charge_time(bfqd, bfqq, delta); in bfq_bfqq_expire()
4371 if (bfqd->low_latency && bfqq->wr_coeff == 1) in bfq_bfqq_expire()
4374 if (bfqd->low_latency && bfqd->bfq_wr_max_softrt_rate > 0 && in bfq_bfqq_expire()
4390 bfq_bfqq_softrt_next_start(bfqd, bfqq); in bfq_bfqq_expire()
4400 bfq_log_bfqq(bfqd, bfqq, in bfq_bfqq_expire()
4409 bfqd->rqs_injected = bfqd->wait_dispatch = false; in bfq_bfqq_expire()
4410 bfqd->waited_rq = NULL; in bfq_bfqq_expire()
4416 __bfq_bfqq_recalc_budget(bfqd, bfqq, reason); in bfq_bfqq_expire()
4417 if (__bfq_bfqq_expire(bfqd, bfqq, reason)) in bfq_bfqq_expire()
4476 bfq_log_bfqq(bfqq->bfqd, bfqq, in bfq_may_expire_for_budg_timeout()
4488 static bool idling_boosts_thr_without_issues(struct bfq_data *bfqd, in idling_boosts_thr_without_issues() argument
4492 !blk_queue_nonrot(bfqd->queue) && !bfqd->hw_tag, in idling_boosts_thr_without_issues()
4526 ((!blk_queue_nonrot(bfqd->queue) || !bfqd->hw_tag) && in idling_boosts_thr_without_issues()
4564 bfqd->wr_busy_queues == 0; in idling_boosts_thr_without_issues()
4590 struct bfq_data *bfqd = bfqq->bfqd; in bfq_better_to_idle() local
4597 if (unlikely(bfqd->strict_guarantees)) in bfq_better_to_idle()
4608 if (bfqd->bfq_slice_idle == 0 || !bfq_bfqq_sync(bfqq) || in bfq_better_to_idle()
4613 idling_boosts_thr_without_issues(bfqd, bfqq); in bfq_better_to_idle()
4616 idling_needed_for_service_guarantees(bfqd, bfqq); in bfq_better_to_idle()
4652 bfq_choose_bfqq_for_injection(struct bfq_data *bfqd) in bfq_choose_bfqq_for_injection() argument
4654 struct bfq_queue *bfqq, *in_serv_bfqq = bfqd->in_service_queue; in bfq_choose_bfqq_for_injection()
4684 time_is_before_eq_jiffies(bfqd->last_idling_start_jiffies + in bfq_choose_bfqq_for_injection()
4685 bfqd->bfq_slice_idle) in bfq_choose_bfqq_for_injection()
4689 if (bfqd->tot_rq_in_driver >= limit) in bfq_choose_bfqq_for_injection()
4704 for (i = 0; i < bfqd->num_actuators; i++) { in bfq_choose_bfqq_for_injection()
4705 list_for_each_entry(bfqq, &bfqd->active_list[i], bfqq_list) in bfq_choose_bfqq_for_injection()
4727 if (blk_queue_nonrot(bfqd->queue) && in bfq_choose_bfqq_for_injection()
4730 bfqd->tot_rq_in_driver >= 1) in bfq_choose_bfqq_for_injection()
4733 bfqd->rqs_injected = true; in bfq_choose_bfqq_for_injection()
4743 bfq_find_active_bfqq_for_actuator(struct bfq_data *bfqd, int idx) in bfq_find_active_bfqq_for_actuator() argument
4747 if (bfqd->in_service_queue && in bfq_find_active_bfqq_for_actuator()
4748 bfqd->in_service_queue->actuator_idx == idx) in bfq_find_active_bfqq_for_actuator()
4749 return bfqd->in_service_queue; in bfq_find_active_bfqq_for_actuator()
4751 list_for_each_entry(bfqq, &bfqd->active_list[idx], bfqq_list) { in bfq_find_active_bfqq_for_actuator()
4776 bfq_find_bfqq_for_underused_actuator(struct bfq_data *bfqd) in bfq_find_bfqq_for_underused_actuator() argument
4780 for (i = 0 ; i < bfqd->num_actuators; i++) { in bfq_find_bfqq_for_underused_actuator()
4781 if (bfqd->rq_in_driver[i] < bfqd->actuator_load_threshold && in bfq_find_bfqq_for_underused_actuator()
4782 (i == bfqd->num_actuators - 1 || in bfq_find_bfqq_for_underused_actuator()
4783 bfqd->rq_in_driver[i] < bfqd->rq_in_driver[i+1])) { in bfq_find_bfqq_for_underused_actuator()
4785 bfq_find_active_bfqq_for_actuator(bfqd, i); in bfq_find_bfqq_for_underused_actuator()
4800 static struct bfq_queue *bfq_select_queue(struct bfq_data *bfqd) in bfq_select_queue() argument
4806 bfqq = bfqd->in_service_queue; in bfq_select_queue()
4810 bfq_log_bfqq(bfqd, bfqq, "select_queue: already in-service queue"); in bfq_select_queue()
4829 inject_bfqq = bfq_find_bfqq_for_underused_actuator(bfqd); in bfq_select_queue()
4876 hrtimer_try_to_cancel(&bfqd->idle_slice_timer); in bfq_select_queue()
5006 else if (!idling_boosts_thr_without_issues(bfqd, bfqq) && in bfq_select_queue()
5007 (bfqq->wr_coeff == 1 || bfqd->wr_busy_queues > 1 || in bfq_select_queue()
5009 bfqq = bfq_choose_bfqq_for_injection(bfqd); in bfq_select_queue()
5018 bfq_bfqq_expire(bfqd, bfqq, false, reason); in bfq_select_queue()
5020 bfqq = bfq_set_in_service_queue(bfqd); in bfq_select_queue()
5022 bfq_log_bfqq(bfqd, bfqq, "select_queue: checking new queue"); in bfq_select_queue()
5027 bfq_log_bfqq(bfqd, bfqq, "select_queue: returned this queue"); in bfq_select_queue()
5029 bfq_log(bfqd, "select_queue: no queue returned"); in bfq_select_queue()
5034 static void bfq_update_wr_data(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_update_wr_data() argument
5039 bfq_log_bfqq(bfqd, bfqq, in bfq_update_wr_data()
5047 bfq_log_bfqq(bfqd, bfqq, "WARN: pending prio change"); in bfq_update_wr_data()
5058 if (bfqq->wr_cur_max_time != bfqd->bfq_wr_rt_max_time || in bfq_update_wr_data()
5060 bfq_wr_duration(bfqd))) { in bfq_update_wr_data()
5075 switch_back_to_interactive_wr(bfqq, bfqd); in bfq_update_wr_data()
5080 bfqq->wr_cur_max_time != bfqd->bfq_wr_rt_max_time && in bfq_update_wr_data()
5102 static struct request *bfq_dispatch_rq_from_bfqq(struct bfq_data *bfqd, in bfq_dispatch_rq_from_bfqq() argument
5112 if (bfqq == bfqd->in_service_queue && bfqd->wait_dispatch) { in bfq_dispatch_rq_from_bfqq()
5113 bfqd->wait_dispatch = false; in bfq_dispatch_rq_from_bfqq()
5114 bfqd->waited_rq = rq; in bfq_dispatch_rq_from_bfqq()
5117 bfq_dispatch_remove(bfqd->queue, rq); in bfq_dispatch_rq_from_bfqq()
5119 if (bfqq != bfqd->in_service_queue) in bfq_dispatch_rq_from_bfqq()
5133 bfq_update_wr_data(bfqd, bfqq); in bfq_dispatch_rq_from_bfqq()
5140 if (bfq_tot_busy_queues(bfqd) > 1 && bfq_class_idle(bfqq)) in bfq_dispatch_rq_from_bfqq()
5141 bfq_bfqq_expire(bfqd, bfqq, false, BFQQE_BUDGET_EXHAUSTED); in bfq_dispatch_rq_from_bfqq()
5148 struct bfq_data *bfqd = hctx->queue->elevator->elevator_data; in bfq_has_work() local
5154 return !list_empty_careful(&bfqd->dispatch) || in bfq_has_work()
5155 READ_ONCE(bfqd->queued); in bfq_has_work()
5160 struct bfq_data *bfqd = hctx->queue->elevator->elevator_data; in __bfq_dispatch_request() local
5164 if (!list_empty(&bfqd->dispatch)) { in __bfq_dispatch_request()
5165 rq = list_first_entry(&bfqd->dispatch, struct request, in __bfq_dispatch_request()
5209 bfq_log(bfqd, "dispatch requests: %d busy queues", in __bfq_dispatch_request()
5210 bfq_tot_busy_queues(bfqd)); in __bfq_dispatch_request()
5212 if (bfq_tot_busy_queues(bfqd) == 0) in __bfq_dispatch_request()
5227 if (bfqd->strict_guarantees && bfqd->tot_rq_in_driver > 0) in __bfq_dispatch_request()
5230 bfqq = bfq_select_queue(bfqd); in __bfq_dispatch_request()
5234 rq = bfq_dispatch_rq_from_bfqq(bfqd, bfqq); in __bfq_dispatch_request()
5238 bfqd->rq_in_driver[bfqq->actuator_idx]++; in __bfq_dispatch_request()
5239 bfqd->tot_rq_in_driver++; in __bfq_dispatch_request()
5301 struct bfq_data *bfqd = hctx->queue->elevator->elevator_data; in bfq_dispatch_request() local
5306 spin_lock_irq(&bfqd->lock); in bfq_dispatch_request()
5308 in_serv_queue = bfqd->in_service_queue; in bfq_dispatch_request()
5312 if (in_serv_queue == bfqd->in_service_queue) { in bfq_dispatch_request()
5317 spin_unlock_irq(&bfqd->lock); in bfq_dispatch_request()
5338 bfq_log_bfqq(bfqq->bfqd, bfqq, "put_queue: %p %d", bfqq, bfqq->ref); in bfq_put_queue()
5372 if (bfqq->bic && bfqq->bfqd->burst_size > 0) in bfq_put_queue()
5373 bfqq->bfqd->burst_size--; in bfq_put_queue()
5402 if (bfqq->bfqd->last_completed_rq_bfqq == bfqq) in bfq_put_queue()
5403 bfqq->bfqd->last_completed_rq_bfqq = NULL; in bfq_put_queue()
5432 static void bfq_exit_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_exit_bfqq() argument
5434 if (bfqq == bfqd->in_service_queue) { in bfq_exit_bfqq()
5435 __bfq_bfqq_expire(bfqd, bfqq, BFQQE_BUDGET_TIMEOUT); in bfq_exit_bfqq()
5436 bfq_schedule_dispatch(bfqd); in bfq_exit_bfqq()
5439 bfq_log_bfqq(bfqd, bfqq, "exit_bfqq: %p, %d", bfqq, bfqq->ref); in bfq_exit_bfqq()
5443 bfq_release_process_ref(bfqd, bfqq); in bfq_exit_bfqq()
5450 struct bfq_data *bfqd; in bfq_exit_icq_bfqq() local
5453 bfqd = bfqq->bfqd; /* NULL if scheduler already exited */ in bfq_exit_icq_bfqq()
5455 if (bfqq && bfqd) { in bfq_exit_icq_bfqq()
5457 bfq_exit_bfqq(bfqd, bfqq); in bfq_exit_icq_bfqq()
5464 struct bfq_data *bfqd = bic_to_bfqd(bic); in bfq_exit_icq() local
5480 if (bfqd) { in bfq_exit_icq()
5481 spin_lock_irqsave(&bfqd->lock, flags); in bfq_exit_icq()
5482 num_actuators = bfqd->num_actuators; in bfq_exit_icq()
5493 if (bfqd) in bfq_exit_icq()
5494 spin_unlock_irqrestore(&bfqd->lock, flags); in bfq_exit_icq()
5506 struct bfq_data *bfqd = bfqq->bfqd; in bfq_set_next_ioprio_data() local
5508 if (!bfqd) in bfq_set_next_ioprio_data()
5515 bdi_dev_name(bfqq->bfqd->queue->disk->bdi), in bfq_set_next_ioprio_data()
5546 bfq_log_bfqq(bfqd, bfqq, "new_ioprio %d new_weight %d", in bfq_set_next_ioprio_data()
5551 static struct bfq_queue *bfq_get_queue(struct bfq_data *bfqd,
5558 struct bfq_data *bfqd = bic_to_bfqd(bic); in bfq_check_ioprio_change() local
5566 if (unlikely(!bfqd) || likely(bic->ioprio == ioprio)) in bfq_check_ioprio_change()
5571 bfqq = bic_to_bfqq(bic, false, bfq_actuator_index(bfqd, bio)); in bfq_check_ioprio_change()
5575 bfqq = bfq_get_queue(bfqd, bio, false, bic, true); in bfq_check_ioprio_change()
5576 bic_set_bfqq(bic, bfqq, false, bfq_actuator_index(bfqd, bio)); in bfq_check_ioprio_change()
5577 bfq_release_process_ref(bfqd, old_bfqq); in bfq_check_ioprio_change()
5580 bfqq = bic_to_bfqq(bic, true, bfq_actuator_index(bfqd, bio)); in bfq_check_ioprio_change()
5585 static void bfq_init_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_init_bfqq() argument
5599 bfqq->bfqd = bfqd; in bfq_init_bfqq()
5630 bfqq->max_budget = (2 * bfq_max_budget(bfqd)) / 3; in bfq_init_bfqq()
5655 static struct bfq_queue **bfq_async_queue_prio(struct bfq_data *bfqd, in bfq_async_queue_prio() argument
5675 bfq_do_early_stable_merge(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_do_early_stable_merge() argument
5697 bfq_merge_bfqqs(bfqd, bic, bfqq, new_bfqq); in bfq_do_early_stable_merge()
5748 static struct bfq_queue *bfq_do_or_sched_stable_merge(struct bfq_data *bfqd, in bfq_do_or_sched_stable_merge() argument
5754 &bfqd->last_bfqq_created; in bfq_do_or_sched_stable_merge()
5791 bfqd->bfq_burst_interval, in bfq_do_or_sched_stable_merge()
5793 if (likely(bfqd->nonrot_with_queueing)) in bfq_do_or_sched_stable_merge()
5800 bfqq = bfq_do_early_stable_merge(bfqd, bfqq, in bfq_do_or_sched_stable_merge()
5827 static struct bfq_queue *bfq_get_queue(struct bfq_data *bfqd, in bfq_get_queue() argument
5838 bfqg = bfq_bio_bfqg(bfqd, bio); in bfq_get_queue()
5840 async_bfqq = bfq_async_queue_prio(bfqd, bfqg, ioprio_class, in bfq_get_queue()
5842 bfq_actuator_index(bfqd, bio)); in bfq_get_queue()
5850 bfqd->queue->node); in bfq_get_queue()
5853 bfq_init_bfqq(bfqd, bfqq, bic, current->pid, in bfq_get_queue()
5854 is_sync, bfq_actuator_index(bfqd, bio)); in bfq_get_queue()
5856 bfq_log_bfqq(bfqd, bfqq, "allocated"); in bfq_get_queue()
5858 bfqq = &bfqd->oom_bfqq; in bfq_get_queue()
5859 bfq_log_bfqq(bfqd, bfqq, "using oom bfqq"); in bfq_get_queue()
5875 bfq_log_bfqq(bfqd, bfqq, "get_queue, bfqq not in async: %p, %d", in bfq_get_queue()
5883 if (bfqq != &bfqd->oom_bfqq && is_sync && !respawn) in bfq_get_queue()
5884 bfqq = bfq_do_or_sched_stable_merge(bfqd, bfqq, bic); in bfq_get_queue()
5888 static void bfq_update_io_thinktime(struct bfq_data *bfqd, in bfq_update_io_thinktime() argument
5902 elapsed = min_t(u64, elapsed, 2ULL * bfqd->bfq_slice_idle); in bfq_update_io_thinktime()
5911 bfq_update_io_seektime(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_update_io_seektime() argument
5915 bfqq->seek_history |= BFQ_RQ_SEEKY(bfqd, bfqq->last_request_pos, rq); in bfq_update_io_seektime()
5918 bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time && in bfq_update_io_seektime()
5921 bfq_wr_duration(bfqd))) { in bfq_update_io_seektime()
5935 switch_back_to_interactive_wr(bfqq, bfqd); in bfq_update_io_seektime()
5941 static void bfq_update_has_short_ttime(struct bfq_data *bfqd, in bfq_update_has_short_ttime() argument
5953 bfqd->bfq_slice_idle == 0) in bfq_update_has_short_ttime()
5958 bfqd->bfq_wr_min_idle_time)) in bfq_update_has_short_ttime()
5968 bfqq->ttime.ttime_mean > bfqd->bfq_slice_idle>>1)) in bfq_update_has_short_ttime()
6066 bfq_reset_inject_limit(bfqd, bfqq); in bfq_update_has_short_ttime()
6073 static void bfq_rq_enqueued(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_rq_enqueued() argument
6081 if (bfqq == bfqd->in_service_queue && bfq_bfqq_wait_request(bfqq)) { in bfq_rq_enqueued()
6102 if (small_req && idling_boosts_thr_without_issues(bfqd, bfqq) && in bfq_rq_enqueued()
6114 hrtimer_try_to_cancel(&bfqd->idle_slice_timer); in bfq_rq_enqueued()
6124 bfq_bfqq_expire(bfqd, bfqq, false, in bfq_rq_enqueued()
6146 static bool __bfq_insert_request(struct bfq_data *bfqd, struct request *rq) in __bfq_insert_request() argument
6149 *new_bfqq = bfq_setup_cooperator(bfqd, bfqq, rq, true, in __bfq_insert_request()
6170 bfq_actuator_index(bfqd, rq->bio)) == bfqq) in __bfq_insert_request()
6171 bfq_merge_bfqqs(bfqd, RQ_BIC(rq), in __bfq_insert_request()
6184 bfq_update_io_thinktime(bfqd, bfqq); in __bfq_insert_request()
6185 bfq_update_has_short_ttime(bfqd, bfqq, RQ_BIC(rq)); in __bfq_insert_request()
6186 bfq_update_io_seektime(bfqd, bfqq, rq); in __bfq_insert_request()
6192 rq->fifo_time = ktime_get_ns() + bfqd->bfq_fifo_expire[rq_is_sync(rq)]; in __bfq_insert_request()
6195 bfq_rq_enqueued(bfqd, bfqq, rq); in __bfq_insert_request()
6238 struct bfq_data *bfqd = q->elevator->elevator_data; in bfq_insert_request() local
6248 spin_lock_irq(&bfqd->lock); in bfq_insert_request()
6251 spin_unlock_irq(&bfqd->lock); in bfq_insert_request()
6260 list_add(&rq->queuelist, &bfqd->dispatch); in bfq_insert_request()
6262 list_add_tail(&rq->queuelist, &bfqd->dispatch); in bfq_insert_request()
6264 idle_timer_disabled = __bfq_insert_request(bfqd, rq); in bfq_insert_request()
6285 spin_unlock_irq(&bfqd->lock); in bfq_insert_request()
6303 static void bfq_update_hw_tag(struct bfq_data *bfqd) in bfq_update_hw_tag() argument
6305 struct bfq_queue *bfqq = bfqd->in_service_queue; in bfq_update_hw_tag()
6307 bfqd->max_rq_in_driver = max_t(int, bfqd->max_rq_in_driver, in bfq_update_hw_tag()
6308 bfqd->tot_rq_in_driver); in bfq_update_hw_tag()
6310 if (bfqd->hw_tag == 1) in bfq_update_hw_tag()
6319 if (bfqd->tot_rq_in_driver + bfqd->queued <= BFQ_HW_QUEUE_THRESHOLD) in bfq_update_hw_tag()
6330 bfqd->tot_rq_in_driver < BFQ_HW_QUEUE_THRESHOLD) in bfq_update_hw_tag()
6333 if (bfqd->hw_tag_samples++ < BFQ_HW_QUEUE_SAMPLES) in bfq_update_hw_tag()
6336 bfqd->hw_tag = bfqd->max_rq_in_driver > BFQ_HW_QUEUE_THRESHOLD; in bfq_update_hw_tag()
6337 bfqd->max_rq_in_driver = 0; in bfq_update_hw_tag()
6338 bfqd->hw_tag_samples = 0; in bfq_update_hw_tag()
6340 bfqd->nonrot_with_queueing = in bfq_update_hw_tag()
6341 blk_queue_nonrot(bfqd->queue) && bfqd->hw_tag; in bfq_update_hw_tag()
6344 static void bfq_completed_request(struct bfq_queue *bfqq, struct bfq_data *bfqd) in bfq_completed_request() argument
6349 bfq_update_hw_tag(bfqd); in bfq_completed_request()
6351 bfqd->rq_in_driver[bfqq->actuator_idx]--; in bfq_completed_request()
6352 bfqd->tot_rq_in_driver--; in bfq_completed_request()
6376 delta_us = div_u64(now_ns - bfqd->last_completion, NSEC_PER_USEC); in bfq_completed_request()
6395 (bfqd->last_rq_max_size<<BFQ_RATE_SHIFT)/delta_us < in bfq_completed_request()
6397 bfq_update_rate_reset(bfqd, NULL); in bfq_completed_request()
6398 bfqd->last_completion = now_ns; in bfq_completed_request()
6409 bfqd->last_completed_rq_bfqq = bfqq; in bfq_completed_request()
6411 bfqd->last_completed_rq_bfqq = NULL; in bfq_completed_request()
6426 bfqq->wr_coeff != bfqd->bfq_wr_coeff) in bfq_completed_request()
6428 bfq_bfqq_softrt_next_start(bfqd, bfqq); in bfq_completed_request()
6434 if (bfqd->in_service_queue == bfqq) { in bfq_completed_request()
6437 bfq_arm_slice_timer(bfqd); in bfq_completed_request()
6463 bfq_bfqq_expire(bfqd, bfqq, false, in bfq_completed_request()
6468 bfq_bfqq_expire(bfqd, bfqq, false, in bfq_completed_request()
6472 if (!bfqd->tot_rq_in_driver) in bfq_completed_request()
6473 bfq_schedule_dispatch(bfqd); in bfq_completed_request()
6580 static void bfq_update_inject_limit(struct bfq_data *bfqd, in bfq_update_inject_limit() argument
6583 u64 tot_time_ns = ktime_get_ns() - bfqd->last_empty_occupied_ns; in bfq_update_inject_limit()
6586 if (bfqq->last_serv_time_ns > 0 && bfqd->rqs_injected) { in bfq_update_inject_limit()
6593 old_limit <= bfqd->max_rq_in_driver) in bfq_update_inject_limit()
6609 if ((bfqq->last_serv_time_ns == 0 && bfqd->tot_rq_in_driver == 1) || in bfq_update_inject_limit()
6619 } else if (!bfqd->rqs_injected && bfqd->tot_rq_in_driver == 1) in bfq_update_inject_limit()
6633 bfqd->waited_rq = NULL; in bfq_update_inject_limit()
6634 bfqd->rqs_injected = false; in bfq_update_inject_limit()
6646 struct bfq_data *bfqd; in bfq_finish_requeue_request() local
6657 bfqd = bfqq->bfqd; in bfq_finish_requeue_request()
6665 spin_lock_irqsave(&bfqd->lock, flags); in bfq_finish_requeue_request()
6667 if (rq == bfqd->waited_rq) in bfq_finish_requeue_request()
6668 bfq_update_inject_limit(bfqd, bfqq); in bfq_finish_requeue_request()
6670 bfq_completed_request(bfqq, bfqd); in bfq_finish_requeue_request()
6675 spin_unlock_irqrestore(&bfqd->lock, flags); in bfq_finish_requeue_request()
6717 bfq_log_bfqq(bfqq->bfqd, bfqq, "splitting queue"); in bfq_split_bfqq()
6730 bfq_release_process_ref(bfqq->bfqd, bfqq); in bfq_split_bfqq()
6734 static struct bfq_queue *bfq_get_bfqq_handle_split(struct bfq_data *bfqd, in bfq_get_bfqq_handle_split() argument
6740 unsigned int act_idx = bfq_actuator_index(bfqd, bio); in bfq_get_bfqq_handle_split()
6744 if (likely(bfqq && bfqq != &bfqd->oom_bfqq)) in bfq_get_bfqq_handle_split()
6752 bfqq = bfq_get_queue(bfqd, bio, is_sync, bic, split); in bfq_get_bfqq_handle_split()
6756 if ((bfqq_data->was_in_burst_list && bfqd->large_burst) || in bfq_get_bfqq_handle_split()
6791 &bfqd->burst_list); in bfq_get_bfqq_handle_split()
6844 struct bfq_data *bfqd = q->elevator->elevator_data; in bfq_init_rq() local
6850 unsigned int a_idx = bfq_actuator_index(bfqd, bio); in bfq_init_rq()
6871 bfqq = bfq_get_bfqq_handle_split(bfqd, bic, bio, false, is_sync, in bfq_init_rq()
6889 bfqq = bfq_get_bfqq_handle_split(bfqd, bic, bio, in bfq_init_rq()
6892 if (unlikely(bfqq == &bfqd->oom_bfqq)) in bfq_init_rq()
6918 bfq_log_bfqq(bfqd, bfqq, "get_request %p: bfqq %p, %d", in bfq_init_rq()
6930 if (likely(bfqq != &bfqd->oom_bfqq) && bfqq_process_refs(bfqq) == 1) { in bfq_init_rq()
6938 bfq_bfqq_resume_state(bfqq, bfqd, bic, in bfq_init_rq()
6964 (bfqd->burst_size > 0 || in bfq_init_rq()
6965 bfq_tot_busy_queues(bfqd) == 0))) in bfq_init_rq()
6966 bfq_handle_burst(bfqd, bfqq); in bfq_init_rq()
6972 bfq_idle_slice_timer_body(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_idle_slice_timer_body() argument
6977 spin_lock_irqsave(&bfqd->lock, flags); in bfq_idle_slice_timer_body()
6986 if (bfqq != bfqd->in_service_queue) { in bfq_idle_slice_timer_body()
6987 spin_unlock_irqrestore(&bfqd->lock, flags); in bfq_idle_slice_timer_body()
7011 bfq_bfqq_expire(bfqd, bfqq, true, reason); in bfq_idle_slice_timer_body()
7014 bfq_schedule_dispatch(bfqd); in bfq_idle_slice_timer_body()
7015 spin_unlock_irqrestore(&bfqd->lock, flags); in bfq_idle_slice_timer_body()
7024 struct bfq_data *bfqd = container_of(timer, struct bfq_data, in bfq_idle_slice_timer() local
7026 struct bfq_queue *bfqq = bfqd->in_service_queue; in bfq_idle_slice_timer()
7037 bfq_idle_slice_timer_body(bfqd, bfqq); in bfq_idle_slice_timer()
7042 static void __bfq_put_async_bfqq(struct bfq_data *bfqd, in __bfq_put_async_bfqq() argument
7047 bfq_log(bfqd, "put_async_bfqq: %p", bfqq); in __bfq_put_async_bfqq()
7049 bfq_bfqq_move(bfqd, bfqq, bfqd->root_group); in __bfq_put_async_bfqq()
7051 bfq_log_bfqq(bfqd, bfqq, "put_async_bfqq: putting %p, %d", in __bfq_put_async_bfqq()
7064 void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg) in bfq_put_async_queues() argument
7068 for (k = 0; k < bfqd->num_actuators; k++) { in bfq_put_async_queues()
7071 __bfq_put_async_bfqq(bfqd, &bfqg->async_bfqq[i][j][k]); in bfq_put_async_queues()
7073 __bfq_put_async_bfqq(bfqd, &bfqg->async_idle_bfqq[k]); in bfq_put_async_queues()
7081 static void bfq_update_depths(struct bfq_data *bfqd, struct sbitmap_queue *bt) in bfq_update_depths() argument
7085 bfqd->full_depth_shift = bt->sb.shift; in bfq_update_depths()
7097 bfqd->word_depths[0][0] = max(depth >> 1, 1U); in bfq_update_depths()
7103 bfqd->word_depths[0][1] = max((depth * 3) >> 2, 1U); in bfq_update_depths()
7113 bfqd->word_depths[1][0] = max((depth * 3) >> 4, 1U); in bfq_update_depths()
7115 bfqd->word_depths[1][1] = max((depth * 6) >> 4, 1U); in bfq_update_depths()
7120 struct bfq_data *bfqd = hctx->queue->elevator->elevator_data; in bfq_depth_updated() local
7123 bfq_update_depths(bfqd, &tags->bitmap_tags); in bfq_depth_updated()
7135 struct bfq_data *bfqd = e->elevator_data; in bfq_exit_queue() local
7138 hrtimer_cancel(&bfqd->idle_slice_timer); in bfq_exit_queue()
7140 spin_lock_irq(&bfqd->lock); in bfq_exit_queue()
7141 list_for_each_entry_safe(bfqq, n, &bfqd->idle_list, bfqq_list) in bfq_exit_queue()
7142 bfq_deactivate_bfqq(bfqd, bfqq, false, false); in bfq_exit_queue()
7143 spin_unlock_irq(&bfqd->lock); in bfq_exit_queue()
7145 hrtimer_cancel(&bfqd->idle_slice_timer); in bfq_exit_queue()
7148 bfqg_and_blkg_put(bfqd->root_group); in bfq_exit_queue()
7151 blkcg_deactivate_policy(bfqd->queue->disk, &blkcg_policy_bfq); in bfq_exit_queue()
7153 spin_lock_irq(&bfqd->lock); in bfq_exit_queue()
7154 bfq_put_async_queues(bfqd, bfqd->root_group); in bfq_exit_queue()
7155 kfree(bfqd->root_group); in bfq_exit_queue()
7156 spin_unlock_irq(&bfqd->lock); in bfq_exit_queue()
7159 blk_stat_disable_accounting(bfqd->queue); in bfq_exit_queue()
7161 wbt_enable_default(bfqd->queue->disk); in bfq_exit_queue()
7163 kfree(bfqd); in bfq_exit_queue()
7167 struct bfq_data *bfqd) in bfq_init_root_group() argument
7174 root_group->bfqd = bfqd; in bfq_init_root_group()
7184 struct bfq_data *bfqd; in bfq_init_queue() local
7193 bfqd = kzalloc_node(sizeof(*bfqd), GFP_KERNEL, q->node); in bfq_init_queue()
7194 if (!bfqd) { in bfq_init_queue()
7198 eq->elevator_data = bfqd; in bfq_init_queue()
7211 bfq_init_bfqq(bfqd, &bfqd->oom_bfqq, NULL, 1, 0, 0); in bfq_init_queue()
7212 bfqd->oom_bfqq.ref++; in bfq_init_queue()
7213 bfqd->oom_bfqq.new_ioprio = BFQ_DEFAULT_QUEUE_IOPRIO; in bfq_init_queue()
7214 bfqd->oom_bfqq.new_ioprio_class = IOPRIO_CLASS_BE; in bfq_init_queue()
7215 bfqd->oom_bfqq.entity.new_weight = in bfq_init_queue()
7216 bfq_ioprio_to_weight(bfqd->oom_bfqq.new_ioprio); in bfq_init_queue()
7219 bfq_clear_bfqq_just_created(&bfqd->oom_bfqq); in bfq_init_queue()
7226 bfqd->oom_bfqq.entity.prio_changed = 1; in bfq_init_queue()
7228 bfqd->queue = q; in bfq_init_queue()
7230 bfqd->num_actuators = 1; in bfq_init_queue()
7246 bfqd->num_actuators = ia_ranges->nr_ia_ranges; in bfq_init_queue()
7248 for (i = 0; i < bfqd->num_actuators; i++) { in bfq_init_queue()
7249 bfqd->sector[i] = ia_ranges->ia_range[i].sector; in bfq_init_queue()
7250 bfqd->nr_sectors[i] = in bfq_init_queue()
7257 if (bfqd->num_actuators == 1) { in bfq_init_queue()
7258 bfqd->sector[0] = 0; in bfq_init_queue()
7259 bfqd->nr_sectors[0] = get_capacity(q->disk); in bfq_init_queue()
7263 INIT_LIST_HEAD(&bfqd->dispatch); in bfq_init_queue()
7265 hrtimer_init(&bfqd->idle_slice_timer, CLOCK_MONOTONIC, in bfq_init_queue()
7267 bfqd->idle_slice_timer.function = bfq_idle_slice_timer; in bfq_init_queue()
7269 bfqd->queue_weights_tree = RB_ROOT_CACHED; in bfq_init_queue()
7271 bfqd->num_groups_with_pending_reqs = 0; in bfq_init_queue()
7274 INIT_LIST_HEAD(&bfqd->active_list[0]); in bfq_init_queue()
7275 INIT_LIST_HEAD(&bfqd->active_list[1]); in bfq_init_queue()
7276 INIT_LIST_HEAD(&bfqd->idle_list); in bfq_init_queue()
7277 INIT_HLIST_HEAD(&bfqd->burst_list); in bfq_init_queue()
7279 bfqd->hw_tag = -1; in bfq_init_queue()
7280 bfqd->nonrot_with_queueing = blk_queue_nonrot(bfqd->queue); in bfq_init_queue()
7282 bfqd->bfq_max_budget = bfq_default_max_budget; in bfq_init_queue()
7284 bfqd->bfq_fifo_expire[0] = bfq_fifo_expire[0]; in bfq_init_queue()
7285 bfqd->bfq_fifo_expire[1] = bfq_fifo_expire[1]; in bfq_init_queue()
7286 bfqd->bfq_back_max = bfq_back_max; in bfq_init_queue()
7287 bfqd->bfq_back_penalty = bfq_back_penalty; in bfq_init_queue()
7288 bfqd->bfq_slice_idle = bfq_slice_idle; in bfq_init_queue()
7289 bfqd->bfq_timeout = bfq_timeout; in bfq_init_queue()
7291 bfqd->bfq_large_burst_thresh = 8; in bfq_init_queue()
7292 bfqd->bfq_burst_interval = msecs_to_jiffies(180); in bfq_init_queue()
7294 bfqd->low_latency = true; in bfq_init_queue()
7299 bfqd->bfq_wr_coeff = 30; in bfq_init_queue()
7300 bfqd->bfq_wr_rt_max_time = msecs_to_jiffies(300); in bfq_init_queue()
7301 bfqd->bfq_wr_min_idle_time = msecs_to_jiffies(2000); in bfq_init_queue()
7302 bfqd->bfq_wr_min_inter_arr_async = msecs_to_jiffies(500); in bfq_init_queue()
7303 bfqd->bfq_wr_max_softrt_rate = 7000; /* in bfq_init_queue()
7309 bfqd->wr_busy_queues = 0; in bfq_init_queue()
7315 bfqd->rate_dur_prod = ref_rate[blk_queue_nonrot(bfqd->queue)] * in bfq_init_queue()
7316 ref_wr_duration[blk_queue_nonrot(bfqd->queue)]; in bfq_init_queue()
7317 bfqd->peak_rate = ref_rate[blk_queue_nonrot(bfqd->queue)] * 2 / 3; in bfq_init_queue()
7320 bfqd->actuator_load_threshold = 4; in bfq_init_queue()
7322 spin_lock_init(&bfqd->lock); in bfq_init_queue()
7339 bfqd->root_group = bfq_create_group_hierarchy(bfqd, q->node); in bfq_init_queue()
7340 if (!bfqd->root_group) in bfq_init_queue()
7342 bfq_init_root_group(bfqd->root_group, bfqd); in bfq_init_queue()
7343 bfq_init_entity(&bfqd->oom_bfqq.entity, bfqd->root_group); in bfq_init_queue()
7355 kfree(bfqd); in bfq_init_queue()
7392 struct bfq_data *bfqd = e->elevator_data; \
7400 SHOW_FUNCTION(bfq_fifo_expire_sync_show, bfqd->bfq_fifo_expire[1], 2);
7401 SHOW_FUNCTION(bfq_fifo_expire_async_show, bfqd->bfq_fifo_expire[0], 2);
7402 SHOW_FUNCTION(bfq_back_seek_max_show, bfqd->bfq_back_max, 0);
7403 SHOW_FUNCTION(bfq_back_seek_penalty_show, bfqd->bfq_back_penalty, 0);
7404 SHOW_FUNCTION(bfq_slice_idle_show, bfqd->bfq_slice_idle, 2);
7405 SHOW_FUNCTION(bfq_max_budget_show, bfqd->bfq_user_max_budget, 0);
7406 SHOW_FUNCTION(bfq_timeout_sync_show, bfqd->bfq_timeout, 1);
7407 SHOW_FUNCTION(bfq_strict_guarantees_show, bfqd->strict_guarantees, 0);
7408 SHOW_FUNCTION(bfq_low_latency_show, bfqd->low_latency, 0);
7414 struct bfq_data *bfqd = e->elevator_data; \
7419 USEC_SHOW_FUNCTION(bfq_slice_idle_us_show, bfqd->bfq_slice_idle);
7426 struct bfq_data *bfqd = e->elevator_data; \
7445 STORE_FUNCTION(bfq_fifo_expire_sync_store, &bfqd->bfq_fifo_expire[1], 1,
7447 STORE_FUNCTION(bfq_fifo_expire_async_store, &bfqd->bfq_fifo_expire[0], 1,
7449 STORE_FUNCTION(bfq_back_seek_max_store, &bfqd->bfq_back_max, 0, INT_MAX, 0);
7450 STORE_FUNCTION(bfq_back_seek_penalty_store, &bfqd->bfq_back_penalty, 1,
7452 STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, INT_MAX, 2);
7458 struct bfq_data *bfqd = e->elevator_data; \
7472 USEC_STORE_FUNCTION(bfq_slice_idle_us_store, &bfqd->bfq_slice_idle, 0,
7479 struct bfq_data *bfqd = e->elevator_data; in bfq_max_budget_store() local
7488 bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); in bfq_max_budget_store()
7492 bfqd->bfq_max_budget = __data; in bfq_max_budget_store()
7495 bfqd->bfq_user_max_budget = __data; in bfq_max_budget_store()
7507 struct bfq_data *bfqd = e->elevator_data; in bfq_timeout_sync_store() local
7520 bfqd->bfq_timeout = msecs_to_jiffies(__data); in bfq_timeout_sync_store()
7521 if (bfqd->bfq_user_max_budget == 0) in bfq_timeout_sync_store()
7522 bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); in bfq_timeout_sync_store()
7530 struct bfq_data *bfqd = e->elevator_data; in bfq_strict_guarantees_store() local
7540 if (!bfqd->strict_guarantees && __data == 1 in bfq_strict_guarantees_store()
7541 && bfqd->bfq_slice_idle < 8 * NSEC_PER_MSEC) in bfq_strict_guarantees_store()
7542 bfqd->bfq_slice_idle = 8 * NSEC_PER_MSEC; in bfq_strict_guarantees_store()
7544 bfqd->strict_guarantees = __data; in bfq_strict_guarantees_store()
7552 struct bfq_data *bfqd = e->elevator_data; in bfq_low_latency_store() local
7562 if (__data == 0 && bfqd->low_latency != 0) in bfq_low_latency_store()
7563 bfq_end_wr(bfqd); in bfq_low_latency_store()
7564 bfqd->low_latency = __data; in bfq_low_latency_store()