Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

futex: remove FUTEX_REQUEUE_PI (non CMP)

The new requeue PI futex op codes were modeled after the existing
FUTEX_REQUEUE and FUTEX_CMP_REQUEUE calls. I was unaware at the time
that FUTEX_REQUEUE was only around for compatibility reasons and
shouldn't be used in new code. Ulrich Drepper elaborates on this in his
Futexes are Tricky paper: http://people.redhat.com/drepper/futex.pdf.
The deprecated call doesn't catch changes to the futex corresponding to
the destination futex which can lead to deadlock.

Therefor, I feel it best to remove FUTEX_REQUEUE_PI and leave only
FUTEX_CMP_REQUEUE_PI as there are not yet any existing users of the API.
This patch does change the OP code value of FUTEX_CMP_REQUEUE_PI to 12
from 13. Since my test case is the only known user of this API, I felt
this was the right thing to do, rather than leave a hole in the
enumeration.

I chose to continue using the _CMP_ modifier in the OP code to make it
explicit to the user that the test is being done.

Builds, boots, and ran several hundred iterations requeue_pi.c.

Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
LKML-Reference: <49ED580E.1050502@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Darren Hart and committed by
Thomas Gleixner
ba9c22f2 a5a2a0c7

+2 -8
+1 -3
include/linux/futex.h
··· 24 24 #define FUTEX_WAIT_BITSET 9 25 25 #define FUTEX_WAKE_BITSET 10 26 26 #define FUTEX_WAIT_REQUEUE_PI 11 27 - #define FUTEX_REQUEUE_PI 12 28 - #define FUTEX_CMP_REQUEUE_PI 13 27 + #define FUTEX_CMP_REQUEUE_PI 12 29 28 30 29 #define FUTEX_PRIVATE_FLAG 128 31 30 #define FUTEX_CLOCK_REALTIME 256 ··· 42 43 #define FUTEX_WAKE_BITSET_PRIVATE (FUTEX_WAKE_BITS | FUTEX_PRIVATE_FLAG) 43 44 #define FUTEX_WAIT_REQUEUE_PI_PRIVATE (FUTEX_WAIT_REQUEUE_PI | \ 44 45 FUTEX_PRIVATE_FLAG) 45 - #define FUTEX_REQUEUE_PI_PRIVATE (FUTEX_REQUEUE_PI | FUTEX_PRIVATE_FLAG) 46 46 #define FUTEX_CMP_REQUEUE_PI_PRIVATE (FUTEX_CMP_REQUEUE_PI | \ 47 47 FUTEX_PRIVATE_FLAG) 48 48
+1 -5
kernel/futex.c
··· 2555 2555 ret = futex_wait_requeue_pi(uaddr, fshared, val, timeout, val3, 2556 2556 clockrt, uaddr2); 2557 2557 break; 2558 - case FUTEX_REQUEUE_PI: 2559 - ret = futex_requeue(uaddr, fshared, uaddr2, val, val2, NULL, 1); 2560 - break; 2561 2558 case FUTEX_CMP_REQUEUE_PI: 2562 2559 ret = futex_requeue(uaddr, fshared, uaddr2, val, val2, &val3, 2563 2560 1); ··· 2593 2596 * number of waiters to wake in 'utime' if cmd == FUTEX_WAKE_OP. 2594 2597 */ 2595 2598 if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE || 2596 - cmd == FUTEX_REQUEUE_PI || cmd == FUTEX_CMP_REQUEUE_PI || 2597 - cmd == FUTEX_WAKE_OP) 2599 + cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP) 2598 2600 val2 = (u32) (unsigned long) utime; 2599 2601 2600 2602 return do_futex(uaddr, op, val, tp, uaddr2, val2, val3);