aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Valente <paolo.valente@linaro.org>2018-08-16 12:51:18 -0400
committerJens Axboe <axboe@kernel.dk>2018-08-16 15:08:15 -0400
commitf812164869b98d81d692ce12bfed76621a5c8908 (patch)
tree7a5c62594c246fe1f539964c68f9de2300304248
parentd5801088a7bd210dd8fd7add04745e35f0f6ea72 (diff)
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: Paolo Valente <paolo.valente@linaro.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/bfq-wf2q.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c
index d558fd26740c..ae52bff43ce4 100644
--- a/block/bfq-wf2q.c
+++ b/block/bfq-wf2q.c
@@ -881,15 +881,11 @@ void bfq_bfqq_charge_time(struct bfq_data *bfqd, struct bfq_queue *bfqq,
881 unsigned long time_ms) 881 unsigned long time_ms)
882{ 882{
883 struct bfq_entity *entity = &bfqq->entity; 883 struct bfq_entity *entity = &bfqq->entity;
884 int tot_serv_to_charge = entity->service; 884 unsigned long timeout_ms = jiffies_to_msecs(bfq_timeout);
885 unsigned int timeout_ms = jiffies_to_msecs(bfq_timeout); 885 unsigned long bounded_time_ms = min(time_ms, timeout_ms);
886 886 int serv_to_charge_for_time =
887 if (time_ms > 0 && time_ms < timeout_ms) 887 (bfqd->bfq_max_budget * bounded_time_ms) / timeout_ms;
888 tot_serv_to_charge = 888 int tot_serv_to_charge = max(serv_to_charge_for_time, entity->service);
889 (bfqd->bfq_max_budget * time_ms) / timeout_ms;
890
891 if (tot_serv_to_charge < entity->service)
892 tot_serv_to_charge = entity->service;
893 889
894 /* Increase budget to avoid inconsistencies */ 890 /* Increase budget to avoid inconsistencies */
895 if (tot_serv_to_charge > entity->budget) 891 if (tot_serv_to_charge > entity->budget)