Re: Fw: potential /dev/urandom scalability improvement

From: Andi Kleen
Date: Sat Mar 27 2004 - 01:14:02 EST

Andrew Morton <akpm@xxxxxxxx> writes:
> I think this gets it right, but I probably screwed something up.
> static inline void prefetch_range(void *addr, size_t len)
> {
> char *cp;
> unsigned long end;
> end = ((unsigned long)addr + len + PREFETCH_STRIDE - 1);
> end &= ~(PREFETCH_STRIDE - 1);
> for (cp = addr; cp < (char *)end; cp += PREFETCH_STRIDE)
> prefetch(cp);
> #endif
> }

The memory/bus controller usually only has a limited queue of
outstanding transactions and for a big buffer you will likely overflow
it. Also usually on modern CPUs it is enough to do prefetch for 2-3
cache lines at the beginning, then an automatic hardware prefetcher
will kick in and take care of the rest.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at