Skip to content

Commit

Permalink
futex: add FUTEX_HAS_TIMEOUT flag to restart.futex.flags
Browse files Browse the repository at this point in the history
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. While the
check is not technically needed in futex_wait_restart(), doing so
makes the code consistent with and will avoid confusion should the
need arise to restart wait without a timeout.

Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Darren Hart authored and Thomas Gleixner committed Apr 6, 2009
1 parent 8dac456 commit a72188d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions kernel/futex.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,7 @@ static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q,
*/
#define FLAGS_SHARED 0x01
#define FLAGS_CLOCKRT 0x02
#define FLAGS_HAS_TIMEOUT 0x04

static long futex_wait_restart(struct restart_block *restart);

Expand Down Expand Up @@ -1486,7 +1487,7 @@ static int futex_wait(u32 __user *uaddr, int fshared,
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;
Expand All @@ -1510,13 +1511,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);
}
Expand Down

0 comments on commit a72188d

Please sign in to comment.