LWN.net Logo

robust futex patch for 2.6.14-rc3-rt13

From:  david singleton <dsingleton@mvista.com>
To:  Ingo Molnar <mingo@elte.hu>
Subject:  robust futex patch for 2.6.14-rc3-rt13
Date:  Sat, 8 Oct 2005 14:47:23 -0700
Cc:  linux-kernel@vger.kernel.org, robustmutexes@lists.osdl.org


Ingo,
     here's a patch for the robust futex changes that match the 
glibc/nptl changes
for robust futexes.  The kernel and glibc now both have robustness and
priority inheritance independent.

	This patch is based off 2.6.14-rc3-rt13.

	The changes remove some duplicate defines from futex.c and glibc and
put all the defines into futex.h.   The defines have also been changed 
a bit
to make the assembler in glibc simpler.

	There is also one fix to futex.c where the first waiter on a futex 
waits instead of returning -EAGAIN.

	The glibc patches can be found at http://source.mvista.com/~dsingleton


glibc-bull-nptl-robustmutexes.patch
glibc-mvl-nptl-priority-inheritance-rf2.patch

David
--- futex/linux-2.6.13.3/include/linux/futex.h	2005-10-08 11:38:24.000000000 -0700
+++ new/linux-2.6.13.3/include/linux/futex.h	2005-10-08 11:37:56.000000000 -0700
@@ -18,10 +18,16 @@
 
 #define FUTEX_ATTR_PRIORITY_QUEUING		0x10000000
 #define FUTEX_ATTR_PRIORITY_INHERITANCE		0x20000000
-#define FUTEX_ATTR_ROBUST			0x40000000
-#define FUTEX_ATTR_PRIORITY_PROTECT		0x80000000
+#define FUTEX_ATTR_PRIORITY_PROTECT		0x40000000
+#define FUTEX_ATTR_ROBUST			0x80000000
 #define FUTEX_ATTR_SHARED			0x01000000
-#define FUTEX_ATTR_MASK				0xf1000000
+#define FUTEX_ATTR_MASK				0xff000000
+
+#define FUTEX_WAITERS                         0x80000000
+#define FUTEX_OWNER_DIED                      0x40000000
+#define FUTEX_NOT_RECOVERABLE                 0x20000000
+#define FUTEX_FLAGS (FUTEX_WAITERS | FUTEX_OWNER_DIED | FUTEX_NOT_RECOVERABLE)
+#define FUTEX_PID                             ~(FUTEX_FLAGS)
 
 #ifdef __KERNEL__
 
--- futex/linux-2.6.13.3/kernel/futex.c	2005-10-08 14:37:58.000000000 -0700
+++ new/linux-2.6.13.3/kernel/futex.c	2005-10-08 14:38:53.000000000 -0700
@@ -853,11 +853,6 @@
  * the futex is not locked.
  */
 
-#define FUTEX_WAITERS		0x80000000
-#define FUTEX_OWNER_DIED	0x40000000
-#define FUTEX_NOT_RECOVERABLE	0x20000000
-#define FUTEX_PID		0x1fffffff
-
 /*
  * Used to track registered robust futexes. Attached to linked list in inodes.
  */
@@ -1179,16 +1174,6 @@
 		goto out_release_sem;
 	}
 
-	/*
-	 * user mode called us because futex had owner and waitflag was
-	 * set. That's not true now, so let user mode try again
-	 */
-	if ((curval & FUTEX_PID) && !(curval & FUTEX_WAITERS)) {
-		ret = -EAGAIN;
-		queue_unlock(&q, bh);
-		goto out_release_sem;
-	}
-
 	/* if owner has died, we don't want to wait */
 	if ((curval & FUTEX_OWNER_DIED)) {
 		ret = -EOWNERDEAD;


Copyright © 2005, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds