Re: linux/drivers/block/nbd.c

Jukka Tapani Santala (e75644@UWasa.Fi)
Thu, 11 Mar 1999 07:52:14 +0200 (EET)


On Wed, 10 Mar 1999 Andries.Brouwer@cwi.nl wrote:
> Glancing through 2.2.3 I get the impression that the 2.2.3 patch
> case BLKGETSIZE:
> - return put_user(nbd_bytesizes[dev]/512, (long *) arg);
> + return put_user(nbd_bytesizes[dev] << 9, (long *) arg);
> writes << where >> was meant.
> This is in linux/drivers/block/nbd.c.

Not to mention it's completely unneccessary, on any platform where it's
actually useful, the compiler can replace the division with shift. I'm
told that on architectures like Alpha the clean division is faster,
anyway.

In my FAT-optimization patch (At least last time I posted that patch it
caused some confusion;) I moved to shift instead of division for the
specific reasons that FAT is an uncommon thing to encounter on Alpha last
I heard, and since the divisor in question was loaded from disk, there was
no way the optimizer could know it was goign to be a power of two, whereas
we indepently know it from MS-DOS reference books.

There's no reason to "optimize" _constant_ divisions/multiplications by
hand except perhaps for aesthetic reasons, and last time this came up, the
consensus was people felt more comfortable seeing the divisions and
multiplications than shifts, for the specific reason this slip-up
demonstrates.

Ofcourse, if it was not a slip-up but the intention actually was to change
the division into multiplication, then you can ignore most of the above,
except that if multiplication had been used instead, we'd have avoided
this confusion ;)

-Donwulff

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/