Skip to content

Commit

Permalink
block, bfq: improve arithmetic division in bfq_delta()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
taskset authored and axboe committed Jan 22, 2020
1 parent b7f22d9 commit 554d21e
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions block/bfq-wf2q.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 554d21e

Please sign in to comment.