Re: [PATCH] linux/kernel.h: fix overflow for DIV_ROUND_UP_ULL

2019-06-25 Thread Vinod Koul
On 25-06-19, 15:32, Andrew Morton wrote: > On Tue, 25 Jun 2019 15:29:38 -0700 Andrew Morton > wrote: > > > On Tue, 25 Jun 2019 15:35:18 +0530 Vinod Koul wrote: > > > > > DIV_ROUND_UP_ULL adds the two arguments and then invokes > > > DIV_ROUND_DOWN_ULL. But on a 32bit system the addition of two

Re: [PATCH] linux/kernel.h: fix overflow for DIV_ROUND_UP_ULL

2019-06-25 Thread Andrew Morton
On Tue, 25 Jun 2019 15:29:38 -0700 Andrew Morton wrote: > On Tue, 25 Jun 2019 15:35:18 +0530 Vinod Koul wrote: > > > DIV_ROUND_UP_ULL adds the two arguments and then invokes > > DIV_ROUND_DOWN_ULL. But on a 32bit system the addition of two 32 bit > > values can overflow. DIV_ROUND_DOWN_ULL doe

Re: [PATCH] linux/kernel.h: fix overflow for DIV_ROUND_UP_ULL

2019-06-25 Thread Andrew Morton
On Tue, 25 Jun 2019 15:35:18 +0530 Vinod Koul wrote: > DIV_ROUND_UP_ULL adds the two arguments and then invokes > DIV_ROUND_DOWN_ULL. But on a 32bit system the addition of two 32 bit > values can overflow. DIV_ROUND_DOWN_ULL does it correctly and stashes > the addition into a unsigned long long s

[PATCH] linux/kernel.h: fix overflow for DIV_ROUND_UP_ULL

2019-06-25 Thread Vinod Koul
DIV_ROUND_UP_ULL adds the two arguments and then invokes DIV_ROUND_DOWN_ULL. But on a 32bit system the addition of two 32 bit values can overflow. DIV_ROUND_DOWN_ULL does it correctly and stashes the addition into a unsigned long long so cast the result to unsigned long long here to avoid the overf