Commit f8121648 authored by Paolo Valente's avatar Paolo Valente Committed by Jens Axboe

block, bfq: improve code of bfq_bfqq_charge_time

bfq_bfqq_charge_time contains some lengthy and redundant code. This
commit trims and condenses that code.
Signed-off-by: default avatarPaolo Valente <paolo.valente@linaro.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent d5801088
...@@ -881,15 +881,11 @@ void bfq_bfqq_charge_time(struct bfq_data *bfqd, struct bfq_queue *bfqq, ...@@ -881,15 +881,11 @@ void bfq_bfqq_charge_time(struct bfq_data *bfqd, struct bfq_queue *bfqq,
unsigned long time_ms) unsigned long time_ms)
{ {
struct bfq_entity *entity = &bfqq->entity; struct bfq_entity *entity = &bfqq->entity;
int tot_serv_to_charge = entity->service; unsigned long timeout_ms = jiffies_to_msecs(bfq_timeout);
unsigned int timeout_ms = jiffies_to_msecs(bfq_timeout); unsigned long bounded_time_ms = min(time_ms, timeout_ms);
int serv_to_charge_for_time =
if (time_ms > 0 && time_ms < timeout_ms) (bfqd->bfq_max_budget * bounded_time_ms) / timeout_ms;
tot_serv_to_charge = int tot_serv_to_charge = max(serv_to_charge_for_time, entity->service);
(bfqd->bfq_max_budget * time_ms) / timeout_ms;
if (tot_serv_to_charge < entity->service)
tot_serv_to_charge = entity->service;
/* Increase budget to avoid inconsistencies */ /* Increase budget to avoid inconsistencies */
if (tot_serv_to_charge > entity->budget) if (tot_serv_to_charge > entity->budget)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment