Question about Linus' QOTW
Posted Aug 25, 2011 17:50 UTC (Thu) by
blitzkrieg3 (subscriber, #57873)
In reply to:
Question about Linus' QOTW by pr1268
Parent article:
Quotes of the week
It is only as easy as a single bit shift on 64 bit architecture. Here's what I gather. The patch doesn't compile on 32-bit, because of
min_free /= 2;
Since min_free is a 64 bit unsigned integer, this is a simple bit shift for 64 bit architectures (your compile will optimize it for you) but is impossible for 32 bit architectures and generates a compiler error.
So to fix that, they use do_div, which is an expensive macro that allows 32-bit machines to do 64-bit division. But all you really need to do on 32-bit machines is two bit shifts instead of one: Bit shift the high register, than the low register.
Instead, on 64 bit, the do_div fix changes a single simple instruction operation to the more expensive divl operation. On 32 bit, the fix changes what should be two simple instruction operations to the expensive multiple instruction do_div macro.
(
Log in to post comments)