Lines Matching refs:bfqd

231 #define BFQ_RQ_SEEKY(bfqd, last_pos, rq) \  argument
234 (!blk_queue_nonrot(bfqd->queue) || \
474 void bfq_schedule_dispatch(struct bfq_data *bfqd) in bfq_schedule_dispatch() argument
476 lockdep_assert_held(&bfqd->lock); in bfq_schedule_dispatch()
478 if (bfqd->queued != 0) { in bfq_schedule_dispatch()
479 bfq_log(bfqd, "schedule dispatch"); in bfq_schedule_dispatch()
480 blk_mq_run_hw_queues(bfqd->queue, true); in bfq_schedule_dispatch()
493 static struct request *bfq_choose_req(struct bfq_data *bfqd, in bfq_choose_req() argument
524 back_max = bfqd->bfq_back_max * 2; in bfq_choose_req()
534 d1 = (last - s1) * bfqd->bfq_back_penalty; in bfq_choose_req()
541 d2 = (last - s2) * bfqd->bfq_back_penalty; in bfq_choose_req()
587 struct bfq_data *bfqd = bfqq->bfqd; in bfqq_request_over_limit() local
601 spin_lock_irq(&bfqd->lock); in bfqq_request_over_limit()
605 spin_unlock_irq(&bfqd->lock); in bfqq_request_over_limit()
655 bfq_log_bfqq(bfqq->bfqd, bfqq, in bfqq_request_over_limit()
663 spin_unlock_irq(&bfqd->lock); in bfqq_request_over_limit()
692 struct bfq_data *bfqd = data->q->elevator->elevator_data; in bfq_limit_depth() local
702 depth = bfqd->word_depths[!!bfqd->wr_busy_queues][op_is_sync(opf)]; in bfq_limit_depth()
703 limit = (limit * depth) >> bfqd->full_depth_shift; in bfq_limit_depth()
706 for (act_idx = 0; bic && act_idx < bfqd->num_actuators; act_idx++) { in bfq_limit_depth()
721 bfq_log(bfqd, "[%s] wr_busy %d sync %d depth %u", in bfq_limit_depth()
722 __func__, bfqd->wr_busy_queues, op_is_sync(opf), depth); in bfq_limit_depth()
728 bfq_rq_pos_tree_lookup(struct bfq_data *bfqd, struct rb_root *root, in bfq_rq_pos_tree_lookup() argument
761 bfq_log(bfqd, "rq_pos_tree_lookup %llu: returning %d", in bfq_rq_pos_tree_lookup()
784 bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_pos_tree_add_move() argument
795 if (bfqq == &bfqd->oom_bfqq) in bfq_pos_tree_add_move()
812 __bfqq = bfq_rq_pos_tree_lookup(bfqd, bfqq->pos_root, in bfq_pos_tree_add_move()
854 static bool bfq_asymmetric_scenario(struct bfq_data *bfqd, in bfq_asymmetric_scenario() argument
861 rb_first_cached(&bfqd->queue_weights_tree), in bfq_asymmetric_scenario()
870 !RB_EMPTY_ROOT(&bfqd->queue_weights_tree.rb_root) && in bfq_asymmetric_scenario()
871 (bfqd->queue_weights_tree.rb_root.rb_node->rb_left || in bfq_asymmetric_scenario()
872 bfqd->queue_weights_tree.rb_root.rb_node->rb_right); in bfq_asymmetric_scenario()
875 (bfqd->busy_queues[0] && bfqd->busy_queues[1]) || in bfq_asymmetric_scenario()
876 (bfqd->busy_queues[0] && bfqd->busy_queues[2]) || in bfq_asymmetric_scenario()
877 (bfqd->busy_queues[1] && bfqd->busy_queues[2]); in bfq_asymmetric_scenario()
881 || bfqd->num_groups_with_pending_reqs > 1 in bfq_asymmetric_scenario()
901 struct rb_root_cached *root = &bfqq->bfqd->queue_weights_tree; in bfq_weights_tree_add()
980 root = &bfqq->bfqd->queue_weights_tree; in bfq_weights_tree_remove()
1011 bfq_log_bfqq(bfqq->bfqd, bfqq, "check_fifo: returned %p", rq); in bfq_check_fifo()
1015 static struct request *bfq_find_next_rq(struct bfq_data *bfqd, in bfq_find_next_rq() argument
1039 return bfq_choose_req(bfqd, next, prev, blk_rq_pos(last)); in bfq_find_next_rq()
1047 bfq_asymmetric_scenario(bfqq->bfqd, bfqq)) in bfq_serv_to_charge()
1064 static void bfq_updated_next_req(struct bfq_data *bfqd, in bfq_updated_next_req() argument
1074 if (bfqq == bfqd->in_service_queue) in bfq_updated_next_req()
1087 bfq_log_bfqq(bfqd, bfqq, "updated next rq: new budget %lu", in bfq_updated_next_req()
1089 bfq_requeue_bfqq(bfqd, bfqq, false); in bfq_updated_next_req()
1093 static unsigned int bfq_wr_duration(struct bfq_data *bfqd) in bfq_wr_duration() argument
1097 dur = bfqd->rate_dur_prod; in bfq_wr_duration()
1098 do_div(dur, bfqd->peak_rate); in bfq_wr_duration()
1125 struct bfq_data *bfqd) in switch_back_to_interactive_wr() argument
1127 bfqq->wr_coeff = bfqd->bfq_wr_coeff; in switch_back_to_interactive_wr()
1128 bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); in switch_back_to_interactive_wr()
1133 bfq_bfqq_resume_state(struct bfq_queue *bfqq, struct bfq_data *bfqd, in bfq_bfqq_resume_state() argument
1162 if (bfqd->low_latency) { in bfq_bfqq_resume_state()
1175 if (bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time && in bfq_bfqq_resume_state()
1178 bfq_wr_duration(bfqd))) { in bfq_bfqq_resume_state()
1179 switch_back_to_interactive_wr(bfqq, bfqd); in bfq_bfqq_resume_state()
1182 bfq_log_bfqq(bfqq->bfqd, bfqq, in bfq_bfqq_resume_state()
1194 bfqd->wr_busy_queues++; in bfq_bfqq_resume_state()
1196 bfqd->wr_busy_queues--; in bfq_bfqq_resume_state()
1207 static void bfq_reset_burst_list(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_reset_burst_list() argument
1212 hlist_for_each_entry_safe(item, n, &bfqd->burst_list, burst_list_node) in bfq_reset_burst_list()
1220 if (bfq_tot_busy_queues(bfqd) == 0) { in bfq_reset_burst_list()
1221 hlist_add_head(&bfqq->burst_list_node, &bfqd->burst_list); in bfq_reset_burst_list()
1222 bfqd->burst_size = 1; in bfq_reset_burst_list()
1224 bfqd->burst_size = 0; in bfq_reset_burst_list()
1226 bfqd->burst_parent_entity = bfqq->entity.parent; in bfq_reset_burst_list()
1230 static void bfq_add_to_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_add_to_burst() argument
1233 bfqd->burst_size++; in bfq_add_to_burst()
1235 if (bfqd->burst_size == bfqd->bfq_large_burst_thresh) { in bfq_add_to_burst()
1243 bfqd->large_burst = true; in bfq_add_to_burst()
1249 hlist_for_each_entry(bfqq_item, &bfqd->burst_list, in bfq_add_to_burst()
1261 hlist_for_each_entry_safe(pos, n, &bfqd->burst_list, in bfq_add_to_burst()
1270 hlist_add_head(&bfqq->burst_list_node, &bfqd->burst_list); in bfq_add_to_burst()
1382 static void bfq_handle_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_handle_burst() argument
1412 if (time_is_before_jiffies(bfqd->last_ins_in_burst + in bfq_handle_burst()
1413 bfqd->bfq_burst_interval) || in bfq_handle_burst()
1414 bfqq->entity.parent != bfqd->burst_parent_entity) { in bfq_handle_burst()
1415 bfqd->large_burst = false; in bfq_handle_burst()
1416 bfq_reset_burst_list(bfqd, bfqq); in bfq_handle_burst()
1425 if (bfqd->large_burst) { in bfq_handle_burst()
1435 bfq_add_to_burst(bfqd, bfqq); in bfq_handle_burst()
1445 bfqd->last_ins_in_burst = jiffies; in bfq_handle_burst()
1460 static int bfq_max_budget(struct bfq_data *bfqd) in bfq_max_budget() argument
1462 if (bfqd->budgets_assigned < bfq_stats_min_budgets) in bfq_max_budget()
1465 return bfqd->bfq_max_budget; in bfq_max_budget()
1472 static int bfq_min_budget(struct bfq_data *bfqd) in bfq_min_budget() argument
1474 if (bfqd->budgets_assigned < bfq_stats_min_budgets) in bfq_min_budget()
1477 return bfqd->bfq_max_budget / 32; in bfq_min_budget()
1584 static bool bfq_bfqq_update_budg_for_activation(struct bfq_data *bfqd, in bfq_bfqq_update_budg_for_activation() argument
1653 static void bfq_update_bfqq_wr_on_rq_arrival(struct bfq_data *bfqd, in bfq_update_bfqq_wr_on_rq_arrival() argument
1665 bfqq->wr_coeff = bfqd->bfq_wr_coeff; in bfq_update_bfqq_wr_on_rq_arrival()
1666 bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); in bfq_update_bfqq_wr_on_rq_arrival()
1681 bfqq->wr_coeff = bfqd->bfq_wr_coeff * in bfq_update_bfqq_wr_on_rq_arrival()
1684 bfqd->bfq_wr_rt_max_time; in bfq_update_bfqq_wr_on_rq_arrival()
1698 2 * bfq_min_budget(bfqd)); in bfq_update_bfqq_wr_on_rq_arrival()
1701 bfqq->wr_coeff = bfqd->bfq_wr_coeff; in bfq_update_bfqq_wr_on_rq_arrival()
1702 bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); in bfq_update_bfqq_wr_on_rq_arrival()
1736 bfqd->bfq_wr_rt_max_time) { in bfq_update_bfqq_wr_on_rq_arrival()
1741 bfqd->bfq_wr_rt_max_time; in bfq_update_bfqq_wr_on_rq_arrival()
1742 bfqq->wr_coeff = bfqd->bfq_wr_coeff * in bfq_update_bfqq_wr_on_rq_arrival()
1750 static bool bfq_bfqq_idle_for_long_time(struct bfq_data *bfqd, in bfq_bfqq_idle_for_long_time() argument
1756 bfqd->bfq_wr_min_idle_time); in bfq_bfqq_idle_for_long_time()
1792 static unsigned int bfq_actuator_index(struct bfq_data *bfqd, struct bio *bio) in bfq_actuator_index() argument
1798 if (bfqd->num_actuators == 1) in bfq_actuator_index()
1804 for (i = 0; i < bfqd->num_actuators; i++) { in bfq_actuator_index()
1805 if (end >= bfqd->sector[i] && in bfq_actuator_index()
1806 end < bfqd->sector[i] + bfqd->nr_sectors[i]) in bfq_actuator_index()
1818 static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, in bfq_bfqq_handle_idle_busy_switch() argument
1826 idle_for_long_time = bfq_bfqq_idle_for_long_time(bfqd, bfqq), in bfq_bfqq_handle_idle_busy_switch()
1834 bfqd->bfq_slice_idle * 3; in bfq_bfqq_handle_idle_busy_switch()
1835 unsigned int act_idx = bfq_actuator_index(bfqd, rq->bio); in bfq_bfqq_handle_idle_busy_switch()
1849 soft_rt = bfqd->bfq_wr_max_softrt_rate > 0 && in bfq_bfqq_handle_idle_busy_switch()
1869 wr_or_deserves_wr = bfqd->low_latency && in bfq_bfqq_handle_idle_busy_switch()
1879 bfq_bfqq_update_budg_for_activation(bfqd, bfqq, in bfq_bfqq_handle_idle_busy_switch()
1906 if (bfqd->low_latency) { in bfq_bfqq_handle_idle_busy_switch()
1910 jiffies - bfqd->bfq_wr_min_idle_time - 1; in bfq_bfqq_handle_idle_busy_switch()
1913 bfqd->bfq_wr_min_idle_time)) { in bfq_bfqq_handle_idle_busy_switch()
1914 bfq_update_bfqq_wr_on_rq_arrival(bfqd, bfqq, in bfq_bfqq_handle_idle_busy_switch()
1975 if (bfqd->in_service_queue && in bfq_bfqq_handle_idle_busy_switch()
1977 bfqq->wr_coeff >= bfqd->in_service_queue->wr_coeff) || in bfq_bfqq_handle_idle_busy_switch()
1978 bfq_bfqq_higher_class_or_weight(bfqq, bfqd->in_service_queue) || in bfq_bfqq_handle_idle_busy_switch()
1979 !bfq_better_to_idle(bfqd->in_service_queue)) && in bfq_bfqq_handle_idle_busy_switch()
1980 next_queue_may_preempt(bfqd)) in bfq_bfqq_handle_idle_busy_switch()
1981 bfq_bfqq_expire(bfqd, bfqd->in_service_queue, in bfq_bfqq_handle_idle_busy_switch()
1985 static void bfq_reset_inject_limit(struct bfq_data *bfqd, in bfq_reset_inject_limit() argument
1995 bfqd->waited_rq = NULL; in bfq_reset_inject_limit()
2132 static void bfq_check_waker(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_check_waker() argument
2137 if (!bfqd->last_completed_rq_bfqq || in bfq_check_waker()
2138 bfqd->last_completed_rq_bfqq == bfqq || in bfq_check_waker()
2140 now_ns - bfqd->last_completion >= 4 * NSEC_PER_MSEC || in bfq_check_waker()
2141 bfqd->last_completed_rq_bfqq == &bfqd->oom_bfqq || in bfq_check_waker()
2142 bfqq == &bfqd->oom_bfqq) in bfq_check_waker()
2151 if (bfqd->last_completed_rq_bfqq != in bfq_check_waker()
2154 128 * (u64)bfqd->bfq_slice_idle) { in bfq_check_waker()
2161 bfqd->last_completed_rq_bfqq; in bfq_check_waker()
2166 bfq_log_bfqq(bfqd, bfqq, "set tentative waker %s", waker_name); in bfq_check_waker()
2171 bfqq->waker_bfqq = bfqd->last_completed_rq_bfqq; in bfq_check_waker()
2175 bfq_log_bfqq(bfqd, bfqq, "set waker %s", waker_name); in bfq_check_waker()
2200 &bfqd->last_completed_rq_bfqq->woken_list); in bfq_check_waker()
2207 struct bfq_data *bfqd = bfqq->bfqd; in bfq_add_request() local
2213 bfq_log_bfqq(bfqd, bfqq, "add_request %d", rq_is_sync(rq)); in bfq_add_request()
2219 WRITE_ONCE(bfqd->queued, bfqd->queued + 1); in bfq_add_request()
2222 bfq_check_waker(bfqd, bfqq, now_ns); in bfq_add_request()
2232 bfq_reset_inject_limit(bfqd, bfqq); in bfq_add_request()
2259 if (bfqq == bfqd->in_service_queue && in bfq_add_request()
2260 (bfqd->tot_rq_in_driver == 0 || in bfq_add_request()
2262 bfqd->rqs_injected && bfqd->tot_rq_in_driver > 0)) && in bfq_add_request()
2265 bfqd->last_empty_occupied_ns = ktime_get_ns(); in bfq_add_request()
2272 bfqd->wait_dispatch = true; in bfq_add_request()
2286 if (bfqd->tot_rq_in_driver == 0) in bfq_add_request()
2287 bfqd->rqs_injected = false; in bfq_add_request()
2300 next_rq = bfq_choose_req(bfqd, bfqq->next_rq, rq, bfqd->last_position); in bfq_add_request()
2307 if (unlikely(!bfqd->nonrot_with_queueing && prev != bfqq->next_rq)) in bfq_add_request()
2308 bfq_pos_tree_add_move(bfqd, bfqq); in bfq_add_request()
2311 bfq_bfqq_handle_idle_busy_switch(bfqd, bfqq, old_wr_coeff, in bfq_add_request()
2314 if (bfqd->low_latency && old_wr_coeff == 1 && !rq_is_sync(rq) && in bfq_add_request()
2317 bfqd->bfq_wr_min_inter_arr_async)) { in bfq_add_request()
2318 bfqq->wr_coeff = bfqd->bfq_wr_coeff; in bfq_add_request()
2319 bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); in bfq_add_request()
2321 bfqd->wr_busy_queues++; in bfq_add_request()
2325 bfq_updated_next_req(bfqd, bfqq); in bfq_add_request()
2354 if (bfqd->low_latency && in bfq_add_request()
2359 static struct request *bfq_find_rq_fmerge(struct bfq_data *bfqd, in bfq_find_rq_fmerge() argument
2363 struct bfq_queue *bfqq = bfqd->bio_bfqq; in bfq_find_rq_fmerge()
2384 struct bfq_data *bfqd = bfqq->bfqd; in bfq_remove_request() local
2388 bfqq->next_rq = bfq_find_next_rq(bfqd, bfqq, rq); in bfq_remove_request()
2389 bfq_updated_next_req(bfqd, bfqq); in bfq_remove_request()
2399 WRITE_ONCE(bfqd->queued, bfqd->queued - 1); in bfq_remove_request()
2409 if (bfq_bfqq_busy(bfqq) && bfqq != bfqd->in_service_queue) { in bfq_remove_request()
2436 if (unlikely(!bfqd->nonrot_with_queueing)) in bfq_remove_request()
2437 bfq_pos_tree_add_move(bfqd, bfqq); in bfq_remove_request()
2448 struct bfq_data *bfqd = q->elevator->elevator_data; in bfq_bio_merge() local
2460 spin_lock_irq(&bfqd->lock); in bfq_bio_merge()
2469 bfqd->bio_bfqq = bic_to_bfqq(bic, op_is_sync(bio->bi_opf), in bfq_bio_merge()
2470 bfq_actuator_index(bfqd, bio)); in bfq_bio_merge()
2472 bfqd->bio_bfqq = NULL; in bfq_bio_merge()
2474 bfqd->bio_bic = bic; in bfq_bio_merge()
2478 spin_unlock_irq(&bfqd->lock); in bfq_bio_merge()
2488 struct bfq_data *bfqd = q->elevator->elevator_data; in bfq_request_merge() local
2491 __rq = bfq_find_rq_fmerge(bfqd, bio, q); in bfq_request_merge()
2512 struct bfq_data *bfqd; in bfq_request_merged() local
2518 bfqd = bfqq->bfqd; in bfq_request_merged()
2526 next_rq = bfq_choose_req(bfqd, bfqq->next_rq, req, in bfq_request_merged()
2527 bfqd->last_position); in bfq_request_merged()
2535 bfq_updated_next_req(bfqd, bfqq); in bfq_request_merged()
2540 if (unlikely(!bfqd->nonrot_with_queueing)) in bfq_request_merged()
2541 bfq_pos_tree_add_move(bfqd, bfqq); in bfq_request_merged()
2618 bfqq->bfqd->bfq_wr_rt_max_time) in bfq_bfqq_end_wr()
2622 bfqq->bfqd->wr_busy_queues--; in bfq_bfqq_end_wr()
2633 void bfq_end_wr_async_queues(struct bfq_data *bfqd, in bfq_end_wr_async_queues() argument
2638 for (k = 0; k < bfqd->num_actuators; k++) { in bfq_end_wr_async_queues()
2648 static void bfq_end_wr(struct bfq_data *bfqd) in bfq_end_wr() argument
2653 spin_lock_irq(&bfqd->lock); in bfq_end_wr()
2655 for (i = 0; i < bfqd->num_actuators; i++) { in bfq_end_wr()
2656 list_for_each_entry(bfqq, &bfqd->active_list[i], bfqq_list) in bfq_end_wr()
2659 list_for_each_entry(bfqq, &bfqd->idle_list, bfqq_list) in bfq_end_wr()
2661 bfq_end_wr_async(bfqd); in bfq_end_wr()
2663 spin_unlock_irq(&bfqd->lock); in bfq_end_wr()
2681 static struct bfq_queue *bfqq_find_close(struct bfq_data *bfqd, in bfqq_find_close() argument
2696 __bfqq = bfq_rq_pos_tree_lookup(bfqd, root, sector, &parent, NULL); in bfqq_find_close()
2723 static struct bfq_queue *bfq_find_close_cooperator(struct bfq_data *bfqd, in bfq_find_close_cooperator() argument
2736 bfqq = bfqq_find_close(bfqd, cur_bfqq, sector); in bfq_find_close_cooperator()
2782 bfq_log_bfqq(bfqq->bfqd, bfqq, "scheduling merge with queue %d", in bfq_setup_merge()
2848 static bool idling_boosts_thr_without_issues(struct bfq_data *bfqd,
2852 bfq_setup_stable_merge(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_setup_stable_merge() argument
2861 if (idling_boosts_thr_without_issues(bfqd, bfqq) || proc_ref == 0) in bfq_setup_stable_merge()
2906 bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_setup_cooperator() argument
2926 if (unlikely(!bfqd->nonrot_with_queueing)) { in bfq_setup_cooperator()
2942 return bfq_setup_stable_merge(bfqd, bfqq, in bfq_setup_cooperator()
2985 if (likely(bfqd->nonrot_with_queueing)) in bfq_setup_cooperator()
3002 if (!io_struct || unlikely(bfqq == &bfqd->oom_bfqq)) in bfq_setup_cooperator()
3006 if (bfq_tot_busy_queues(bfqd) == 1) in bfq_setup_cooperator()
3009 in_service_bfqq = bfqd->in_service_queue; in bfq_setup_cooperator()
3012 likely(in_service_bfqq != &bfqd->oom_bfqq) && in bfq_setup_cooperator()
3014 bfqd->in_serv_last_pos) && in bfq_setup_cooperator()
3026 new_bfqq = bfq_find_close_cooperator(bfqd, bfqq, in bfq_setup_cooperator()
3029 if (new_bfqq && likely(new_bfqq != &bfqd->oom_bfqq) && in bfq_setup_cooperator()
3067 bfqq->bfqd->low_latency)) { in bfq_bfqq_save_state()
3077 bfqq_data->saved_wr_coeff = bfqq->bfqd->bfq_wr_coeff; in bfq_bfqq_save_state()
3081 bfq_wr_duration(bfqq->bfqd); in bfq_bfqq_save_state()
3102 else if (cur_bfqq->bfqd && cur_bfqq->bfqd->last_bfqq_created == cur_bfqq) in bfq_reassign_last_bfqq()
3103 cur_bfqq->bfqd->last_bfqq_created = new_bfqq; in bfq_reassign_last_bfqq()
3106 void bfq_release_process_ref(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_release_process_ref() argument
3120 bfqq != bfqd->in_service_queue) in bfq_release_process_ref()
3129 bfq_merge_bfqqs(struct bfq_data *bfqd, struct bfq_io_cq *bic, in bfq_merge_bfqqs() argument
3132 bfq_log_bfqq(bfqd, bfqq, "merging with queue %lu", in bfq_merge_bfqqs()
3180 bfqd->wr_busy_queues++; in bfq_merge_bfqqs()
3188 bfqd->wr_busy_queues--; in bfq_merge_bfqqs()
3191 bfq_log_bfqq(bfqd, new_bfqq, "merge_bfqqs: wr_busy %d", in bfq_merge_bfqqs()
3192 bfqd->wr_busy_queues); in bfq_merge_bfqqs()
3224 bfq_release_process_ref(bfqd, bfqq); in bfq_merge_bfqqs()
3230 struct bfq_data *bfqd = q->elevator->elevator_data; in bfq_allow_bio_merge() local
3232 struct bfq_queue *bfqq = bfqd->bio_bfqq, *new_bfqq; in bfq_allow_bio_merge()
3251 new_bfqq = bfq_setup_cooperator(bfqd, bfqq, bio, false, bfqd->bio_bic); in bfq_allow_bio_merge()
3260 bfq_merge_bfqqs(bfqd, bfqd->bio_bic, bfqq, in bfq_allow_bio_merge()
3275 bfqd->bio_bfqq = bfqq; in bfq_allow_bio_merge()
3287 static void bfq_set_budget_timeout(struct bfq_data *bfqd, in bfq_set_budget_timeout() argument
3292 if (bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time) in bfq_set_budget_timeout()
3297 bfqd->last_budget_start = ktime_get(); in bfq_set_budget_timeout()
3300 bfqd->bfq_timeout * timeout_coeff; in bfq_set_budget_timeout()
3303 static void __bfq_set_in_service_queue(struct bfq_data *bfqd, in __bfq_set_in_service_queue() argument
3309 bfqd->budgets_assigned = (bfqd->budgets_assigned * 7 + 256) / 8; in __bfq_set_in_service_queue()
3313 bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time && in __bfq_set_in_service_queue()
3347 bfq_set_budget_timeout(bfqd, bfqq); in __bfq_set_in_service_queue()
3348 bfq_log_bfqq(bfqd, bfqq, in __bfq_set_in_service_queue()
3353 bfqd->in_service_queue = bfqq; in __bfq_set_in_service_queue()
3354 bfqd->in_serv_last_pos = 0; in __bfq_set_in_service_queue()
3360 static struct bfq_queue *bfq_set_in_service_queue(struct bfq_data *bfqd) in bfq_set_in_service_queue() argument
3362 struct bfq_queue *bfqq = bfq_get_next_queue(bfqd); in bfq_set_in_service_queue()
3364 __bfq_set_in_service_queue(bfqd, bfqq); in bfq_set_in_service_queue()
3368 static void bfq_arm_slice_timer(struct bfq_data *bfqd) in bfq_arm_slice_timer() argument
3370 struct bfq_queue *bfqq = bfqd->in_service_queue; in bfq_arm_slice_timer()
3380 sl = bfqd->bfq_slice_idle; in bfq_arm_slice_timer()
3392 !bfq_asymmetric_scenario(bfqd, bfqq)) in bfq_arm_slice_timer()
3397 bfqd->last_idling_start = ktime_get(); in bfq_arm_slice_timer()
3398 bfqd->last_idling_start_jiffies = jiffies; in bfq_arm_slice_timer()
3400 hrtimer_start(&bfqd->idle_slice_timer, ns_to_ktime(sl), in bfq_arm_slice_timer()
3412 static unsigned long bfq_calc_max_budget(struct bfq_data *bfqd) in bfq_calc_max_budget() argument
3414 return (u64)bfqd->peak_rate * USEC_PER_MSEC * in bfq_calc_max_budget()
3415 jiffies_to_msecs(bfqd->bfq_timeout)>>BFQ_RATE_SHIFT; in bfq_calc_max_budget()
3423 static void update_thr_responsiveness_params(struct bfq_data *bfqd) in update_thr_responsiveness_params() argument
3425 if (bfqd->bfq_user_max_budget == 0) { in update_thr_responsiveness_params()
3426 bfqd->bfq_max_budget = in update_thr_responsiveness_params()
3427 bfq_calc_max_budget(bfqd); in update_thr_responsiveness_params()
3428 bfq_log(bfqd, "new max_budget = %d", bfqd->bfq_max_budget); in update_thr_responsiveness_params()
3432 static void bfq_reset_rate_computation(struct bfq_data *bfqd, in bfq_reset_rate_computation() argument
3436 bfqd->last_dispatch = bfqd->first_dispatch = ktime_get_ns(); in bfq_reset_rate_computation()
3437 bfqd->peak_rate_samples = 1; in bfq_reset_rate_computation()
3438 bfqd->sequential_samples = 0; in bfq_reset_rate_computation()
3439 bfqd->tot_sectors_dispatched = bfqd->last_rq_max_size = in bfq_reset_rate_computation()
3442 bfqd->peak_rate_samples = 0; /* full re-init on next disp. */ in bfq_reset_rate_computation()
3444 bfq_log(bfqd, in bfq_reset_rate_computation()
3446 bfqd->peak_rate_samples, bfqd->sequential_samples, in bfq_reset_rate_computation()
3447 bfqd->tot_sectors_dispatched); in bfq_reset_rate_computation()
3450 static void bfq_update_rate_reset(struct bfq_data *bfqd, struct request *rq) in bfq_update_rate_reset() argument
3462 if (bfqd->peak_rate_samples < BFQ_RATE_MIN_SAMPLES || in bfq_update_rate_reset()
3463 bfqd->delta_from_first < BFQ_RATE_MIN_INTERVAL) in bfq_update_rate_reset()
3472 bfqd->delta_from_first = in bfq_update_rate_reset()
3473 max_t(u64, bfqd->delta_from_first, in bfq_update_rate_reset()
3474 bfqd->last_completion - bfqd->first_dispatch); in bfq_update_rate_reset()
3480 rate = div64_ul(bfqd->tot_sectors_dispatched<<BFQ_RATE_SHIFT, in bfq_update_rate_reset()
3481 div_u64(bfqd->delta_from_first, NSEC_PER_USEC)); in bfq_update_rate_reset()
3489 if ((bfqd->sequential_samples < (3 * bfqd->peak_rate_samples)>>2 && in bfq_update_rate_reset()
3490 rate <= bfqd->peak_rate) || in bfq_update_rate_reset()
3517 weight = (9 * bfqd->sequential_samples) / bfqd->peak_rate_samples; in bfq_update_rate_reset()
3524 div_u64(weight * bfqd->delta_from_first, in bfq_update_rate_reset()
3538 bfqd->peak_rate *= divisor-1; in bfq_update_rate_reset()
3539 bfqd->peak_rate /= divisor; in bfq_update_rate_reset()
3542 bfqd->peak_rate += rate; in bfq_update_rate_reset()
3551 bfqd->peak_rate = max_t(u32, 1, bfqd->peak_rate); in bfq_update_rate_reset()
3553 update_thr_responsiveness_params(bfqd); in bfq_update_rate_reset()
3556 bfq_reset_rate_computation(bfqd, rq); in bfq_update_rate_reset()
3591 static void bfq_update_peak_rate(struct bfq_data *bfqd, struct request *rq) in bfq_update_peak_rate() argument
3595 if (bfqd->peak_rate_samples == 0) { /* first dispatch */ in bfq_update_peak_rate()
3596 bfq_log(bfqd, "update_peak_rate: goto reset, samples %d", in bfq_update_peak_rate()
3597 bfqd->peak_rate_samples); in bfq_update_peak_rate()
3598 bfq_reset_rate_computation(bfqd, rq); in bfq_update_peak_rate()
3614 if (now_ns - bfqd->last_dispatch > 100*NSEC_PER_MSEC && in bfq_update_peak_rate()
3615 bfqd->tot_rq_in_driver == 0) in bfq_update_peak_rate()
3619 bfqd->peak_rate_samples++; in bfq_update_peak_rate()
3621 if ((bfqd->tot_rq_in_driver > 0 || in bfq_update_peak_rate()
3622 now_ns - bfqd->last_completion < BFQ_MIN_TT) in bfq_update_peak_rate()
3623 && !BFQ_RQ_SEEKY(bfqd, bfqd->last_position, rq)) in bfq_update_peak_rate()
3624 bfqd->sequential_samples++; in bfq_update_peak_rate()
3626 bfqd->tot_sectors_dispatched += blk_rq_sectors(rq); in bfq_update_peak_rate()
3629 if (likely(bfqd->peak_rate_samples % 32)) in bfq_update_peak_rate()
3630 bfqd->last_rq_max_size = in bfq_update_peak_rate()
3631 max_t(u32, blk_rq_sectors(rq), bfqd->last_rq_max_size); in bfq_update_peak_rate()
3633 bfqd->last_rq_max_size = blk_rq_sectors(rq); in bfq_update_peak_rate()
3635 bfqd->delta_from_first = now_ns - bfqd->first_dispatch; in bfq_update_peak_rate()
3638 if (bfqd->delta_from_first < BFQ_RATE_REF_INTERVAL) in bfq_update_peak_rate()
3642 bfq_update_rate_reset(bfqd, rq); in bfq_update_peak_rate()
3644 bfqd->last_position = blk_rq_pos(rq) + blk_rq_sectors(rq); in bfq_update_peak_rate()
3645 if (RQ_BFQQ(rq) == bfqd->in_service_queue) in bfq_update_peak_rate()
3646 bfqd->in_serv_last_pos = bfqd->last_position; in bfq_update_peak_rate()
3647 bfqd->last_dispatch = now_ns; in bfq_update_peak_rate()
3876 static bool idling_needed_for_service_guarantees(struct bfq_data *bfqd, in idling_needed_for_service_guarantees() argument
3879 int tot_busy_queues = bfq_tot_busy_queues(bfqd); in idling_needed_for_service_guarantees()
3886 (bfqd->wr_busy_queues < tot_busy_queues || in idling_needed_for_service_guarantees()
3887 bfqd->tot_rq_in_driver >= bfqq->dispatched + 4)) || in idling_needed_for_service_guarantees()
3888 bfq_asymmetric_scenario(bfqd, bfqq) || in idling_needed_for_service_guarantees()
3892 static bool __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq, in __bfq_bfqq_expire() argument
3919 idling_needed_for_service_guarantees(bfqd, bfqq))) { in __bfq_bfqq_expire()
3931 bfq_requeue_bfqq(bfqd, bfqq, true); in __bfq_bfqq_expire()
3936 if (unlikely(!bfqd->nonrot_with_queueing && in __bfq_bfqq_expire()
3938 bfq_pos_tree_add_move(bfqd, bfqq); in __bfq_bfqq_expire()
3948 return __bfq_bfqd_reset_in_service(bfqd); in __bfq_bfqq_expire()
3960 static void __bfq_bfqq_recalc_budget(struct bfq_data *bfqd, in __bfq_bfqq_recalc_budget() argument
3967 min_budget = bfq_min_budget(bfqd); in __bfq_bfqq_recalc_budget()
3979 bfq_log_bfqq(bfqd, bfqq, "recalc_budg: last budg %d, budg left %d", in __bfq_bfqq_recalc_budget()
3981 bfq_log_bfqq(bfqd, bfqq, "recalc_budg: last max_budg %d, min budg %d", in __bfq_bfqq_recalc_budget()
3982 budget, bfq_min_budget(bfqd)); in __bfq_bfqq_recalc_budget()
3983 bfq_log_bfqq(bfqd, bfqq, "recalc_budg: sync %d, seeky %d", in __bfq_bfqq_recalc_budget()
3984 bfq_bfqq_sync(bfqq), BFQQ_SEEKY(bfqd->in_service_queue)); in __bfq_bfqq_recalc_budget()
4018 budget = min(budget * 2, bfqd->bfq_max_budget); in __bfq_bfqq_recalc_budget()
4033 budget = min(budget * 2, bfqd->bfq_max_budget); in __bfq_bfqq_recalc_budget()
4045 budget = min(budget * 4, bfqd->bfq_max_budget); in __bfq_bfqq_recalc_budget()
4092 budget = bfqd->bfq_max_budget; in __bfq_bfqq_recalc_budget()
4097 if (bfqd->budgets_assigned >= bfq_stats_min_budgets && in __bfq_bfqq_recalc_budget()
4098 !bfqd->bfq_user_max_budget) in __bfq_bfqq_recalc_budget()
4099 bfqq->max_budget = min(bfqq->max_budget, bfqd->bfq_max_budget); in __bfq_bfqq_recalc_budget()
4116 bfq_log_bfqq(bfqd, bfqq, "head sect: %u, new budget %d", in __bfq_bfqq_recalc_budget()
4152 static bool bfq_bfqq_is_slow(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_bfqq_is_slow() argument
4163 delta_ktime = bfqd->last_idling_start; in bfq_bfqq_is_slow()
4166 delta_ktime = ktime_sub(delta_ktime, bfqd->last_budget_start); in bfq_bfqq_is_slow()
4171 if (blk_queue_nonrot(bfqd->queue)) in bfq_bfqq_is_slow()
4200 slow = bfqq->entity.service < bfqd->bfq_max_budget / 2; in bfq_bfqq_is_slow()
4203 bfq_log_bfqq(bfqd, bfqq, "bfq_bfqq_is_slow: slow %d", slow); in bfq_bfqq_is_slow()
4301 static unsigned long bfq_bfqq_softrt_next_start(struct bfq_data *bfqd, in bfq_bfqq_softrt_next_start() argument
4307 bfqd->bfq_wr_max_softrt_rate, in bfq_bfqq_softrt_next_start()
4308 jiffies + nsecs_to_jiffies(bfqq->bfqd->bfq_slice_idle) + 4); in bfq_bfqq_softrt_next_start()
4337 void bfq_bfqq_expire(struct bfq_data *bfqd, in bfq_bfqq_expire() argument
4349 slow = bfq_bfqq_is_slow(bfqd, bfqq, compensate, &delta); in bfq_bfqq_expire()
4370 bfq_bfqq_charge_time(bfqd, bfqq, delta); in bfq_bfqq_expire()
4372 if (bfqd->low_latency && bfqq->wr_coeff == 1) in bfq_bfqq_expire()
4375 if (bfqd->low_latency && bfqd->bfq_wr_max_softrt_rate > 0 && in bfq_bfqq_expire()
4391 bfq_bfqq_softrt_next_start(bfqd, bfqq); in bfq_bfqq_expire()
4401 bfq_log_bfqq(bfqd, bfqq, in bfq_bfqq_expire()
4410 bfqd->rqs_injected = bfqd->wait_dispatch = false; in bfq_bfqq_expire()
4411 bfqd->waited_rq = NULL; in bfq_bfqq_expire()
4417 __bfq_bfqq_recalc_budget(bfqd, bfqq, reason); in bfq_bfqq_expire()
4418 if (__bfq_bfqq_expire(bfqd, bfqq, reason)) in bfq_bfqq_expire()
4477 bfq_log_bfqq(bfqq->bfqd, bfqq, in bfq_may_expire_for_budg_timeout()
4489 static bool idling_boosts_thr_without_issues(struct bfq_data *bfqd, in idling_boosts_thr_without_issues() argument
4493 !blk_queue_nonrot(bfqd->queue) && !bfqd->hw_tag, in idling_boosts_thr_without_issues()
4527 ((!blk_queue_nonrot(bfqd->queue) || !bfqd->hw_tag) && in idling_boosts_thr_without_issues()
4565 bfqd->wr_busy_queues == 0; in idling_boosts_thr_without_issues()
4591 struct bfq_data *bfqd = bfqq->bfqd; in bfq_better_to_idle() local
4598 if (unlikely(bfqd->strict_guarantees)) in bfq_better_to_idle()
4609 if (bfqd->bfq_slice_idle == 0 || !bfq_bfqq_sync(bfqq) || in bfq_better_to_idle()
4614 idling_boosts_thr_without_issues(bfqd, bfqq); in bfq_better_to_idle()
4617 idling_needed_for_service_guarantees(bfqd, bfqq); in bfq_better_to_idle()
4653 bfq_choose_bfqq_for_injection(struct bfq_data *bfqd) in bfq_choose_bfqq_for_injection() argument
4655 struct bfq_queue *bfqq, *in_serv_bfqq = bfqd->in_service_queue; in bfq_choose_bfqq_for_injection()
4685 time_is_before_eq_jiffies(bfqd->last_idling_start_jiffies + in bfq_choose_bfqq_for_injection()
4686 bfqd->bfq_slice_idle) in bfq_choose_bfqq_for_injection()
4690 if (bfqd->tot_rq_in_driver >= limit) in bfq_choose_bfqq_for_injection()
4705 for (i = 0; i < bfqd->num_actuators; i++) { in bfq_choose_bfqq_for_injection()
4706 list_for_each_entry(bfqq, &bfqd->active_list[i], bfqq_list) in bfq_choose_bfqq_for_injection()
4728 if (blk_queue_nonrot(bfqd->queue) && in bfq_choose_bfqq_for_injection()
4731 bfqd->tot_rq_in_driver >= 1) in bfq_choose_bfqq_for_injection()
4734 bfqd->rqs_injected = true; in bfq_choose_bfqq_for_injection()
4744 bfq_find_active_bfqq_for_actuator(struct bfq_data *bfqd, int idx) in bfq_find_active_bfqq_for_actuator() argument
4748 if (bfqd->in_service_queue && in bfq_find_active_bfqq_for_actuator()
4749 bfqd->in_service_queue->actuator_idx == idx) in bfq_find_active_bfqq_for_actuator()
4750 return bfqd->in_service_queue; in bfq_find_active_bfqq_for_actuator()
4752 list_for_each_entry(bfqq, &bfqd->active_list[idx], bfqq_list) { in bfq_find_active_bfqq_for_actuator()
4777 bfq_find_bfqq_for_underused_actuator(struct bfq_data *bfqd) in bfq_find_bfqq_for_underused_actuator() argument
4781 for (i = 0 ; i < bfqd->num_actuators; i++) { in bfq_find_bfqq_for_underused_actuator()
4782 if (bfqd->rq_in_driver[i] < bfqd->actuator_load_threshold && in bfq_find_bfqq_for_underused_actuator()
4783 (i == bfqd->num_actuators - 1 || in bfq_find_bfqq_for_underused_actuator()
4784 bfqd->rq_in_driver[i] < bfqd->rq_in_driver[i+1])) { in bfq_find_bfqq_for_underused_actuator()
4786 bfq_find_active_bfqq_for_actuator(bfqd, i); in bfq_find_bfqq_for_underused_actuator()
4801 static struct bfq_queue *bfq_select_queue(struct bfq_data *bfqd) in bfq_select_queue() argument
4807 bfqq = bfqd->in_service_queue; in bfq_select_queue()
4811 bfq_log_bfqq(bfqd, bfqq, "select_queue: already in-service queue"); in bfq_select_queue()
4830 inject_bfqq = bfq_find_bfqq_for_underused_actuator(bfqd); in bfq_select_queue()
4877 hrtimer_try_to_cancel(&bfqd->idle_slice_timer); in bfq_select_queue()
5007 else if (!idling_boosts_thr_without_issues(bfqd, bfqq) && in bfq_select_queue()
5008 (bfqq->wr_coeff == 1 || bfqd->wr_busy_queues > 1 || in bfq_select_queue()
5010 bfqq = bfq_choose_bfqq_for_injection(bfqd); in bfq_select_queue()
5019 bfq_bfqq_expire(bfqd, bfqq, false, reason); in bfq_select_queue()
5021 bfqq = bfq_set_in_service_queue(bfqd); in bfq_select_queue()
5023 bfq_log_bfqq(bfqd, bfqq, "select_queue: checking new queue"); in bfq_select_queue()
5028 bfq_log_bfqq(bfqd, bfqq, "select_queue: returned this queue"); in bfq_select_queue()
5030 bfq_log(bfqd, "select_queue: no queue returned"); in bfq_select_queue()
5035 static void bfq_update_wr_data(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_update_wr_data() argument
5040 bfq_log_bfqq(bfqd, bfqq, in bfq_update_wr_data()
5048 bfq_log_bfqq(bfqd, bfqq, "WARN: pending prio change"); in bfq_update_wr_data()
5059 if (bfqq->wr_cur_max_time != bfqd->bfq_wr_rt_max_time || in bfq_update_wr_data()
5061 bfq_wr_duration(bfqd))) { in bfq_update_wr_data()
5076 switch_back_to_interactive_wr(bfqq, bfqd); in bfq_update_wr_data()
5081 bfqq->wr_cur_max_time != bfqd->bfq_wr_rt_max_time && in bfq_update_wr_data()
5103 static struct request *bfq_dispatch_rq_from_bfqq(struct bfq_data *bfqd, in bfq_dispatch_rq_from_bfqq() argument
5113 if (bfqq == bfqd->in_service_queue && bfqd->wait_dispatch) { in bfq_dispatch_rq_from_bfqq()
5114 bfqd->wait_dispatch = false; in bfq_dispatch_rq_from_bfqq()
5115 bfqd->waited_rq = rq; in bfq_dispatch_rq_from_bfqq()
5118 bfq_dispatch_remove(bfqd->queue, rq); in bfq_dispatch_rq_from_bfqq()
5120 if (bfqq != bfqd->in_service_queue) in bfq_dispatch_rq_from_bfqq()
5134 bfq_update_wr_data(bfqd, bfqq); in bfq_dispatch_rq_from_bfqq()
5141 if (bfq_tot_busy_queues(bfqd) > 1 && bfq_class_idle(bfqq)) in bfq_dispatch_rq_from_bfqq()
5142 bfq_bfqq_expire(bfqd, bfqq, false, BFQQE_BUDGET_EXHAUSTED); in bfq_dispatch_rq_from_bfqq()
5149 struct bfq_data *bfqd = hctx->queue->elevator->elevator_data; in bfq_has_work() local
5155 return !list_empty_careful(&bfqd->dispatch) || in bfq_has_work()
5156 READ_ONCE(bfqd->queued); in bfq_has_work()
5161 struct bfq_data *bfqd = hctx->queue->elevator->elevator_data; in __bfq_dispatch_request() local
5165 if (!list_empty(&bfqd->dispatch)) { in __bfq_dispatch_request()
5166 rq = list_first_entry(&bfqd->dispatch, struct request, in __bfq_dispatch_request()
5210 bfq_log(bfqd, "dispatch requests: %d busy queues", in __bfq_dispatch_request()
5211 bfq_tot_busy_queues(bfqd)); in __bfq_dispatch_request()
5213 if (bfq_tot_busy_queues(bfqd) == 0) in __bfq_dispatch_request()
5228 if (bfqd->strict_guarantees && bfqd->tot_rq_in_driver > 0) in __bfq_dispatch_request()
5231 bfqq = bfq_select_queue(bfqd); in __bfq_dispatch_request()
5235 rq = bfq_dispatch_rq_from_bfqq(bfqd, bfqq); in __bfq_dispatch_request()
5239 bfqd->rq_in_driver[bfqq->actuator_idx]++; in __bfq_dispatch_request()
5240 bfqd->tot_rq_in_driver++; in __bfq_dispatch_request()
5302 struct bfq_data *bfqd = hctx->queue->elevator->elevator_data; in bfq_dispatch_request() local
5307 spin_lock_irq(&bfqd->lock); in bfq_dispatch_request()
5309 in_serv_queue = bfqd->in_service_queue; in bfq_dispatch_request()
5313 if (in_serv_queue == bfqd->in_service_queue) { in bfq_dispatch_request()
5318 spin_unlock_irq(&bfqd->lock); in bfq_dispatch_request()
5339 bfq_log_bfqq(bfqq->bfqd, bfqq, "put_queue: %p %d", bfqq, bfqq->ref); in bfq_put_queue()
5373 if (bfqq->bic && bfqq->bfqd->burst_size > 0) in bfq_put_queue()
5374 bfqq->bfqd->burst_size--; in bfq_put_queue()
5403 if (bfqq->bfqd->last_completed_rq_bfqq == bfqq) in bfq_put_queue()
5404 bfqq->bfqd->last_completed_rq_bfqq = NULL; in bfq_put_queue()
5437 static void bfq_exit_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_exit_bfqq() argument
5439 if (bfqq == bfqd->in_service_queue) { in bfq_exit_bfqq()
5440 __bfq_bfqq_expire(bfqd, bfqq, BFQQE_BUDGET_TIMEOUT); in bfq_exit_bfqq()
5441 bfq_schedule_dispatch(bfqd); in bfq_exit_bfqq()
5444 bfq_log_bfqq(bfqd, bfqq, "exit_bfqq: %p, %d", bfqq, bfqq->ref); in bfq_exit_bfqq()
5448 bfq_release_process_ref(bfqd, bfqq); in bfq_exit_bfqq()
5455 struct bfq_data *bfqd; in bfq_exit_icq_bfqq() local
5458 bfqd = bfqq->bfqd; /* NULL if scheduler already exited */ in bfq_exit_icq_bfqq()
5460 if (bfqq && bfqd) { in bfq_exit_icq_bfqq()
5462 bfq_exit_bfqq(bfqd, bfqq); in bfq_exit_icq_bfqq()
5469 struct bfq_data *bfqd = bic_to_bfqd(bic); in bfq_exit_icq() local
5485 if (bfqd) { in bfq_exit_icq()
5486 spin_lock_irqsave(&bfqd->lock, flags); in bfq_exit_icq()
5487 num_actuators = bfqd->num_actuators; in bfq_exit_icq()
5498 if (bfqd) in bfq_exit_icq()
5499 spin_unlock_irqrestore(&bfqd->lock, flags); in bfq_exit_icq()
5511 struct bfq_data *bfqd = bfqq->bfqd; in bfq_set_next_ioprio_data() local
5513 if (!bfqd) in bfq_set_next_ioprio_data()
5520 bdi_dev_name(bfqq->bfqd->queue->disk->bdi), in bfq_set_next_ioprio_data()
5551 bfq_log_bfqq(bfqd, bfqq, "new_ioprio %d new_weight %d", in bfq_set_next_ioprio_data()
5556 static struct bfq_queue *bfq_get_queue(struct bfq_data *bfqd,
5563 struct bfq_data *bfqd = bic_to_bfqd(bic); in bfq_check_ioprio_change() local
5571 if (unlikely(!bfqd) || likely(bic->ioprio == ioprio)) in bfq_check_ioprio_change()
5576 bfqq = bic_to_bfqq(bic, false, bfq_actuator_index(bfqd, bio)); in bfq_check_ioprio_change()
5580 bfqq = bfq_get_queue(bfqd, bio, false, bic, true); in bfq_check_ioprio_change()
5581 bic_set_bfqq(bic, bfqq, false, bfq_actuator_index(bfqd, bio)); in bfq_check_ioprio_change()
5582 bfq_release_process_ref(bfqd, old_bfqq); in bfq_check_ioprio_change()
5585 bfqq = bic_to_bfqq(bic, true, bfq_actuator_index(bfqd, bio)); in bfq_check_ioprio_change()
5590 static void bfq_init_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_init_bfqq() argument
5604 bfqq->bfqd = bfqd; in bfq_init_bfqq()
5635 bfqq->max_budget = (2 * bfq_max_budget(bfqd)) / 3; in bfq_init_bfqq()
5660 static struct bfq_queue **bfq_async_queue_prio(struct bfq_data *bfqd, in bfq_async_queue_prio() argument
5680 bfq_do_early_stable_merge(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_do_early_stable_merge() argument
5702 bfq_merge_bfqqs(bfqd, bic, bfqq, new_bfqq); in bfq_do_early_stable_merge()
5753 static struct bfq_queue *bfq_do_or_sched_stable_merge(struct bfq_data *bfqd, in bfq_do_or_sched_stable_merge() argument
5759 &bfqd->last_bfqq_created; in bfq_do_or_sched_stable_merge()
5796 bfqd->bfq_burst_interval, in bfq_do_or_sched_stable_merge()
5798 if (likely(bfqd->nonrot_with_queueing)) in bfq_do_or_sched_stable_merge()
5805 bfqq = bfq_do_early_stable_merge(bfqd, bfqq, in bfq_do_or_sched_stable_merge()
5832 static struct bfq_queue *bfq_get_queue(struct bfq_data *bfqd, in bfq_get_queue() argument
5843 bfqg = bfq_bio_bfqg(bfqd, bio); in bfq_get_queue()
5845 async_bfqq = bfq_async_queue_prio(bfqd, bfqg, ioprio_class, in bfq_get_queue()
5847 bfq_actuator_index(bfqd, bio)); in bfq_get_queue()
5855 bfqd->queue->node); in bfq_get_queue()
5858 bfq_init_bfqq(bfqd, bfqq, bic, current->pid, in bfq_get_queue()
5859 is_sync, bfq_actuator_index(bfqd, bio)); in bfq_get_queue()
5861 bfq_log_bfqq(bfqd, bfqq, "allocated"); in bfq_get_queue()
5863 bfqq = &bfqd->oom_bfqq; in bfq_get_queue()
5864 bfq_log_bfqq(bfqd, bfqq, "using oom bfqq"); in bfq_get_queue()
5880 bfq_log_bfqq(bfqd, bfqq, "get_queue, bfqq not in async: %p, %d", in bfq_get_queue()
5888 if (bfqq != &bfqd->oom_bfqq && is_sync && !respawn) in bfq_get_queue()
5889 bfqq = bfq_do_or_sched_stable_merge(bfqd, bfqq, bic); in bfq_get_queue()
5893 static void bfq_update_io_thinktime(struct bfq_data *bfqd, in bfq_update_io_thinktime() argument
5907 elapsed = min_t(u64, elapsed, 2ULL * bfqd->bfq_slice_idle); in bfq_update_io_thinktime()
5916 bfq_update_io_seektime(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_update_io_seektime() argument
5920 bfqq->seek_history |= BFQ_RQ_SEEKY(bfqd, bfqq->last_request_pos, rq); in bfq_update_io_seektime()
5923 bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time && in bfq_update_io_seektime()
5926 bfq_wr_duration(bfqd))) { in bfq_update_io_seektime()
5940 switch_back_to_interactive_wr(bfqq, bfqd); in bfq_update_io_seektime()
5946 static void bfq_update_has_short_ttime(struct bfq_data *bfqd, in bfq_update_has_short_ttime() argument
5958 bfqd->bfq_slice_idle == 0) in bfq_update_has_short_ttime()
5963 bfqd->bfq_wr_min_idle_time)) in bfq_update_has_short_ttime()
5973 bfqq->ttime.ttime_mean > bfqd->bfq_slice_idle>>1)) in bfq_update_has_short_ttime()
6071 bfq_reset_inject_limit(bfqd, bfqq); in bfq_update_has_short_ttime()
6078 static void bfq_rq_enqueued(struct bfq_data *bfqd, struct bfq_queue *bfqq, in bfq_rq_enqueued() argument
6086 if (bfqq == bfqd->in_service_queue && bfq_bfqq_wait_request(bfqq)) { in bfq_rq_enqueued()
6107 if (small_req && idling_boosts_thr_without_issues(bfqd, bfqq) && in bfq_rq_enqueued()
6119 hrtimer_try_to_cancel(&bfqd->idle_slice_timer); in bfq_rq_enqueued()
6129 bfq_bfqq_expire(bfqd, bfqq, false, in bfq_rq_enqueued()
6151 static bool __bfq_insert_request(struct bfq_data *bfqd, struct request *rq) in __bfq_insert_request() argument
6154 *new_bfqq = bfq_setup_cooperator(bfqd, bfqq, rq, true, in __bfq_insert_request()
6175 bfq_actuator_index(bfqd, rq->bio)) == bfqq) in __bfq_insert_request()
6176 bfq_merge_bfqqs(bfqd, RQ_BIC(rq), in __bfq_insert_request()
6189 bfq_update_io_thinktime(bfqd, bfqq); in __bfq_insert_request()
6190 bfq_update_has_short_ttime(bfqd, bfqq, RQ_BIC(rq)); in __bfq_insert_request()
6191 bfq_update_io_seektime(bfqd, bfqq, rq); in __bfq_insert_request()
6197 rq->fifo_time = ktime_get_ns() + bfqd->bfq_fifo_expire[rq_is_sync(rq)]; in __bfq_insert_request()
6200 bfq_rq_enqueued(bfqd, bfqq, rq); in __bfq_insert_request()
6243 struct bfq_data *bfqd = q->elevator->elevator_data; in bfq_insert_request() local
6253 spin_lock_irq(&bfqd->lock); in bfq_insert_request()
6256 spin_unlock_irq(&bfqd->lock); in bfq_insert_request()
6264 list_add(&rq->queuelist, &bfqd->dispatch); in bfq_insert_request()
6266 list_add_tail(&rq->queuelist, &bfqd->dispatch); in bfq_insert_request()
6268 idle_timer_disabled = __bfq_insert_request(bfqd, rq); in bfq_insert_request()
6289 spin_unlock_irq(&bfqd->lock); in bfq_insert_request()
6308 static void bfq_update_hw_tag(struct bfq_data *bfqd) in bfq_update_hw_tag() argument
6310 struct bfq_queue *bfqq = bfqd->in_service_queue; in bfq_update_hw_tag()
6312 bfqd->max_rq_in_driver = max_t(int, bfqd->max_rq_in_driver, in bfq_update_hw_tag()
6313 bfqd->tot_rq_in_driver); in bfq_update_hw_tag()
6315 if (bfqd->hw_tag == 1) in bfq_update_hw_tag()
6324 if (bfqd->tot_rq_in_driver + bfqd->queued <= BFQ_HW_QUEUE_THRESHOLD) in bfq_update_hw_tag()
6335 bfqd->tot_rq_in_driver < BFQ_HW_QUEUE_THRESHOLD) in bfq_update_hw_tag()
6338 if (bfqd->hw_tag_samples++ < BFQ_HW_QUEUE_SAMPLES) in bfq_update_hw_tag()
6341 bfqd->hw_tag = bfqd->max_rq_in_driver > BFQ_HW_QUEUE_THRESHOLD; in bfq_update_hw_tag()
6342 bfqd->max_rq_in_driver = 0; in bfq_update_hw_tag()
6343 bfqd->hw_tag_samples = 0; in bfq_update_hw_tag()
6345 bfqd->nonrot_with_queueing = in bfq_update_hw_tag()
6346 blk_queue_nonrot(bfqd->queue) && bfqd->hw_tag; in bfq_update_hw_tag()
6349 static void bfq_completed_request(struct bfq_queue *bfqq, struct bfq_data *bfqd) in bfq_completed_request() argument
6354 bfq_update_hw_tag(bfqd); in bfq_completed_request()
6356 bfqd->rq_in_driver[bfqq->actuator_idx]--; in bfq_completed_request()
6357 bfqd->tot_rq_in_driver--; in bfq_completed_request()
6381 delta_us = div_u64(now_ns - bfqd->last_completion, NSEC_PER_USEC); in bfq_completed_request()
6400 (bfqd->last_rq_max_size<<BFQ_RATE_SHIFT)/delta_us < in bfq_completed_request()
6402 bfq_update_rate_reset(bfqd, NULL); in bfq_completed_request()
6403 bfqd->last_completion = now_ns; in bfq_completed_request()
6414 bfqd->last_completed_rq_bfqq = bfqq; in bfq_completed_request()
6416 bfqd->last_completed_rq_bfqq = NULL; in bfq_completed_request()
6431 bfqq->wr_coeff != bfqd->bfq_wr_coeff) in bfq_completed_request()
6433 bfq_bfqq_softrt_next_start(bfqd, bfqq); in bfq_completed_request()
6439 if (bfqd->in_service_queue == bfqq) { in bfq_completed_request()
6442 bfq_arm_slice_timer(bfqd); in bfq_completed_request()
6468 bfq_bfqq_expire(bfqd, bfqq, false, in bfq_completed_request()
6473 bfq_bfqq_expire(bfqd, bfqq, false, in bfq_completed_request()
6477 if (!bfqd->tot_rq_in_driver) in bfq_completed_request()
6478 bfq_schedule_dispatch(bfqd); in bfq_completed_request()
6585 static void bfq_update_inject_limit(struct bfq_data *bfqd, in bfq_update_inject_limit() argument
6588 u64 tot_time_ns = ktime_get_ns() - bfqd->last_empty_occupied_ns; in bfq_update_inject_limit()
6591 if (bfqq->last_serv_time_ns > 0 && bfqd->rqs_injected) { in bfq_update_inject_limit()
6598 old_limit <= bfqd->max_rq_in_driver) in bfq_update_inject_limit()
6614 if ((bfqq->last_serv_time_ns == 0 && bfqd->tot_rq_in_driver == 1) || in bfq_update_inject_limit()
6624 } else if (!bfqd->rqs_injected && bfqd->tot_rq_in_driver == 1) in bfq_update_inject_limit()
6638 bfqd->waited_rq = NULL; in bfq_update_inject_limit()
6639 bfqd->rqs_injected = false; in bfq_update_inject_limit()
6651 struct bfq_data *bfqd; in bfq_finish_requeue_request() local
6662 bfqd = bfqq->bfqd; in bfq_finish_requeue_request()
6670 spin_lock_irqsave(&bfqd->lock, flags); in bfq_finish_requeue_request()
6672 if (rq == bfqd->waited_rq) in bfq_finish_requeue_request()
6673 bfq_update_inject_limit(bfqd, bfqq); in bfq_finish_requeue_request()
6675 bfq_completed_request(bfqq, bfqd); in bfq_finish_requeue_request()
6680 spin_unlock_irqrestore(&bfqd->lock, flags); in bfq_finish_requeue_request()
6722 bfq_log_bfqq(bfqq->bfqd, bfqq, "splitting queue"); in bfq_split_bfqq()
6735 bfq_release_process_ref(bfqq->bfqd, bfqq); in bfq_split_bfqq()
6739 static struct bfq_queue *bfq_get_bfqq_handle_split(struct bfq_data *bfqd, in bfq_get_bfqq_handle_split() argument
6745 unsigned int act_idx = bfq_actuator_index(bfqd, bio); in bfq_get_bfqq_handle_split()
6749 if (likely(bfqq && bfqq != &bfqd->oom_bfqq)) in bfq_get_bfqq_handle_split()
6757 bfqq = bfq_get_queue(bfqd, bio, is_sync, bic, split); in bfq_get_bfqq_handle_split()
6761 if ((bfqq_data->was_in_burst_list && bfqd->large_burst) || in bfq_get_bfqq_handle_split()
6796 &bfqd->burst_list); in bfq_get_bfqq_handle_split()
6849 struct bfq_data *bfqd = q->elevator->elevator_data; in bfq_init_rq() local
6855 unsigned int a_idx = bfq_actuator_index(bfqd, bio); in bfq_init_rq()
6876 bfqq = bfq_get_bfqq_handle_split(bfqd, bic, bio, false, is_sync, in bfq_init_rq()
6894 bfqq = bfq_get_bfqq_handle_split(bfqd, bic, bio, in bfq_init_rq()
6897 if (unlikely(bfqq == &bfqd->oom_bfqq)) in bfq_init_rq()
6923 bfq_log_bfqq(bfqd, bfqq, "get_request %p: bfqq %p, %d", in bfq_init_rq()
6935 if (likely(bfqq != &bfqd->oom_bfqq) && bfqq_process_refs(bfqq) == 1) { in bfq_init_rq()
6943 bfq_bfqq_resume_state(bfqq, bfqd, bic, in bfq_init_rq()
6969 (bfqd->burst_size > 0 || in bfq_init_rq()
6970 bfq_tot_busy_queues(bfqd) == 0))) in bfq_init_rq()
6971 bfq_handle_burst(bfqd, bfqq); in bfq_init_rq()
6977 bfq_idle_slice_timer_body(struct bfq_data *bfqd, struct bfq_queue *bfqq) in bfq_idle_slice_timer_body() argument
6982 spin_lock_irqsave(&bfqd->lock, flags); in bfq_idle_slice_timer_body()
6991 if (bfqq != bfqd->in_service_queue) { in bfq_idle_slice_timer_body()
6992 spin_unlock_irqrestore(&bfqd->lock, flags); in bfq_idle_slice_timer_body()
7016 bfq_bfqq_expire(bfqd, bfqq, true, reason); in bfq_idle_slice_timer_body()
7019 bfq_schedule_dispatch(bfqd); in bfq_idle_slice_timer_body()
7020 spin_unlock_irqrestore(&bfqd->lock, flags); in bfq_idle_slice_timer_body()
7029 struct bfq_data *bfqd = container_of(timer, struct bfq_data, in bfq_idle_slice_timer() local
7031 struct bfq_queue *bfqq = bfqd->in_service_queue; in bfq_idle_slice_timer()
7042 bfq_idle_slice_timer_body(bfqd, bfqq); in bfq_idle_slice_timer()
7047 static void __bfq_put_async_bfqq(struct bfq_data *bfqd, in __bfq_put_async_bfqq() argument
7052 bfq_log(bfqd, "put_async_bfqq: %p", bfqq); in __bfq_put_async_bfqq()
7054 bfq_bfqq_move(bfqd, bfqq, bfqd->root_group); in __bfq_put_async_bfqq()
7056 bfq_log_bfqq(bfqd, bfqq, "put_async_bfqq: putting %p, %d", in __bfq_put_async_bfqq()
7069 void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg) in bfq_put_async_queues() argument
7073 for (k = 0; k < bfqd->num_actuators; k++) { in bfq_put_async_queues()
7076 __bfq_put_async_bfqq(bfqd, &bfqg->async_bfqq[i][j][k]); in bfq_put_async_queues()
7078 __bfq_put_async_bfqq(bfqd, &bfqg->async_idle_bfqq[k]); in bfq_put_async_queues()
7086 static void bfq_update_depths(struct bfq_data *bfqd, struct sbitmap_queue *bt) in bfq_update_depths() argument
7090 bfqd->full_depth_shift = bt->sb.shift; in bfq_update_depths()
7102 bfqd->word_depths[0][0] = max(depth >> 1, 1U); in bfq_update_depths()
7108 bfqd->word_depths[0][1] = max((depth * 3) >> 2, 1U); in bfq_update_depths()
7118 bfqd->word_depths[1][0] = max((depth * 3) >> 4, 1U); in bfq_update_depths()
7120 bfqd->word_depths[1][1] = max((depth * 6) >> 4, 1U); in bfq_update_depths()
7125 struct bfq_data *bfqd = hctx->queue->elevator->elevator_data; in bfq_depth_updated() local
7128 bfq_update_depths(bfqd, &tags->bitmap_tags); in bfq_depth_updated()
7140 struct bfq_data *bfqd = e->elevator_data; in bfq_exit_queue() local
7144 hrtimer_cancel(&bfqd->idle_slice_timer); in bfq_exit_queue()
7146 spin_lock_irq(&bfqd->lock); in bfq_exit_queue()
7147 list_for_each_entry_safe(bfqq, n, &bfqd->idle_list, bfqq_list) in bfq_exit_queue()
7148 bfq_deactivate_bfqq(bfqd, bfqq, false, false); in bfq_exit_queue()
7149 spin_unlock_irq(&bfqd->lock); in bfq_exit_queue()
7151 for (actuator = 0; actuator < bfqd->num_actuators; actuator++) in bfq_exit_queue()
7152 WARN_ON_ONCE(bfqd->rq_in_driver[actuator]); in bfq_exit_queue()
7153 WARN_ON_ONCE(bfqd->tot_rq_in_driver); in bfq_exit_queue()
7155 hrtimer_cancel(&bfqd->idle_slice_timer); in bfq_exit_queue()
7158 bfqg_and_blkg_put(bfqd->root_group); in bfq_exit_queue()
7161 blkcg_deactivate_policy(bfqd->queue->disk, &blkcg_policy_bfq); in bfq_exit_queue()
7163 spin_lock_irq(&bfqd->lock); in bfq_exit_queue()
7164 bfq_put_async_queues(bfqd, bfqd->root_group); in bfq_exit_queue()
7165 kfree(bfqd->root_group); in bfq_exit_queue()
7166 spin_unlock_irq(&bfqd->lock); in bfq_exit_queue()
7169 blk_stat_disable_accounting(bfqd->queue); in bfq_exit_queue()
7171 wbt_enable_default(bfqd->queue->disk); in bfq_exit_queue()
7173 kfree(bfqd); in bfq_exit_queue()
7177 struct bfq_data *bfqd) in bfq_init_root_group() argument
7184 root_group->bfqd = bfqd; in bfq_init_root_group()
7194 struct bfq_data *bfqd; in bfq_init_queue() local
7203 bfqd = kzalloc_node(sizeof(*bfqd), GFP_KERNEL, q->node); in bfq_init_queue()
7204 if (!bfqd) { in bfq_init_queue()
7208 eq->elevator_data = bfqd; in bfq_init_queue()
7221 bfq_init_bfqq(bfqd, &bfqd->oom_bfqq, NULL, 1, 0, 0); in bfq_init_queue()
7222 bfqd->oom_bfqq.ref++; in bfq_init_queue()
7223 bfqd->oom_bfqq.new_ioprio = BFQ_DEFAULT_QUEUE_IOPRIO; in bfq_init_queue()
7224 bfqd->oom_bfqq.new_ioprio_class = IOPRIO_CLASS_BE; in bfq_init_queue()
7225 bfqd->oom_bfqq.entity.new_weight = in bfq_init_queue()
7226 bfq_ioprio_to_weight(bfqd->oom_bfqq.new_ioprio); in bfq_init_queue()
7229 bfq_clear_bfqq_just_created(&bfqd->oom_bfqq); in bfq_init_queue()
7236 bfqd->oom_bfqq.entity.prio_changed = 1; in bfq_init_queue()
7238 bfqd->queue = q; in bfq_init_queue()
7240 bfqd->num_actuators = 1; in bfq_init_queue()
7256 bfqd->num_actuators = ia_ranges->nr_ia_ranges; in bfq_init_queue()
7258 for (i = 0; i < bfqd->num_actuators; i++) { in bfq_init_queue()
7259 bfqd->sector[i] = ia_ranges->ia_range[i].sector; in bfq_init_queue()
7260 bfqd->nr_sectors[i] = in bfq_init_queue()
7267 if (bfqd->num_actuators == 1) { in bfq_init_queue()
7268 bfqd->sector[0] = 0; in bfq_init_queue()
7269 bfqd->nr_sectors[0] = get_capacity(q->disk); in bfq_init_queue()
7273 INIT_LIST_HEAD(&bfqd->dispatch); in bfq_init_queue()
7275 hrtimer_init(&bfqd->idle_slice_timer, CLOCK_MONOTONIC, in bfq_init_queue()
7277 bfqd->idle_slice_timer.function = bfq_idle_slice_timer; in bfq_init_queue()
7279 bfqd->queue_weights_tree = RB_ROOT_CACHED; in bfq_init_queue()
7281 bfqd->num_groups_with_pending_reqs = 0; in bfq_init_queue()
7284 INIT_LIST_HEAD(&bfqd->active_list[0]); in bfq_init_queue()
7285 INIT_LIST_HEAD(&bfqd->active_list[1]); in bfq_init_queue()
7286 INIT_LIST_HEAD(&bfqd->idle_list); in bfq_init_queue()
7287 INIT_HLIST_HEAD(&bfqd->burst_list); in bfq_init_queue()
7289 bfqd->hw_tag = -1; in bfq_init_queue()
7290 bfqd->nonrot_with_queueing = blk_queue_nonrot(bfqd->queue); in bfq_init_queue()
7292 bfqd->bfq_max_budget = bfq_default_max_budget; in bfq_init_queue()
7294 bfqd->bfq_fifo_expire[0] = bfq_fifo_expire[0]; in bfq_init_queue()
7295 bfqd->bfq_fifo_expire[1] = bfq_fifo_expire[1]; in bfq_init_queue()
7296 bfqd->bfq_back_max = bfq_back_max; in bfq_init_queue()
7297 bfqd->bfq_back_penalty = bfq_back_penalty; in bfq_init_queue()
7298 bfqd->bfq_slice_idle = bfq_slice_idle; in bfq_init_queue()
7299 bfqd->bfq_timeout = bfq_timeout; in bfq_init_queue()
7301 bfqd->bfq_large_burst_thresh = 8; in bfq_init_queue()
7302 bfqd->bfq_burst_interval = msecs_to_jiffies(180); in bfq_init_queue()
7304 bfqd->low_latency = true; in bfq_init_queue()
7309 bfqd->bfq_wr_coeff = 30; in bfq_init_queue()
7310 bfqd->bfq_wr_rt_max_time = msecs_to_jiffies(300); in bfq_init_queue()
7311 bfqd->bfq_wr_min_idle_time = msecs_to_jiffies(2000); in bfq_init_queue()
7312 bfqd->bfq_wr_min_inter_arr_async = msecs_to_jiffies(500); in bfq_init_queue()
7313 bfqd->bfq_wr_max_softrt_rate = 7000; /* in bfq_init_queue()
7319 bfqd->wr_busy_queues = 0; in bfq_init_queue()
7325 bfqd->rate_dur_prod = ref_rate[blk_queue_nonrot(bfqd->queue)] * in bfq_init_queue()
7326 ref_wr_duration[blk_queue_nonrot(bfqd->queue)]; in bfq_init_queue()
7327 bfqd->peak_rate = ref_rate[blk_queue_nonrot(bfqd->queue)] * 2 / 3; in bfq_init_queue()
7330 bfqd->actuator_load_threshold = 4; in bfq_init_queue()
7332 spin_lock_init(&bfqd->lock); in bfq_init_queue()
7349 bfqd->root_group = bfq_create_group_hierarchy(bfqd, q->node); in bfq_init_queue()
7350 if (!bfqd->root_group) in bfq_init_queue()
7352 bfq_init_root_group(bfqd->root_group, bfqd); in bfq_init_queue()
7353 bfq_init_entity(&bfqd->oom_bfqq.entity, bfqd->root_group); in bfq_init_queue()
7365 kfree(bfqd); in bfq_init_queue()
7402 struct bfq_data *bfqd = e->elevator_data; \
7410 SHOW_FUNCTION(bfq_fifo_expire_sync_show, bfqd->bfq_fifo_expire[1], 2);
7411 SHOW_FUNCTION(bfq_fifo_expire_async_show, bfqd->bfq_fifo_expire[0], 2);
7412 SHOW_FUNCTION(bfq_back_seek_max_show, bfqd->bfq_back_max, 0);
7413 SHOW_FUNCTION(bfq_back_seek_penalty_show, bfqd->bfq_back_penalty, 0);
7414 SHOW_FUNCTION(bfq_slice_idle_show, bfqd->bfq_slice_idle, 2);
7415 SHOW_FUNCTION(bfq_max_budget_show, bfqd->bfq_user_max_budget, 0);
7416 SHOW_FUNCTION(bfq_timeout_sync_show, bfqd->bfq_timeout, 1);
7417 SHOW_FUNCTION(bfq_strict_guarantees_show, bfqd->strict_guarantees, 0);
7418 SHOW_FUNCTION(bfq_low_latency_show, bfqd->low_latency, 0);
7424 struct bfq_data *bfqd = e->elevator_data; \
7429 USEC_SHOW_FUNCTION(bfq_slice_idle_us_show, bfqd->bfq_slice_idle);
7436 struct bfq_data *bfqd = e->elevator_data; \
7455 STORE_FUNCTION(bfq_fifo_expire_sync_store, &bfqd->bfq_fifo_expire[1], 1,
7457 STORE_FUNCTION(bfq_fifo_expire_async_store, &bfqd->bfq_fifo_expire[0], 1,
7459 STORE_FUNCTION(bfq_back_seek_max_store, &bfqd->bfq_back_max, 0, INT_MAX, 0);
7460 STORE_FUNCTION(bfq_back_seek_penalty_store, &bfqd->bfq_back_penalty, 1,
7462 STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, INT_MAX, 2);
7468 struct bfq_data *bfqd = e->elevator_data; \
7482 USEC_STORE_FUNCTION(bfq_slice_idle_us_store, &bfqd->bfq_slice_idle, 0,
7489 struct bfq_data *bfqd = e->elevator_data; in bfq_max_budget_store() local
7498 bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); in bfq_max_budget_store()
7502 bfqd->bfq_max_budget = __data; in bfq_max_budget_store()
7505 bfqd->bfq_user_max_budget = __data; in bfq_max_budget_store()
7517 struct bfq_data *bfqd = e->elevator_data; in bfq_timeout_sync_store() local
7530 bfqd->bfq_timeout = msecs_to_jiffies(__data); in bfq_timeout_sync_store()
7531 if (bfqd->bfq_user_max_budget == 0) in bfq_timeout_sync_store()
7532 bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); in bfq_timeout_sync_store()
7540 struct bfq_data *bfqd = e->elevator_data; in bfq_strict_guarantees_store() local
7550 if (!bfqd->strict_guarantees && __data == 1 in bfq_strict_guarantees_store()
7551 && bfqd->bfq_slice_idle < 8 * NSEC_PER_MSEC) in bfq_strict_guarantees_store()
7552 bfqd->bfq_slice_idle = 8 * NSEC_PER_MSEC; in bfq_strict_guarantees_store()
7554 bfqd->strict_guarantees = __data; in bfq_strict_guarantees_store()
7562 struct bfq_data *bfqd = e->elevator_data; in bfq_low_latency_store() local
7572 if (__data == 0 && bfqd->low_latency != 0) in bfq_low_latency_store()
7573 bfq_end_wr(bfqd); in bfq_low_latency_store()
7574 bfqd->low_latency = __data; in bfq_low_latency_store()