Return-Path: Return-Path: From: Vincent Fu Subject: Re: [PATCH] Fix overflow in percentile calculation for Windows References: <20171010212710.12526-1-andrzej.jakowski@intel.com> Message-ID: <28cd47ad-913c-0eaa-ec2d-84ab47763029@gmail.com> Date: Wed, 11 Oct 2017 19:36:46 -0400 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit To: Jens Axboe , Sitsofe Wheeler Cc: "fio@vger.kernel.org" , Andrzej Jakowski List-ID: On 11-Oct-17 18:26, Jens Axboe wrote: > On 10/11/2017 04:18 PM, Sitsofe Wheeler wrote: >> Hi Jens, >> >> On 10 October 2017 at 22:27, Andrzej Jakowski >> wrote: >>> This patch fixes percentile calculation for Windows where overflow >>> on 32 bit type happened while calculating actual percentiles. >>> >>> Signed-off-by: Andrzej Jakowski >>> --- >>> stat.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/stat.c b/stat.c >>> index c5a68ad5..5c758680 100644 >>> --- a/stat.c >>> +++ b/stat.c >>> @@ -139,7 +139,7 @@ unsigned int calc_clat_percentiles(unsigned int *io_u_plat, unsigned long nr, >>> fio_fp64_t *plist, unsigned long long **output, >>> unsigned long long *maxv, unsigned long long *minv) >>> { >>> - unsigned long sum = 0; >>> + unsigned long long sum = 0; >>> unsigned int len, i, j = 0; >>> unsigned int oval_len = 0; >>> unsigned long long *ovals = NULL; >>> -- >>> 2.13.6 >> >> Just in case you didn't see it, the above looks sensible/necessary... > > Thanks for pointing it my way, I don't always see the mailing list > posts quickly. > > Looks good to me, I'll get it applied. Thanks Andrzej! > Andrzej, does this actually resolve the problem you observed? unsigned long nr in the parameter list of calc_clat_percentiles() and show_clat_percentiles() also looks like it will overflow when you have more than 2^32 IOs.