[<prev] [next>] [day] [month] [year] [list]
Message-ID: <4C7F3A2E.7080307@cn.fujitsu.com>
Date: Thu, 02 Sep 2010 13:46:22 +0800
From: Miao Xie <miaox@...fujitsu.com>
To: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
"Theodore Ts'o" <tytso@....edu>,
Andreas Dilger <adilger.kernel@...ger.ca>,
Chris Mason <chris.mason@...cle.com>,
Yan Zheng <zheng.yan@...cle.com>
CC: Linux Kernel <linux-kernel@...r.kernel.org>,
Linux Btrfs <linux-btrfs@...r.kernel.org>,
Linux Ext4 <linux-ext4@...r.kernel.org>
Subject: [PATCH 2/3] lib: improve the performance of memcpy and memmove of
the general version
the performance of memcpy and memmove of the general version is
very inefficient, this patch improved them.
Signed-off-by: Miao Xie <miaox@...fujitsu.com>
---
lib/string.c | 32 ++++++++++++++------------------
1 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/lib/string.c b/lib/string.c
index f71bead..6cbf6d8 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -23,6 +23,7 @@
#include <linux/string.h>
#include <linux/ctype.h>
#include <linux/module.h>
+#include <linux/memcopy.h>
#ifndef __HAVE_ARCH_STRNICMP
/**
@@ -567,11 +568,12 @@ EXPORT_SYMBOL(memset);
*/
void *memcpy(void *dest, const void *src, size_t count)
{
- char *tmp = dest;
- const char *s = src;
+ unsigned long dstp = (unsigned long)dest;
+ unsigned long srcp = (unsigned long)src;
+
+ /* Copy from the beginning to the end */
+ mem_copy_fwd(dstp, srcp, count);
- while (count--)
- *tmp++ = *s++;
return dest;
}
EXPORT_SYMBOL(memcpy);
@@ -588,21 +590,15 @@ EXPORT_SYMBOL(memcpy);
*/
void *memmove(void *dest, const void *src, size_t count)
{
- char *tmp;
- const char *s;
-
- if (dest <= src) {
- tmp = dest;
- s = src;
- while (count--)
- *tmp++ = *s++;
+ unsigned long dstp = (unsigned long)dest;
+ unsigned long srcp = (unsigned long)src;
+
+ if (dest - src >= count) {
+ /* Copy from the beginning to the end */
+ mem_copy_fwd(dstp, srcp, count);
} else {
- tmp = dest;
- tmp += count;
- s = src;
- s += count;
- while (count--)
- *--tmp = *--s;
+ /* Copy from the end to the beginning */
+ mem_copy_bwd(dstp, srcp, count);
}
return dest;
}
--
1.7.0.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists