Skip to content

Commit

Permalink
kyber: fix integer overflow of latency targets on 32-bit
Browse files Browse the repository at this point in the history
NSEC_PER_SEC has type long, so 5 * NSEC_PER_SEC is calculated as a long.
However, 5 seconds is 5,000,000,000 nanoseconds, which overflows a
32-bit long. Make sure all of the targets are calculated as 64-bit
values.

Fixes: 6e25cb0 ("kyber: implement improved heuristics")
Reported-by: Stephen Rothwell <[email protected]>
Signed-off-by: Omar Sandoval <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
osandov authored and axboe committed Sep 28, 2018
1 parent e982c4d commit f0a0cdd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions block/kyber-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ static const unsigned int kyber_depth[] = {
* Default latency targets for each scheduling domain.
*/
static const u64 kyber_latency_targets[] = {
[KYBER_READ] = 2 * NSEC_PER_MSEC,
[KYBER_WRITE] = 10 * NSEC_PER_MSEC,
[KYBER_DISCARD] = 5 * NSEC_PER_SEC,
[KYBER_READ] = 2ULL * NSEC_PER_MSEC,
[KYBER_WRITE] = 10ULL * NSEC_PER_MSEC,
[KYBER_DISCARD] = 5ULL * NSEC_PER_SEC,
};

/*
Expand Down

0 comments on commit f0a0cdd

Please sign in to comment.