lkml.org 
[lkml]   [2018]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [mm 4.15-rc8] Random oopses under memory pressure.
Date
On 2018-01-19 19:42, Linus Torvalds wrote:
>
> I actually asked (long long ago) for an optinal compiler warning for
> "pointer subtraction with non-power-of-2 sizes". Not because of it
> being undefined, but simply because it's expensive. The
> divide->multiply thing doesn't always work,

Huh? If (compile-time constant, positive) d=m*2^k with m odd, and x is
known to be a multiple of d, x/d can always be computed as (x>>k)*m' ==
(x*m')>>k, with m' being the mod 2^N multiplicative inverse of m, right?
This works whether x has signed or unsigned type and whether it indeed
happens to be negative, AFAICT.

Sure, the multiplication by m' may not exactly be cheap, but one only
needs the low N bits of the result.

Rasmus

\
 
 \ /
  Last update: 2018-01-22 14:26    [W:0.115 / U:0.932 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site