Messages in this thread | | | Subject | Re: Patch 2/6 introduce helper infrastructure | From | Andi Kleen <> | Date | Thu, 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/
| |