Re: [PATCH V2 04/16] block, bfq: modify the peak-rate estimator
From: Bart Van Assche <hidden>
Date: 2017-04-04 15:29:21
Also in:
lkml
On Tue, 2017-04-04 at 12:42 +0200, Paolo Valente wrote:
quoted
Il giorno 31 mar 2017, alle ore 17:31, Bart Van Assche <bart.vanassche@=
sandisk.com> ha scritto:
quoted
=20 On Fri, 2017-03-31 at 14:47 +0200, Paolo Valente wrote:quoted
+ delta_ktime =3D ktime_get(); + delta_ktime =3D ktime_sub(delta_ktime, bfqd->last_budget_star=
t);
quoted
quoted
+ delta_usecs =3D ktime_to_us(delta_ktime);=20 This patch changes the type of the variable in which the result of ktim=
e_to_us()
quoted
is stored from u64 into u32 and next compares that result with LONG_MAX=
. Since
quoted
ktime_to_us() returns a signed 64-bit number, are you sure you want to =
store that
quoted
result in a 32-bit variable? If ktime_to_us() would e.g. return 0xfffff=
fff00000100
quoted
or 0x100000100 then the assignment will truncate these numbers to 0x100=
.
=20 The instruction above the assignment you highlight stores in delta_ktime the difference between 'now' and the last budget start. The latter may have happened at most about 100 ms before 'now'. So there should be no overflow issue.
Hello Paolo, Please double check the following code: if (delta_usecs < 1000 || delta_use= cs >=3D LONG_MAX) Since delta_usecs is a 32-bit variable and LONG_MAX a 64-bit constant on 64= -bit systems I'm not sure that code will do what it is intended to do. Thanks, Bart.=