PERFORCE change 119326 for review

Roman Divacky rdivacky at FreeBSD.org
Sun May 6 12:28:28 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=119326

Change 119326 by rdivacky at rdivacky_witten on 2007/05/06 12:28:12

	Raceless linux_support.s for i386. This should be a final version.
	
	Submitted by: kib

Affected files ...

.. //depot/projects/soc2007/rdivacky/linux_futex/sys/i386/linux/linux_support.s#3 edit

Differences ...

==== //depot/projects/soc2007/rdivacky/linux_futex/sys/i386/linux/linux_support.s#3 (text+ko) ====

@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1993 The Regents of the University of California.
+ * Copyright (c) 2006,2007 The FreeBSD Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,8 +29,8 @@
  * $FreeBSD$
  */
 
-#include "linux_assym.h"                        /* system definitions */
-#include <machine/asmacros.h>                   /* miscellaneous asm macros */
+#include "linux_assym.h"		/* system definitions */
+#include <machine/asmacros.h>		/* miscellaneous asm macros */
 
 #include "assym.s"
 
@@ -38,110 +38,94 @@
 /* linux_futex support                                                       */
 /*****************************************************************************/
 
-/* we return -EFAULT in a case of a fault */
+futex_fault_decx:
+	movl	PCPU(CURPCB),%ecx
 futex_fault:
 	movl	$0,PCB_ONFAULT(%ecx)
 	movl	$-EFAULT,%eax
 	ret
 
 ENTRY(futex_xchgl)
-	/* set fault address */
 	movl	PCPU(CURPCB),%ecx
 	movl	$futex_fault,PCB_ONFAULT(%ecx)
-	movl	12(%esp),%ebx
+	movl	4(%esp),%eax
+	movl	8(%esp),%edx
 	cmpl    $VM_MAXUSER_ADDRESS-4,%edx
 	ja     	futex_fault
-	movl	8(%esp),%edx
-	/*    
-	 *    use now free eax and do:
-	 *    *oldval = *uaddr
-	 */
-	movl	(%edx),%eax
-	movl	%eax,(%ebx)
-	movl	4(%esp),%eax
-
-	/* perform the operation */
-#ifdef SMP
-	lock
-#endif
 	xchgl	%eax,(%edx)
-	/* and return 0 */
+	movl	12(%esp),%edx
+	movl	%eax,(%edx)
 	xorl	%eax,%eax
-	movl	$0,PCB_ONFAULT(%ecx)
+	movl	%eax,PCB_ONFAULT(%ecx)
 	ret
 
 ENTRY(futex_addl)
 	movl	PCPU(CURPCB),%ecx
 	movl	$futex_fault,PCB_ONFAULT(%ecx)
+	movl	4(%esp),%eax
 	movl	8(%esp),%edx
 	cmpl    $VM_MAXUSER_ADDRESS-4,%edx
 	ja     	futex_fault
-	movl	12(%esp),%ebx
-	movl	(%edx),%eax
-	movl	%eax,(%ebx)
-	movl	4(%esp),%eax
-
 #ifdef SMP
 	lock
 #endif
 	xaddl	%eax,(%edx)
+	movl	12(%esp),%edx
+	movl	%eax,(%edx)
 	xorl	%eax,%eax
-	movl	$0,PCB_ONFAULT(%ecx)
+	movl	%eax,PCB_ONFAULT(%ecx)
 	ret
 
 ENTRY(futex_orl)
 	movl	PCPU(CURPCB),%ecx
-	movl	$futex_fault,PCB_ONFAULT(%ecx)
+	movl	$futex_fault_decx,PCB_ONFAULT(%ecx)
 	movl	8(%esp),%edx
 	cmpl    $VM_MAXUSER_ADDRESS-4,%edx
 	ja     	futex_fault
-	movl	12(%esp),%ebx
 	movl	(%edx),%eax
-	movl	%eax,(%ebx)
-	movl	4(%esp),%eax
-
+1:	movl	%eax,%ecx
+	orl	4(%esp),%ecx
 #ifdef SMP
 	lock
 #endif
-	orl	%eax,(%edx)
+	cmpxchgl %ecx,(%edx)
+	jnz	1b
+futex_tail:	
+	movl	12(%esp),%edx
+	movl	%eax,(%edx)
 	xorl	%eax,%eax
-	movl	$0,PCB_ONFAULT(%ecx)
+	movl	PCPU(CURPCB),%ecx
+	movl	%eax,PCB_ONFAULT(%ecx)
 	ret
 
 ENTRY(futex_andl)
 	movl	PCPU(CURPCB),%ecx
-	movl	$futex_fault,PCB_ONFAULT(%ecx)
+	movl	$futex_fault_decx,PCB_ONFAULT(%ecx)
 	movl	8(%esp),%edx
 	cmpl    $VM_MAXUSER_ADDRESS-4,%edx
 	ja     	futex_fault
-	movl	12(%esp),%ebx
 	movl	(%edx),%eax
-	movl	%eax,(%ebx)
-	movl	4(%esp),%eax
-	
+1:	movl	%eax,%ecx
+	andl	4(%esp),%ecx
 #ifdef SMP
 	lock
 #endif
-	andl	%eax,(%edx)
-	xorl	%eax,%eax
-	movl	$0,PCB_ONFAULT(%ecx)
-	ret
+	cmpxchgl %ecx,(%edx)
+	jnz	1b
+	jmp	futex_tail
 
 ENTRY(futex_xorl)
 	movl	PCPU(CURPCB),%ecx
-	movl	$futex_fault,PCB_ONFAULT(%ecx)
+	movl	$futex_fault_decx,PCB_ONFAULT(%ecx)
 	movl	8(%esp),%edx
 	cmpl    $VM_MAXUSER_ADDRESS-4,%edx
 	ja     	futex_fault
-	movl	12(%esp),%ebx
 	movl	(%edx),%eax
-	movl	%eax,(%ebx)
-	movl	4(%esp),%eax
-
+1:	movl	%eax,%ecx
+	xorl	4(%esp),%ecx
 #ifdef SMP
 	lock
 #endif
-	xorl	%eax,(%edx)
-	xorl	%eax,%eax
-	movl	$0,PCB_ONFAULT(%ecx)
-	ret
+	cmpxchgl %ecx,(%edx)
+	jnz	1b
+	jmp	futex_tail


More information about the p4-projects mailing list