提交 f0a0cddd 编写于 作者: O Omar Sandoval 提交者: Jens Axboe

kyber: fix integer overflow of latency targets on 32-bit

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: 6e25cb01 ("kyber: implement improved heuristics")
Reported-by: NStephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: NOmar Sandoval <osandov@fb.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 e982c4d0
......@@ -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,
};
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册