lkml.org 
[lkml]   [2005]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
Date
From
SubjectRe: Patch 2/6 introduce helper infrastructure
On Thu, Jan 27, 2005 at 11:58:29AM +0000, Arjan van de Ven wrote:
> On Thu, Jan 27, 2005 at 11:41:33AM +0100, Andi Kleen wrote:
> > 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.
>
>
> actually the static was ther from a previous revision where the ip rng was
> compiled out at times so it needed some RNG characteristic. Patch below just
> removes the static; it's good enough.

I guess the per MM prng would be still faster, but it's probably
not worth tweaking unless it shows up as a problem.

> + if (end <= start + len)
> + return 0;
> + return PAGE_ALIGN(get_random_int() % range + start);

Division through variable is often quite slow, it would be good if you
avoided it somehow.

-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    [W:0.814 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site