All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] uboot optimize memmove
@ 2013-07-26  6:53 Andy Green
  2013-07-26 12:58 ` Wolfgang Denk
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Green @ 2013-07-26  6:53 UTC (permalink / raw)
  To: u-boot

While studying the reason why kernel copy from NOR was so slow on our platform,
I realized U-Boot is pulling it from 32-bit NOR in 8-bit chunks needlessly.

bootm uses memmove() and that just takes the approach by default to move u8s
around.

This optimization prefers memcpy() implementation (done mostly in 32-bit reads
and writes) if there's no overlap in source and dest, resulting in a huge
speedup on our platform (480ms copy from 32-bit NOR ---> 140ms)

Signed-off-by: Andy Green <andy.green@linaro.org>
---
 lib/string.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/string.c b/lib/string.c
index c3ad055..96d66e0 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -542,13 +542,21 @@ void * memmove(void * dest,const void *src,size_t count)
 	if (src == dest)
 		return dest;
 
-	if (dest <= src) {
+	if (dest < src) {
+
+		if ((unsigned long)dest + count <= (unsigned long)src)
+			return memcpy(dest, src, count);
+
 		tmp = (char *) dest;
 		s = (char *) src;
 		while (count--)
 			*tmp++ = *s++;
 		}
 	else {
+
+		if ((unsigned long)src + count <= (unsigned long)dest)
+			return memcpy(dest, src, count);
+
 		tmp = (char *) dest + count;
 		s = (char *) src + count;
 		while (count--)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-07-29 10:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-26  6:53 [U-Boot] [PATCH] uboot optimize memmove Andy Green
2013-07-26 12:58 ` Wolfgang Denk
2013-07-26 13:42   ` Andy Green
2013-07-26 19:06     ` Wolfgang Denk
2013-07-28 23:39       ` Andy Green
2013-07-29  8:03         ` Wolfgang Denk
2013-07-29  8:28     ` Dirk Behme
2013-07-29  8:44       ` Andy Green
2013-07-29 10:34         ` Will Newton

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.