lkml.org 
[lkml]   [2015]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] null_blk: use sector_div instead of do_div
From
On Fri, Nov 27, 2015 at 5:49 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> - do_div(size, bs); /* convert size to pages */
> - do_div(size, 256); /* concert size to pgs pr blk */
> + sector_div(size, bs); /* convert size to pages */
> + sector_div(size, 256); /* concert size to pgs pr blk */

Ugh.

Dividing by 256 should never be done with do_div() *or* sector-div.

Same goes for this, which is just obnoxiously idiotic:

> - do_div(size, (1 << 16));
> + sector_div(size, (1 << 16));

WTF? It explicitly divides by a particular power-of-two?

Has nobody ever heard of expensive divide operations? Sure, for the
cases where we *don't* do this with inline asm etc because it's
already fairly cheap, the compiler will DTRT. But that "divide by (1
<< 16)" is just a sign of insanity.

Why is that not just

size >>= 16;

instead, which is certainly not any less legible, and won't generate
potentially crap code?

Linus


\
 
 \ /
  Last update: 2015-11-27 19:41    [W:0.088 / U:1.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site