public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: Chris Metcalf <cmetcalf@tilera.com>
To: Steve Ellcey <sellcey@mips.com>
Cc: <libc-ports@sourceware.org>
Subject: Re: [patch, mips, memmove] Remove memmove's use of memcpy on MIPS
Date: Fri, 25 Jan 2013 18:55:00 -0000	[thread overview]
Message-ID: <5102D50C.6030300@tilera.com> (raw)
In-Reply-To: <8eea9547-6de4-482b-833c-f552df9283d4@EXCHHUB01.MIPS.com>

On 1/25/2013 1:17 PM, Steve Ellcey wrote:
> While doing some other testing Maciej Rozycki found a bug in the MIPS
> memmove.  A few weeks ago (after the release of 2.17) I updated the MIPS
> memcpy.S to use the prepare-to-store prefetch instruction.  This makes
> memcpy (particularly long memcpy's) much faster.  The problem is that the
> prepare-to-store prefetch is not a 'real' prefetch, it doesn't read the
> memory into the cache but, if the data is not already in cache, it creates a
> cache line with all zeros and assumes that the user will write to the entire
> line.  If you try to read from that cache line or if you don't write to the
> entire cache line before it is flushed you will get bad results.

See ports/sysdeps/tile/tilegx/memcpy.c for how the tile architecture handles this issue.  The memcpy code advances until the destination pointer is cache-aligned, then loops cacheline at a time, first reading 64 bytes, then doing the prepare-to-store (aka "wh64"), then writing all 64 bytes.  This ensures that no matter what overlap the source has with the destination, we have captured any data that might be overwritten by the "wh64" instruction.  Since our memory architecture is non-blocking we can issue all eight reads without waiting for them to complete.

Would doing something like this for MIPS allow your memcpy to be safe for forward memmove?

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com

  reply	other threads:[~2013-01-25 18:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-25 18:17 Steve Ellcey 
2013-01-25 18:55 ` Chris Metcalf [this message]
2013-01-25 19:29   ` Steve Ellcey
2013-01-25 20:16 ` Joseph S. Myers
2013-01-25 21:29   ` Steve Ellcey
2013-01-25 23:15     ` Joseph S. Myers
2013-01-26  2:09     ` Maxim Kuvyrkov

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=5102D50C.6030300@tilera.com \
    --to=cmetcalf@tilera.com \
    --cc=libc-ports@sourceware.org \
    --cc=sellcey@mips.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).