Message ID | 56a03261ec32ef67a8ce36106bf2f2f7638600ca.1538151757.git.osandov@fb.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | kyber: fix integer overflow of latency targets on 32-bit | expand |
On 9/28/18 10:22 AM, Omar Sandoval wrote: > From: Omar Sandoval <osandov@fb.com> > > 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. Applied, thanks Omar.
diff --git a/block/kyber-iosched.c b/block/kyber-iosched.c index 2b62e362fb36..eccac01a10b6 100644 --- a/block/kyber-iosched.c +++ b/block/kyber-iosched.c @@ -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, }; /*