From: Robert Hancock <hancockr@shaw.ca>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: "linux-os (Dick Johnson)" <linux-os@analogic.com>
Subject: Re: memcpy_toio on i386 using byte writes even when n%2==0
Date: Tue, 30 May 2006 18:55:55 -0600 [thread overview]
Message-ID: <447CE99B.7070707@shaw.ca> (raw)
In-Reply-To: <6idov-5Tc-7@gated-at.bofh.it>
linux-os (Dick Johnson) wrote:
> If byte writes are used, they should always be last for any
> odd byte. I think you found a bug in spite of the fact that
> whoever made the revision to memcpy probably thinks they
> did something 'cool'. This is an example of cute code causing
> problems. The classic example of a proper memcpy() that uses
> the ix86 built-in macros runs like this:
>
> pushl %esi # Save precious registers
> pushl %edi
> movl COUNT(%esp),%ecx
> movl SOURCE(%esp),%esi
> movl DEST(%esp),%edi
> cld
> shrl $1,%ecx # Make WORDS, possibly set carry
> rep movsw # Copy the words
> adcl %ecx,%ecx # Any spare byte
> rep movsb # Copy any spare byte
> popl %edi # Restore precious registers
> popl %esi
>
> Note that there isn't any code for moving dwords because the
> chances of gaining anything are slim (alignment may hurt).
I'd say the chances of gaining something from executing half as many
instructions on copying a large block of memory are very good indeed..
--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/
next parent reply other threads:[~2006-05-31 0:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <6gUec-3mb-7@gated-at.bofh.it>
[not found] ` <6gUec-3mb-5@gated-at.bofh.it>
[not found] ` <6icVy-56r-9@gated-at.bofh.it>
[not found] ` <6idov-5Tc-7@gated-at.bofh.it>
2006-05-31 0:55 ` Robert Hancock [this message]
2006-05-31 1:13 ` memcpy_toio on i386 using byte writes even when n%2==0 H. Peter Anvin
[not found] <6ined-4gY-17@gated-at.bofh.it>
[not found] ` <6ined-4gY-21@gated-at.bofh.it>
[not found] ` <6inee-4gY-23@gated-at.bofh.it>
[not found] ` <6ined-4gY-15@gated-at.bofh.it>
[not found] ` <6inxv-4U2-17@gated-at.bofh.it>
2006-06-03 23:52 ` Robert Hancock
2006-06-04 0:48 ` H. Peter Anvin
[not found] <6gMqr-8uW-23@gated-at.bofh.it>
2006-05-26 23:46 ` Robert Hancock
2006-05-29 7:38 ` H. Peter Anvin
2006-05-30 13:55 ` Chris Lesiak
2006-05-30 14:24 ` linux-os (Dick Johnson)
2006-05-26 15:29 Chris Lesiak
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=447CE99B.7070707@shaw.ca \
--to=hancockr@shaw.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-os@analogic.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.