Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755183AbbK0SH4 (ORCPT ); Fri, 27 Nov 2015 13:07:56 -0500 Received: from mail-ig0-f174.google.com ([209.85.213.174]:32811 "EHLO mail-ig0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754853AbbK0SHz (ORCPT ); Fri, 27 Nov 2015 13:07:55 -0500 MIME-Version: 1.0 In-Reply-To: <3768541.ja0r6f0Odi@wuerfel> References: <3768541.ja0r6f0Odi@wuerfel> Date: Fri, 27 Nov 2015 10:07:54 -0800 X-Google-Sender-Auth: 5RmkNsc73OssQopDcZiPCHUp4CE Message-ID: Subject: Re: [PATCH] null_blk: use sector_div instead of do_div From: Linus Torvalds To: Arnd Bergmann Cc: Jens Axboe , Matias Bjorling , Linux Kernel Mailing List , "linux-arm-kernel@lists.infradead.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1219 Lines: 35 On Fri, Nov 27, 2015 at 5:49 AM, Arnd Bergmann 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/