Re: [PATCH 1/7] random: cleanup poolinfo abstraction

From: Dominik Brodowski
Date: Sun Jan 16 2022 - 08:45:28 EST


Am Thu, Jan 13, 2022 at 04:44:07PM +0100 schrieb Jason A. Donenfeld:
> Now that we're only using one polynomial, we can cleanup its
> representation into constants, instead of passing around pointers
> dynamically to select different polynomials. This improves the codegen
> and makes the code a bit more straightforward.
>
> Signed-off-by: Jason A. Donenfeld <Jason@xxxxxxxxx>

> -} poolinfo_table[] = {
> - /* was: x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 */
> +enum poolinfo {
> + POOL_WORDS = 128,
> + POOL_WORDMASK = POOL_WORDS - 1,
> + POOL_BYTES = POOL_WORDS * sizeof(u32),
> + POOL_BITS = POOL_BYTES * 8,
> + POOL_BITSHIFT = ilog2(POOL_WORDS) + 5,
> + POOL_FRACBITS = POOL_WORDS << (ENTROPY_SHIFT + 5),
> +
> /* x^128 + x^104 + x^76 + x^51 +x^25 + x + 1 */
> - { S(128), 104, 76, 51, 25, 1 },
> + POOL_TAP1 = 104,
> + POOL_TAP2 = 76,

The only information lost seems to be that POOL_TAP1 used to be 103. But
that comment is still available in git history, so feel free to add:

Reviewed-by: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>

Thanks,
Dominik