lkml.org 
[lkml]   [2021]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 58/63] futex: Prevent requeue_pi() lock nesting issue on RT
On Mon, Aug 02, 2021 at 02:56:09PM +0200, Peter Zijlstra wrote:
> static inline int futex_requeue_pi_wakeup_sync(struct futex_q *q)
> {
> + int old, new;
>
> + old = atomic_read_acquire(&q->requeue_state);
> + do {
> /* Is requeue done already? */
> + if (old >= Q_REQUEUE_PI_DONE)
> break;

I think that can be: return old; for slightly simpler code.

>
> /*
> * If not done, then tell the requeue code to either ignore
> * the waiter or to wake it up once the requeue is done.
> */
> + new = Q_REQUEUE_PI_WAIT;
> + if (old == Q_REQUEUE_PI_NONE)
> + new = Q_REQUEUE_PI_IGNORE;
> + } while (!atomic_try_cmpxchg(&q->requeue_state, &old, new));
>
> /* If the requeue was in progress, wait for it to complete */
> + if (old == Q_REQUEUE_PI_IN_PROGRESS) {
> #ifdef CONFIG_PREEMPT_RT
> rcuwait_wait_event(&q->requeue_wait,
> atomic_read(&q->requeue_state) != Q_REQUEUE_PI_WAIT,
> TASK_UNINTERRUPTIBLE);
> #else
> + (void)atomic_cond_read_relaxed(&q->requeue_state, VAL != Q_REQUEUE_PI_WAIT);
> #endif
> }
>

\
 
 \ /
  Last update: 2021-08-02 15:11    [W:0.185 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site