lkml.org 
[lkml]   [2021]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[patch 5/6] futex: Prepare futex_lock_pi() for runtime clock selection
    futex_lock_pi() is the only futex operation which cannot select the clock
    for timeouts (CLOCK_MONOTONIC/CLOCK_REALTIME). That's inconsistent and
    there is no particular reason why this cannot be supported.

    This was overlooked when CLOCK_REALTIME_FLAG was introduced and
    unfortunately not reported when the inconsistency was discovered in glibc.

    Prepare the function and enforce the CLOCK_REALTIME_FLAG on FUTEX_LOCK_PI
    so that a new FUTEX_LOCK_PI2 can implement it correctly.

    Reported-by: Kurt Kanzenbach <kurt@linutronix.de>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    ---
    kernel/futex.c | 5 +++--
    1 file changed, 3 insertions(+), 2 deletions(-)

    --- a/kernel/futex.c
    +++ b/kernel/futex.c
    @@ -2786,7 +2786,7 @@ static int futex_lock_pi(u32 __user *uad
    if (refill_pi_state_cache())
    return -ENOMEM;

    - to = futex_setup_timer(time, &timeout, FLAGS_CLOCKRT, 0);
    + to = futex_setup_timer(time, &timeout, flags, 0);

    retry:
    ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q.key, FUTEX_WRITE);
    @@ -3711,7 +3711,7 @@ long do_futex(u32 __user *uaddr, int op,

    if (op & FUTEX_CLOCK_REALTIME) {
    flags |= FLAGS_CLOCKRT;
    - if (cmd != FUTEX_WAIT_BITSET && cmd != FUTEX_WAIT_REQUEUE_PI)
    + if (cmd != FUTEX_WAIT_BITSET && cmd != FUTEX_WAIT_REQUEUE_PI)
    return -ENOSYS;
    }

    @@ -3743,6 +3743,7 @@ long do_futex(u32 __user *uaddr, int op,
    case FUTEX_WAKE_OP:
    return futex_wake_op(uaddr, flags, uaddr2, val, val2, val3);
    case FUTEX_LOCK_PI:
    + flags |= FLAGS_CLOCKRT;
    return futex_lock_pi(uaddr, flags, timeout, 0);
    case FUTEX_UNLOCK_PI:
    return futex_unlock_pi(uaddr, flags);
    \
     
     \ /
      Last update: 2021-04-22 22:30    [W:3.989 / U:0.536 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site