aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWen Yang <[email protected]>2020-01-20 18:04:43 +0800
committerJens Axboe <[email protected]>2020-01-22 10:34:11 -0700
commit554d21efb0d2e102a14f8c4b6bdfbcfbe54b3c65 (patch)
tree0e784efc85671e7bb4e4668d115bacba43ebf54a
parentb7f22d993f51c64d79b7fd7ad2c060e3fdc006c0 (diff)
block, bfq: improve arithmetic division in bfq_delta()
do_div() does a 64-by-32 division. Use div64_ul() instead of it if the divisor is unsigned long, to avoid truncation to 32-bit. And as a nice side effect also cleans up the function a bit. Signed-off-by: Wen Yang <[email protected]> Cc: Paolo Valente <[email protected]> Cc: Jens Axboe <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Jens Axboe <[email protected]>
-rw-r--r--block/bfq-wf2q.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c
index 05f0bf4a1144..ffe9ce9faa89 100644
--- a/block/bfq-wf2q.c
+++ b/block/bfq-wf2q.c
@@ -277,10 +277,7 @@ struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity)
*/
static u64 bfq_delta(unsigned long service, unsigned long weight)
{
- u64 d = (u64)service << WFQ_SERVICE_SHIFT;
-
- do_div(d, weight);
- return d;
+ return div64_ul((u64)service << WFQ_SERVICE_SHIFT, weight);
}
/**