[Top] [All Lists]

Re: Prefetches in memcpy

To: "Gilad" <>, <>
Subject: Re: Prefetches in memcpy
From: "Kevin D. Kissell" <>
Date: Sun, 8 Dec 2002 11:01:43 +0100
Original-recipient: rfc822;
References: <>
> As someone rather new to this list, and to mips-linux in general,
> can someone explain the problem, as well as how one can avoid 
> it or limit it's effects to a minimum ?

The problem is that memcpy() uses prefetch to pre-load the
cache from the copy source, but does so very naively, such
that it continues prefetching beyond the end of the block to
be copied.  This is a Bad Idea for a couple of reasons.
The first to be commented upon was the fact that it can
result in bus hangs/bus errors if the kernel is trying to copy
from the last few hundred bytes of physical memory, but 
the really nasty one is that it screws up cache coherence
for DMA I/O.

The no-brainer solution which has been proposed as a
stopgap is simply to stop doing prefetch in memcpy()
altogether.  The "correct" solution would be to have a
slightly more complex memcpy() loop which only does
prefetch up to the end of the source block, which is
what is now done in the x86 port.

<Prev in Thread] Current Thread [Next in Thread>