All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Daney <ddaney@caviumnetworks.com>
To: Michael Sundius <msundius@cisco.com>
Cc: linux-mips@linux-mips.org, "VomLehn, David" <dvomlehn@cisco.com>,
	msundius@sundius.com
Subject: Re: memcpy and prefetch
Date: Wed, 28 Jan 2009 11:54:03 -0800	[thread overview]
Message-ID: <4980B7DB.3090304@caviumnetworks.com> (raw)
In-Reply-To: <4980B1CA.4060505@cisco.com>

Michael Sundius wrote:
> David Daney wrote:
[...]
>> The Cavium OCTEON port overrides the default memcpy and does use 
>> prefetch.  It was recently merged (2.6.29-rc2).  Look at octeon-memcpy.S
[...]
> 
> thanks!!! that's really useful. I have a few questions tho:
> 
> 1) So you made this function explicitly for the Octeon.

I didn't personally write the code. But yes, as its name implies, it was 
created specifically for OCTEON.

> and that is 
> because you know the cache-line is 128 bytes long
> on the octeon? is that right?

That and we know exactly how prefetching works on this CPU *and* we know 
we can do unaligned accesses quickly.

> 
> 2) It seems as though you always prefectch the first cache line..  what 
> happens if the memcopy is less than 1 cache line long?
> wouldn't you risk prefetching beyond the end of the buffer?

It is a risk we were willing to take.  Cache lines are loaded with 
unneeded data all the time.

> 
> 3) why do you only do the "pref   0 offset(src)" and not a prefetch for 
> the destination?

I don't know.  But the interaction between the writeback buffers, the 
cache and RAM are somewhat complicated.  It may not be enough of a win 
to overcome the cost of the code that would determine when to do it.

> 
> 4) on line 244 you check to see if len is less than 128. while on the 
> other checks you check for (offset)+1
> why would you not do the prefetch if len was exactly 256 bytes? (or 128 
> in the case of line 196)?

We are always prefetching 256 bytes ahead of the current position.  If 
we prefetch beyound the end of the buffer it is truly wasting memory 
bandwidth, also if we prefetch to memory addresses where there is no 
physical memory, bad things happen.

David Daney

  reply	other threads:[~2009-01-28 19:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-27 23:00 memcpy and prefetch Michael Sundius
2009-01-27 23:07 ` David Daney
2009-01-28 10:37   ` Ralf Baechle
2009-01-28 15:28     ` Atsushi Nemoto
2009-01-28 18:30       ` Ralf Baechle
2009-01-29 12:36         ` Atsushi Nemoto
2009-01-29 15:58           ` Ralf Baechle
2009-01-30  3:39             ` David VomLehn (dvomlehn)
2009-01-30  3:39               ` David VomLehn (dvomlehn)
2009-02-04 21:27               ` Ralf Baechle
2009-02-05 15:31                 ` Atsushi Nemoto
2009-01-28 19:28   ` Michael Sundius
2009-01-28 19:54     ` David Daney [this message]
2009-01-28 21:52       ` Chad Reese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4980B7DB.3090304@caviumnetworks.com \
    --to=ddaney@caviumnetworks.com \
    --cc=dvomlehn@cisco.com \
    --cc=linux-mips@linux-mips.org \
    --cc=msundius@cisco.com \
    --cc=msundius@sundius.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.