Skip to content

random: bytes vs. bits

Greg Price lkml 1 version Applied

Status from this message: Thanks, applied.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2random: entropy_bytes is actually bitsdrivers/char/random.c+3 -31 reply
2/2random: clarify bits/bytes in wakeup thresholdsdrivers/char/random.c+17 -171 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [3.13 PATCH 0/2] random: bytes vs. bits

The new when-to-push logic in v3.13-rc1~61^2~6 "random: push extra entropy to the output pools" uses the name "entropy_bytes" for a quantity that's actually in bits. This results in confusing, buggy-looking lines both where the variable is set and where it's used. Fortunately it's all consistent if the variable is understood as counting bits, so the behavior is fine.

This code is new in v3.13-rc1, so fixing the name seems in order for 3.13. The first patch here just does that.

One cause of the mistake is probably that the names of random_read_wakeup_thresh and random_write_wakeup_thresh don't indicate what units they're in. This is an especially acute issue now that we have three units for entropy in different places -- bytes, bits, and 1 / (1 << ENTROPY_SHIFT) fractions of a bit. The second patch clarifies the units in both names. (Maybe other names should be clarified too.) This may as well be post-3.13.

Cheers,
Greg

Greg Price (2):
random: entropy_bytes is actually bits
random: clarify bits/bytes in wakeup thresholds

 drivers/char/random.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
Signature · 1 line
1.8.3.2