* [4/3] fix initrd memcpy
@ 2004-12-21 4:56 William Lee Irwin III
2004-12-21 6:28 ` David S. Miller
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: William Lee Irwin III @ 2004-12-21 4:56 UTC (permalink / raw)
To: sparclinux
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.
On Sun, Nov 14, 2004 at 11:16:40PM -0500, Jurij Smakov wrote:
> As a followup: I have tried fiddling more with the memcpy() routine.
> Insight from Rob Radez and comments in arch/sparc/lib/blockops.S suggest,
> that __copy_1page assumes that the memory regions copied are aligned on a
> double-word boundary. I have checked, that in the cramfs case it wasn't
> true, the destination was not aligned on the double-word boundary. So, I
> have implemented a simple workaround (see patch below), which together
> with Bob Breuer's iommu.c fix [0] made 2.6.8 kernel to boot on my
> machine (SS10 with Ross Hypersparc CPU)! I also confirm, that adding the
> suggested fix to the srmmu.c also [1] breaks sunlance on my machine. With
> that "fix" the line 'eth0: Memory error, status 88c3, addr 3713ba' is
> displayed continuously during boot, when it comes to configuring network
> interfaces. The successful patch for me is:
Acked-by: William Irwin <wli@holomorphy.com>
Acked-by: Dave Miller <davem@davemloft.net>
Signed-off-by: Jurij Smakov <jurij@wooyd.org>
Index: sparc32-2.6.10-rc3/include/asm-sparc/string.h
=================================--- sparc32-2.6.10-rc3.orig/include/asm-sparc/string.h 2004-06-15 22:18:38.000000000 -0700
+++ sparc32-2.6.10-rc3/include/asm-sparc/string.h 2004-12-20 20:53:00.585527010 -0800
@@ -40,6 +40,9 @@
if(n <= 32) {
__builtin_memcpy(to, from, n);
+ } else if (((unsigned int) to & 7) != 0) {
+ /* Destination is not aligned on the double-word boundary */
+ __memcpy(to, from, n);
} else {
switch(n) {
case PAGE_SIZE:
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [4/3] fix initrd memcpy
2004-12-21 4:56 [4/3] fix initrd memcpy William Lee Irwin III
@ 2004-12-21 6:28 ` David S. Miller
2004-12-21 6:39 ` William Lee Irwin III
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: David S. Miller @ 2004-12-21 6:28 UTC (permalink / raw)
To: sparclinux
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [4/3] fix initrd memcpy
2004-12-21 4:56 [4/3] fix initrd memcpy William Lee Irwin III
2004-12-21 6:28 ` David S. Miller
@ 2004-12-21 6:39 ` William Lee Irwin III
2004-12-21 7:00 ` William Lee Irwin III
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: William Lee Irwin III @ 2004-12-21 6:39 UTC (permalink / raw)
To: sparclinux
On Mon, 20 Dec 2004 20:56:27 -0800 William Lee Irwin III 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.
>
On Mon, Dec 20, 2004 at 10:28:38PM -0800, David S. Miller wrote:
> 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 looks tremendously cleaner. I'll look for an ack to see if there
are actively participating users lingering about with toolchains that
do something unintelligible out of paranoia and then send an analogue
of this upstream.
-- wli
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [4/3] fix initrd memcpy
2004-12-21 4:56 [4/3] fix initrd memcpy William Lee Irwin III
2004-12-21 6:28 ` David S. Miller
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
4 siblings, 0 replies; 6+ messages in thread
From: William Lee Irwin III @ 2004-12-21 7:00 UTC (permalink / raw)
To: sparclinux
On Mon, Dec 20, 2004 at 10:39:01PM -0800, William Lee Irwin III wrote:
> This looks tremendously cleaner. I'll look for an ack to see if there
> are actively participating users lingering about with toolchains that
> do something unintelligible out of paranoia and then send an analogue
> of this upstream.
tentative sparc32 analogue (not booted it yet):
Acked-by: William Irwin <wli@holomorphy.com>
Signed-off-by: Dave Miller <davem@davemloft.net>
Signed-off-by: Jurij Smakov <jurij@wooyd.org>
Index: sparc32-2.6.10-rc3/include/asm-sparc/string.h
=================================--- sparc32-2.6.10-rc3.orig/include/asm-sparc/string.h 2004-06-15 22:18:38.000000000 -0700
+++ sparc32-2.6.10-rc3/include/asm-sparc/string.h 2004-12-20 22:50:52.891373098 -0800
@@ -16,7 +16,7 @@
#ifdef __KERNEL__
extern void __memmove(void *,const void *,__kernel_size_t);
-extern __kernel_size_t __memcpy(void *,const void *,__kernel_size_t);
+void *memcpy(void *,const void *,__kernel_size_t);
extern __kernel_size_t __memset(void *,int,__kernel_size_t);
#ifndef EXPORT_SYMTAB_STROPS
@@ -33,38 +33,6 @@
})
#define __HAVE_ARCH_MEMCPY
-
-static inline void *__constant_memcpy(void *to, const void *from, __kernel_size_t n)
-{
- extern void __copy_1page(void *, const void *);
-
- if(n <= 32) {
- __builtin_memcpy(to, from, n);
- } else {
- switch(n) {
- case PAGE_SIZE:
- __copy_1page(to, from);
- break;
- default:
- __memcpy(to, from, n);
- break;
- }
- }
- 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)))
-
#define __HAVE_ARCH_MEMSET
static inline void *__constant_c_and_count_memset(void *s, char c, __kernel_size_t count)
Index: sparc32-2.6.10-rc3/arch/sparc/lib/checksum.S
=================================--- sparc32-2.6.10-rc3.orig/arch/sparc/lib/checksum.S 2004-06-15 22:19:36.000000000 -0700
+++ sparc32-2.6.10-rc3/arch/sparc/lib/checksum.S 2004-12-20 22:40:19.814615394 -0800
@@ -560,7 +560,7 @@
mov %i0, %o1
mov %i1, %o0
5:
- call __memcpy
+ call memcpy
mov %i2, %o2
tst %o0
bne,a 2f
Index: sparc32-2.6.10-rc3/arch/sparc/kernel/sparc_ksyms.c
=================================--- sparc32-2.6.10-rc3.orig/arch/sparc/kernel/sparc_ksyms.c 2004-11-17 02:25:41.000000000 -0800
+++ sparc32-2.6.10-rc3/arch/sparc/kernel/sparc_ksyms.c 2004-12-20 22:44:37.788397418 -0800
@@ -280,7 +280,6 @@
/* Special internal versions of library functions. */
EXPORT_SYMBOL(__copy_1page);
-EXPORT_SYMBOL(__memcpy);
EXPORT_SYMBOL(__memset);
EXPORT_SYMBOL(bzero_1page);
EXPORT_SYMBOL(__bzero);
Index: sparc32-2.6.10-rc3/arch/sparc/lib/memcpy.S
=================================--- sparc32-2.6.10-rc3.orig/arch/sparc/lib/memcpy.S 2004-10-07 04:01:27.000000000 -0700
+++ sparc32-2.6.10-rc3/arch/sparc/lib/memcpy.S 2004-12-20 22:40:46.813510938 -0800
@@ -550,9 +550,6 @@
b 3f
add %o0, 2, %o0
-#ifdef __KERNEL__
-FUNC(__memcpy)
-#endif
FUNC(memcpy) /* %o0=dst %o1=src %o2=len */
sub %o0, %o1, %o4
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [4/3] fix initrd memcpy
2004-12-21 4:56 [4/3] fix initrd memcpy William Lee Irwin III
` (2 preceding siblings ...)
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
4 siblings, 0 replies; 6+ messages in thread
From: David S. Miller @ 2004-12-21 7:58 UTC (permalink / raw)
To: sparclinux
On Mon, 20 Dec 2004 23:00:25 -0800
William Lee Irwin III <wli@holomorphy.com> wrote:
> On Mon, Dec 20, 2004 at 10:39:01PM -0800, William Lee Irwin III wrote:
> > This looks tremendously cleaner. I'll look for an ack to see if there
> > are actively participating users lingering about with toolchains that
> > do something unintelligible out of paranoia and then send an analogue
> > of this upstream.
>
> tentative sparc32 analogue (not booted it yet):
Won't work, you have to fixup the memcpy.S code to return
the original destination pointer.
And you can't use the SETUP_RETL et al. stuff already there
since %g6 is used for the current thread pointer.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [4/3] fix initrd memcpy
2004-12-21 4:56 [4/3] fix initrd memcpy William Lee Irwin III
` (3 preceding siblings ...)
2004-12-21 7:58 ` David S. Miller
@ 2004-12-21 8:28 ` William Lee Irwin III
4 siblings, 0 replies; 6+ messages in thread
From: William Lee Irwin III @ 2004-12-21 8:28 UTC (permalink / raw)
To: sparclinux
On Mon, 20 Dec 2004 23:00:25 -0800 William Lee Irwin III wrote:
>> tentative sparc32 analogue (not booted it yet):
On Mon, Dec 20, 2004 at 11:58:12PM -0800, David S. Miller wrote:
> Won't work, you have to fixup the memcpy.S code to return
>
> And you can't use the SETUP_RETL et al. stuff already there
> since %g6 is used for the current thread pointer.
Amazingly, the kernel runs anyway, but I'll do that.
-- wli
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-12-21 8:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-21 4:56 [4/3] fix initrd memcpy William Lee Irwin III
2004-12-21 6:28 ` David S. Miller
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
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.