[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFy=JjwmtNysByu822S2Av0sv_KUCLfa86tAz5K5Unwsmw@mail.gmail.com>
Date: Fri, 27 Nov 2015 10:07:54 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Arnd Bergmann <arnd@...db.de>
Cc: Jens Axboe <axboe@...com>, Matias Bjorling <m@...rling.me>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH] null_blk: use sector_div instead of do_div
On Fri, Nov 27, 2015 at 5:49 AM, Arnd Bergmann <arnd@...db.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists