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

Configure Feed

Select the types of activity you want to include in your feed.

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>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210422194705.338657741@linutronix.de

authored by

Thomas Gleixner and committed by
Peter Zijlstra
e112c413 1a812296

+2 -1
+2 -1
kernel/futex.c
··· 2783 2783 if (refill_pi_state_cache()) 2784 2784 return -ENOMEM; 2785 2785 2786 - to = futex_setup_timer(time, &timeout, FLAGS_CLOCKRT, 0); 2786 + to = futex_setup_timer(time, &timeout, flags, 0); 2787 2787 2788 2788 retry: 2789 2789 ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q.key, FUTEX_WRITE); ··· 3739 3739 case FUTEX_WAKE_OP: 3740 3740 return futex_wake_op(uaddr, flags, uaddr2, val, val2, val3); 3741 3741 case FUTEX_LOCK_PI: 3742 + flags |= FLAGS_CLOCKRT; 3742 3743 return futex_lock_pi(uaddr, flags, timeout, 0); 3743 3744 case FUTEX_UNLOCK_PI: 3744 3745 return futex_unlock_pi(uaddr, flags);