[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CA+55aFyytOcFQ0Y3GOzGo7ozchM1kGfJgoAHgHpETLP9qKwPAw@mail.gmail.com>
Date: Mon, 22 Jan 2018 11:58:09 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Rasmus Villemoes <rasmus.villemoes@...vas.dk>
Cc: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Matthew Wilcox <willy@...radead.org>,
Al Viro <viro@...iv.linux.org.uk>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [mm 4.15-rc8] Random oopses under memory pressure.
On Mon, Jan 22, 2018 at 5:26 AM, Rasmus Villemoes
<rasmus.villemoes@...vas.dk> wrote:
> 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?
Hmm. I have definitely seen gcc generate the difference with a divide.
But it may be less of a "can't do it with a multiply" and more of a
"not all versions of gcc have the multiplication optimization".
Linus
Powered by blists - more mailing lists