[tip PATCH v6 6/8] RFC: futex: Add FUTEX_HAS_TIMEOUT flag to restart.futex.flags

[tip PATCH v6 6/8] RFC: futex: Add FUTEX_HAS_TIMEOUT flag to restart.futex.flags

Post by Eric Dumaz » Wed, 01 Apr 2009 06:50:20


Darren Hart a crit :

You probably meant :

if (restart->futex.flags & FLAGS_HAS_TIMEOUT)



To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/
 
 
 

[tip PATCH v6 6/8] RFC: futex: Add FUTEX_HAS_TIMEOUT flag to restart.futex.flags

Post by Darren Har » Wed, 01 Apr 2009 07:50:07


Hi Eric,

Thanks for the prompt review...



Gah! You are correct. Corrected patch below.


RFC: futex: Add FUTEX_HAS_TIMEOUT flag to restart.futex.flags

From: Darren Hart < XXXX@XXXXX.COM >

Currently restart is only used if there is a timeout. The requeue_pi
functionality requires restarting to futex_lock_pi() on signal after
wakeup in futex_wait_requeue_pi() regardless of if there was a timeout
or not. Using 0 for the timeout value is confusing as that could
indicate an expired timer. The flag makes this explicit.

Changelog:
V7pre: -Corrected FLAGS_HAS_TIMEOUT flag detection logic per Eric Dumazet
V6: - Initial version

Signed-off-by: Darren Hart < XXXX@XXXXX.COM >
Cc: Thomas Gleixner < XXXX@XXXXX.COM >
Cc: Sripathi Kodi < XXXX@XXXXX.COM >
Cc: Peter Zijlstra < XXXX@XXXXX.COM >
Cc: John Stultz < XXXX@XXXXX.COM >
Cc: Steven Rostedt < XXXX@XXXXX.COM >
Cc: Dinakar Guniguntala < XXXX@XXXXX.COM >
Cc: Ulrich Drepper < XXXX@XXXXX.COM >
Cc: Eric Dumazet < XXXX@XXXXX.COM >
Cc: Ingo Molnar < XXXX@XXXXX.COM >
Cc: Jakub Jelinek < XXXX@XXXXX.COM >
---

kernel/futex.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)


diff --git a/kernel/futex.c b/kernel/futex.c
index dd05803..07e314c 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1254,6 +1254,7 @@ handle_fault:
*/
#define FLAGS_SHARED 0x01
#define FLAGS_CLOCKRT 0x02
+#define FLAGS_HAS_TIMEOUT 0x04

static long futex_wait_restart(struct restart_block *restart);

@@ -1493,7 +1494,7 @@ retry_private:
restart->futex.val = val;
restart->futex.time = abs_time->tv64;
restart->futex.bitset = bitset;
- restart->futex.flags = 0;
+ restart->futex.flags = FLAGS_HAS_TIMEOUT;

if (fshared)
restart->futex.flags |= FLAGS_SHARED;
@@ -1517,13 +1518,16 @@ static long futex_wait_restart(struct restart_block *restart)
{
u32 __user *uaddr = (u32 __user *)restart->futex.uaddr;
int fshared = 0;
- ktime_t t;
+ ktime_t t, *tp = NULL;

- t.tv64 = restart->futex.time;
+ if (restart->futex.flags & FLAGS_HAS_TIMEOUT) {
+ t.tv64 = restart->futex.time;
+ tp = &t;
+ }
restart->fn = do_no_restart_syscall;
if (restart->futex.flags & FLAGS_SHARED)
fshared = 1;
- return (long)futex_wait(uaddr, fshared, restart->futex.val, &t,
+ return (long)futex_wait(uaddr, fshared, restart->futex.val, tp,
restart->futex.bitset,
restart->futex.flags & FLAGS_CLOCKRT);
}

--
Darren Hart
IBM Linux Technology Center
Real-Time Linux Team
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/