Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* axp clear_page typo
@ 1998-07-20  7:07 Richard Henderson
  0 siblings, 0 replies; only message in thread
From: Richard Henderson @ 1998-07-20  7:07 UTC (permalink / raw)
  To: torvalds, axp-list

I've no idea how long this has been there -- probably since you
wrote the thing in the first place.  But I've just spent nigh on
to 5 days tracking down a bit of random corruption that I'd
believed to be caused by a broken compiler.


--- include/asm-alpha/page.h.orig	Mon Oct 14 01:51:59 1996
+++ include/asm-alpha/page.h	Sun Jul 19 22:48:16 1998
@@ -32,7 +32,7 @@ static inline void clear_page(unsigned l
 		"stq $31,40(%1)\n\t"
 		"stq $31,48(%1)\n\t"
 		"stq $31,56(%1)\n\t"
-		"addq $1,64,$1\n\t"
+		"addq %1,64,%1\n\t"
 		"bne %0,1b"
 		:"=r" (count),"=r" (page)
 		:"0" (PAGE_SIZE/64), "1" (page));


We should seriously consider getting rid of these two asm blocks 
altogether.  Yes, all released versions of gcc will do stupid
things with that simple loop, but I've been hacking the shit
out of loop.c for a few months, and my patches don't do stupid
things with this. 

And it's not like older versions produce incorrect code...


r~



--- include/asm-alpha/page.h.orig	Mon Oct 14 01:51:59 1996
+++ include/asm-alpha/page.h	Sun Jul 19 22:54:22 1998
@@ -19,54 +19,51 @@
  */
 static inline void clear_page(unsigned long page)
 {
-	unsigned long count;
-	__asm__ __volatile__(
-		".align 4\n"
-		"1:\n\t"
-		"stq $31,0(%1)\n\t"
-		"stq $31,8(%1)\n\t"
-		"stq $31,16(%1)\n\t"
-		"stq $31,24(%1)\n\t"
-		"subq %0,1,%0\n\t"
-		"stq $31,32(%1)\n\t"
-		"stq $31,40(%1)\n\t"
-		"stq $31,48(%1)\n\t"
-		"stq $31,56(%1)\n\t"
-		"addq $1,64,$1\n\t"
-		"bne %0,1b"
-		:"=r" (count),"=r" (page)
-		:"0" (PAGE_SIZE/64), "1" (page));
+	unsigned long count = PAGE_SIZE/64;
+	unsigned long *ptr = (unsigned long *)page;
+
+	do {
+		ptr[0] = 0;
+		ptr[1] = 0;
+		ptr[2] = 0;
+		ptr[3] = 0;
+		count--;
+		ptr[4] = 0;
+		ptr[5] = 0;
+		ptr[6] = 0;
+		ptr[7] = 0;
+		ptr += 8;
+	} while (count);
 }
 
-static inline void copy_page(unsigned long to, unsigned long from)
+static inline void copy_page(unsigned long _to, unsigned long _from)
 {
-	unsigned long count;
-	__asm__ __volatile__(
-		".align 4\n"
-		"1:\n\t"
-		"ldq $0,0(%1)\n\t"
-		"ldq $1,8(%1)\n\t"
-		"ldq $2,16(%1)\n\t"
-		"ldq $3,24(%1)\n\t"
-		"ldq $4,32(%1)\n\t"
-		"ldq $5,40(%1)\n\t"
-		"ldq $6,48(%1)\n\t"
-		"ldq $7,56(%1)\n\t"
-		"subq %0,1,%0\n\t"
-		"addq %1,64,%1\n\t"
-		"stq $0,0(%2)\n\t"
-		"stq $1,8(%2)\n\t"
-		"stq $2,16(%2)\n\t"
-		"stq $3,24(%2)\n\t"
-		"stq $4,32(%2)\n\t"
-		"stq $5,40(%2)\n\t"
-		"stq $6,48(%2)\n\t"
-		"stq $7,56(%2)\n\t"
-		"addq %2,64,%2\n\t"
-		"bne %0,1b"
-		:"=r" (count), "=r" (from), "=r" (to)
-		:"0" (PAGE_SIZE/64), "1" (from), "2" (to)
-		:"$0","$1","$2","$3","$4","$5","$6","$7");
+	unsigned long count = PAGE_SIZE/64;
+	unsigned long *to = (unsigned long *)_to;
+	unsigned long *from = (unsigned long *)_from;
+
+	do {
+		unsigned long a,b,c,d,e,f,g,h;
+		a = from[0];
+		b = from[1];
+		c = from[2];
+		d = from[3];
+		e = from[4];
+		f = from[5];
+		g = from[6];
+		h = from[7];
+		count--;
+		from += 8;
+		to[0] = a;
+		to[1] = b;
+		to[2] = c;
+		to[3] = d;
+		to[4] = e;
+		to[5] = f;
+		to[6] = g;
+		to[7] = h;
+		to += 8;
+	} while (count);
 }
 
 #ifdef STRICT_MM_TYPECHECKS


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-07-20  7:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-07-20  7:07 axp clear_page typo Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox