Futex: Revert the non-functional REQUEUE_PI
PATCH 1/1 Futex: Revert the non-functional REQUEUE_PI
Patch d0aa7a70bf03b9de9e995ab272293be1f7937822 titled
"futex_requeue_pi optimization"
introduced user space visible changes to the futex syscall.
The patch is non-functional and there is no way to fix it proper before the 2.6.22 release.
The breakage report ( http://lkml.org/lkml/2007/5/12/17 ) went unanswered, and unfortunately it turned out that the concept is not feasible at all. It violates the rtmutex semantics badly by introducing a virtual owner, which hacks around the coupling of the user-space pi_futex and the kernel internal rt_mutex representation.
At the moment the only safe option is to remove it fully as it contains user-space visible changes to broken kernel code, which we do not want to expose in the 2.6.22 release.
The patch reverts the original patch mostly 1:1, but contains a couple of trivial manual cleanups which were necessary due to patches, which touched the same area of code later.
Verified against the glibc tests and my own PI futex tests.
include/linux/futex.h +1 -8
@@ -17,7 +17,6 @@ union ktime;#define FUTEX_LOCK_PI 6#define FUTEX_UNLOCK_PI 7#define FUTEX_TRYLOCK_PI 8 -#define FUTEX_CMP_REQUEUE_PI 9#define FUTEX_PRIVATE_FLAG 128#define FUTEX_CMD_MASK ~FUTEX_PRIVATE_FLAG
@@ -98,14 +97,9 @@ struct robust_list_head {#define FUTEX_OWNER_DIED 0x40000000/* -* Some processes have been requeued on this PI-futex -*/ -#define FUTEX_WAITER_REQUEUED 0x20000000 - -/* * The rest of the robust-futex field is for the TID: */ -#define FUTEX_TID_MASK 0x0fffffff +#define FUTEX_TID_MASK 0x3fffffff/* * This limit protects against a deliberately circular list.
@@ -139,7 +133,6 @@ handle_futex_death(u32 __user *uaddr, st#define FUT_OFF_MMSHARED 2/* We set bit 1 if key has a reference on mm */ union futex_key { -u32 __user *uaddr;struct {unsigned long pgoff;struct inode *inode;
kernel/futex.c +9 -406
523 lines not on this page · raw message
kernel/futex_compat.c +1 -2
@@ -157,8 +157,7 @@ asmlinkage long compat_sys_futex(u32 __u t =ktime_add (ktime_get (), t); tp = &t; } -if (cmd ==FUTEX_REQUEUE || cmd ==FUTEX_CMP_REQUEUE - || cmd ==FUTEX_CMP_REQUEUE_PI ) +if (cmd ==FUTEX_REQUEUE || cmd ==FUTEX_CMP_REQUEUE ) val2 = (int ) (unsigned long ) utime;return do_futex (uaddr, op, val, tp, uaddr2, val2, val3);
kernel/rtmutex.c +32 -9
71 lines not on this page · raw message
kernel/rtmutex_common.h +0 -34
@@ -113,29 +113,6 @@ static inline unsigned long rt_mutex_own }/* -* We can speed up the acquire/release, if the architecture -* supports cmpxchg and if there's no debugging state to be set up -*/ -#if defined(__HAVE_ARCH_CMPXCHG) && !defined(CONFIG_DEBUG_RT_MUTEXES ) -# define rt_mutex_cmpxchg (l,c,n) (cmpxchg(&l->owner, c, n) == c) -static inline void mark_rt_mutex_waiters (struct rt_mutex *lock) -{ -unsigned long owner, *p = (unsigned long *) &lock->owner; - -do { - owner = *p; - }while (cmpxchg (p, owner, owner |RT_MUTEX_HAS_WAITERS ) != owner); -} -#else -# define rt_mutex_cmpxchg (l,c,n) (0) -static inline void mark_rt_mutex_waiters (struct rt_mutex *lock) -{ - lock->owner = (struct task_struct *) - ((unsigned long )lock->owner |RT_MUTEX_HAS_WAITERS ); -} -#endif - -/* * PI-futex support (proxy locking functions, etc.): */ extern struct task_struct *rt_mutex_next_owner (struct rt_mutex *lock);
@@ -143,15 +120,4 @@ extern void rt_mutex_init_proxy_locked(s struct task_struct *proxy_owner);extern void rt_mutex_proxy_unlock (struct rt_mutex *lock,struct task_struct *proxy_owner); - -extern void rt_mutex_set_owner (struct rt_mutex *lock,struct task_struct *owner, -unsigned long mask); -extern void __rt_mutex_adjust_prio (struct task_struct *task); -extern int rt_mutex_adjust_prio_chain (struct task_struct *task, -int deadlock_detect, -struct rt_mutex *orig_lock, -struct rt_mutex_waiter *orig_waiter, -struct task_struct *top_task); -extern void remove_waiter (struct rt_mutex *lock, -struct rt_mutex_waiter *waiter);#endif
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 2 lines · Thomas Gleixner
The patch is non-functional and there is no way to fix it proper before the 2.6.22 release.
Indeed. A lot more discussion is needed to handle this correctly. No committed code in glibc so far uses the function so removal is no problem.
Quoted 2 lines
Signed-off-by Thomas Gleixner <[email protected]>Signed-off-by Ingo Molnar <[email protected]>
- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖ -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQFGdYmx2ijCOnn/RHQRAqFEAJ9lwl52xOFl2rJ/sxrlaDtMDbU71wCfYgxS VJUlQaO3Fba9aPUFWjrVjXI=
=GvES
-----END PGP SIGNATURE-----
Quoted 11 lines · Thomas Gleixner
Patch
d0aa7a70bf03b9de9e995ab272293be1f7937822titled"
futex_requeue_pioptimization"introduced user space visible changes to the futex syscall.
The patch is non-functional and there is no way to fix it proper before the 2.6.22 release.
The breakage report ( http://lkml.org/lkml/2007/5/12/17 ) went unanswered,
Sorry, but I passed lot of time on this last year without any answers or comments from the community when I have sent my patches.
Now I'm working on something else and I can't spent more time on this for now... Futexes are so complex that it is always difficult to investigate a problem in only one or two hours...
Quoted 2 lines
and unfortunately it turned out that the concept is not feasible at all.
Without robust futex, the concept works well, and the performance gain has been proven.
It violates the rtmutex semantics badly by introducing
Quoted 2 lines
a virtual owner, which hacks around the coupling of the user-space
pi_futexand the kernel internalrt_mutexrepresentation.
What you call a hack, is for me a design point. And if this is a hack, then I think that we can say that futexes are based on a series of hacks... But, okay, this is not very constructive, so...
Quoted 3 lines · Ulrich Drepper
Indeed. A lot more discussion is needed to handle this correctly. No committed code in glibc so far uses the function so removal is no problem.
Once again, it's a pity that people didn't spent time to comment on this when I was working on this. Now, the work will probably just be lost...
Signature · 1 line
Pierre
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 2 lines · Pierre Peiffer
Once again, it's a pity that people didn't spent time to comment on this when I was working on this.
It was no accusation. IMO this is how it should work. The problems became visible only once the code was being used. This is what the current model allows: we find problems and since the development cycle requires changes to be added at the beginning we have time to back changes out again. No harm done.
- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖ -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQFGdpLa2ijCOnn/RHQRArfeAJ941sp77rF4BN6heEZvB/E6Tx29KwCeI34f um8soonlsK4Lp1k+t0WHzhM=
=9v8e
-----END PGP SIGNATURE-----