lkml.org 
[lkml]   [2005]   [Jan]   [27]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Patch 2/6 introduce helper infrastructure
FromAndi Kleen <>
DateThu, 27 Jan 2005 11:41:33 +0100
Arjan van de Ven <arjan@infradead.org> writes:
> +unsigned int get_random_int(void)
> +{
> +	static unsigned int val = 0;
> +
> +	val += current->pid + jiffies;

Shouldn't there be some kind of locking for this? It's random,
but still random corruption sounds a bit too random.

Also you probably have a very hot cache line here, which
may hurt on the bigger machines.

I think it would be better to just get a global random number
for each mm as it is created and then run a fast PRNG with that
state. Maybe even make it per task to improve performance on
multithreaded programs. Or alternatively per cpu state with
different starting points.
-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:09    [from the cache]
©2003-2008