Skip to contentSkip to conversation

Thought about credit_entropy_bits() math

DISCUSSION George Spelvin 1 participant 1 message Oct 21, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

(Resend because I can't spell "kernel.org".)

Quoted 3 lines · H. Peter Anvin

The main advantage with this approximation is that it doesn't need a multiplication instruction. Instead, it can be implemented with two shifts and a subtract on hardware for which multiplication is slow.

Er... I'm as addicted to micro-optimization as anyone, which is why I posted all those various approximations, but I'm taking about going from one to two, not zero to one.

The current approximaion is used right in the middle of a non-constant multiply:

	unsigned int add = ((pool_size - entropy_count)*anfrac*3) >> s;

(Does Linux even run on any hardware without a multiply instruction? There are tons of multiplies all over the scheduler. The worst cases I can think of just have slow bitwise multiplies: the nommu 68000 and SPARCv7's multiply step.)