Re: [PATCH 1/3] Make /dev/urandom scalable

From: Rasmus Villemoes
Date: Wed Sep 30 2015 - 10:40:33 EST


On Thu, Sep 24 2015, Andi Kleen <andi@xxxxxxxxxxxxxx> wrote:

>
> v2: Fix name of pool 0. Fix race with interrupts. Make
> iteration loops slightly more efficient. Add ifdefs to avoid
> any extra code on non-NUMA. Delay other pool use to when
> the original pool initialized and initialize the pools from
> pool 0. Add comments on memory allocation.

More bikeshedding. Please ignore unless you do a v3 anyway.

> static struct entropy_store nonblocking_pool = {
> .poolinfo = &poolinfo_table[1],
> - .name = "nonblocking",
> + .name = "nonblocking pool 0",

Hm, yeah, but then you should probably also update the blocking pool's
name (or use the format "nonblocking %d").

> +#define POOL_INIT_BYTES (128 / 8)
> +
> +void init_node_pools(void)
> +{
> +#ifdef CONFIG_NUMA
> + int i;
> + for (i = 0; i < num_possible_nodes(); i++) {

int num_nodes = num_possible_nodes();
for (i = 0; i < num_nodes; i++) {

> static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
> {
> + int i;
> int size, ent_count;
> int __user *p = (int __user *)arg;
> int retval;
> + struct entropy_store *pool;
>
> switch (cmd) {
> case RNDGETENTCNT:
> @@ -1569,6 +1696,10 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
> return -EPERM;
> input_pool.entropy_count = 0;
> nonblocking_pool.entropy_count = 0;
> + if (nonblocking_node_pool)
> + for_each_nb_pool (i, pool) {
> + pool->entropy_count = 0;
> + } end_for_each_nb();

extra ;. harmless in this case, but could cause slightly hard-to-understand build
failures if that if grows an else.

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