From: "David S. Miller" <davem@davemloft.net>
To: sparclinux@vger.kernel.org
Subject: Re: [4/3] fix initrd memcpy
Date: Tue, 21 Dec 2004 06:28:38 +0000 [thread overview]
Message-ID: <20041220222838.2fb3639a.davem@davemloft.net> (raw)
In-Reply-To: <20041221045627.GC771@holomorphy.com>
On Mon, 20 Dec 2004 20:56:27 -0800
William Lee Irwin III <wli@holomorphy.com> wrote:
> The latter hunk of the forwarded patch has already been applied, so
> please apply the patch as it appears in the un-forwarded part. I've
> taken some liberties in adding the Acked/Signed-off lines in what I
> hope is an agreeable way.
For this one it may be advisable to kill this silly attempt
to optimize constant count memcpy()'s. GCC knows very well
when to do a __builtin_memcpy() expansion vs. a real memcpy
call.
All the memcpy --> __memcpy is doing is making it so that the
memcpy assembler doesn't need to retain and return the original
destination pointer argument.
Sparc64 was doing silly stuff like this too, and it simplified
things a lot to just kill all of these macroized optimizations.
I did that as follows:
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/07/27 12:55:12-07:00 davem@nuts.davemloft.net
# [SPARC64]: Kill all this silly inline memcpy handling.
#
# GCC does this well enough.
#
# Signed-off-by: David S. Miller <davem@redhat.com>
#
# include/asm-sparc64/string.h
# 2004/07/27 12:54:49-07:00 davem@nuts.davemloft.net +1 -25
# [SPARC64]: Kill all this silly inline memcpy handling.
#
# GCC does this well enough.
#
# Signed-off-by: David S. Miller <davem@redhat.com>
#
# include/asm-sparc64/page.h
# 2004/07/27 12:54:49-07:00 davem@nuts.davemloft.net +1 -1
# [SPARC64]: Kill all this silly inline memcpy handling.
#
# GCC does this well enough.
#
# Signed-off-by: David S. Miller <davem@redhat.com>
#
# arch/sparc64/lib/VIScopy.S
# 2004/07/27 12:54:49-07:00 davem@nuts.davemloft.net +0 -4
# [SPARC64]: Kill all this silly inline memcpy handling.
#
# GCC does this well enough.
#
# Signed-off-by: David S. Miller <davem@redhat.com>
#
# arch/sparc64/kernel/sparc64_ksyms.c
# 2004/07/27 12:54:49-07:00 davem@nuts.davemloft.net +0 -1
# [SPARC64]: Kill all this silly inline memcpy handling.
#
# GCC does this well enough.
#
# Signed-off-by: David S. Miller <davem@redhat.com>
#
diff -Nru a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c
--- a/arch/sparc64/kernel/sparc64_ksyms.c 2004-12-20 22:06:27 -08:00
+++ b/arch/sparc64/kernel/sparc64_ksyms.c 2004-12-20 22:06:27 -08:00
@@ -334,7 +334,6 @@
#endif
/* Special internal versions of library functions. */
-EXPORT_SYMBOL(__memcpy);
EXPORT_SYMBOL(__memset);
EXPORT_SYMBOL(_clear_page);
EXPORT_SYMBOL(clear_user_page);
diff -Nru a/arch/sparc64/lib/VIScopy.S b/arch/sparc64/lib/VIScopy.S
--- a/arch/sparc64/lib/VIScopy.S 2004-12-20 22:06:27 -08:00
+++ b/arch/sparc64/lib/VIScopy.S 2004-12-20 22:06:27 -08:00
@@ -306,11 +306,7 @@
.globl __memcpy_begin
__memcpy_begin:
- .globl __memcpy
- .type __memcpy,@function
-
memcpy_private:
-__memcpy:
memcpy: mov ASI_P, asi_src ! IEU0 Group
brnz,pt %o2, __memcpy_entry ! CTI
mov ASI_P, asi_dest ! IEU1
diff -Nru a/include/asm-sparc64/page.h b/include/asm-sparc64/page.h
--- a/include/asm-sparc64/page.h 2004-12-20 22:06:27 -08:00
+++ b/include/asm-sparc64/page.h 2004-12-20 22:06:27 -08:00
@@ -18,7 +18,7 @@
#define clear_page(X) _clear_page((void *)(X))
struct page;
extern void clear_user_page(void *addr, unsigned long vaddr, struct page *page);
-#define copy_page(X,Y) __memcpy((void *)(X), (void *)(Y), PAGE_SIZE)
+#define copy_page(X,Y) memcpy((void *)(X), (void *)(Y), PAGE_SIZE)
extern void copy_user_page(void *to, void *from, unsigned long vaddr, struct page *topage);
/* GROSS, defining this makes gcc pass these types as aggregates,
diff -Nru a/include/asm-sparc64/string.h b/include/asm-sparc64/string.h
--- a/include/asm-sparc64/string.h 2004-12-20 22:06:27 -08:00
+++ b/include/asm-sparc64/string.h 2004-12-20 22:06:27 -08:00
@@ -16,9 +16,7 @@
#include <asm/asi.h>
extern void __memmove(void *,const void *,__kernel_size_t);
-extern __kernel_size_t __memcpy(void *,const void *,__kernel_size_t);
extern void *__memset(void *,int,__kernel_size_t);
-extern void *__builtin_memcpy(void *,const void *,__kernel_size_t);
extern void *__builtin_memset(void *,int,__kernel_size_t);
#ifndef EXPORT_SYMTAB_STROPS
@@ -37,29 +35,7 @@
#define __HAVE_ARCH_MEMCPY
-static inline void *__constant_memcpy(void *to, const void *from, __kernel_size_t n)
-{
- if(n) {
- if(n <= 32) {
- __builtin_memcpy(to, from, n);
- } else {
- __memcpy(to, from, n);
- }
- }
- return to;
-}
-
-static inline void *__nonconstant_memcpy(void *to, const void *from, __kernel_size_t n)
-{
- __memcpy(to, from, n);
- return to;
-}
-
-#undef memcpy
-#define memcpy(t, f, n) \
-(__builtin_constant_p(n) ? \
- __constant_memcpy((t),(f),(n)) : \
- __nonconstant_memcpy((t),(f),(n)))
+extern void * memcpy(void *,const void *,__kernel_size_t);
#define __HAVE_ARCH_MEMSET
next prev parent reply other threads:[~2004-12-21 6:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-21 4:56 [4/3] fix initrd memcpy William Lee Irwin III
2004-12-21 6:28 ` David S. Miller [this message]
2004-12-21 6:39 ` William Lee Irwin III
2004-12-21 7:00 ` William Lee Irwin III
2004-12-21 7:58 ` David S. Miller
2004-12-21 8:28 ` William Lee Irwin III
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=20041220222838.2fb3639a.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=sparclinux@vger.kernel.org \
/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.