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

From: Andi Kleen
Date: Wed Sep 23 2015 - 17:54:53 EST


> > +{
> > + struct entropy_store *pool = &nonblocking_pool;
> > +
> > + /*
> > + * Non node 0 pools may take longer to initialize. Keep using
> > + * the boot nonblocking pool while this happens.
> > + */
> > + if (nonblocking_node_pool)
> > + pool = nonblocking_node_pool[numa_node_id()];
> > + if (!pool->initialized)
> > + pool = &nonblocking_pool;
> > + return pool;
> > +}
>
> I assume this can't get called concurrently with rand_initialize
> (otherwise pool may be NULL even if nonblocking_node_pool is non-NULL).

Yes. I can move the assignment to the global last and add a memory
barrier.

> > + char name[40];
> > +
> > + nonblocking_node_pool = kzalloc(num_nodes * sizeof(void *),
> > + GFP_KERNEL|__GFP_NOFAIL);
> > +
>
> Why kzalloc, when you immediately initialize all elements? New uses of
> __GFP_NOFAIL seem to be frowned upon. How hard would it be to just fall
> back to only using the single statically allocated pool?

It's already doing that.

>
> Does rand_initialize get called before or after other initialization
> code updates node_possible_map to reflect the actual possible number of
> nodes? If before, won't we be wasting a lot of memory (not to mention
> that we then might as well allocate all the nonblocking pools statically
> based on MAX_NUMNODES).

I'll check.

-Andi
--
ak@xxxxxxxxxxxxxxx -- Speaking for myself only.
--
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/