From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933732AbdEKQFF convert rfc822-to-8bit (ORCPT ); Thu, 11 May 2017 12:05:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:57944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933097AbdEKQEp (ORCPT ); Thu, 11 May 2017 12:04:45 -0400 X-Greylist: delayed 594 seconds by postgrey-1.27 at vger.kernel.org; Thu, 11 May 2017 12:04:44 EDT DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 257D123986 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Thu, 11 May 2017 11:54:47 -0400 From: Steven Rostedt To: Sebastian Sewior Cc: Thomas Gleixner , Wanpeng Li , LKML , Peter Zijlstra , linux-rt-users , Engleder Gerhard Subject: Re: [PATCH RT v2] futex/rtmutex: Cure RT double blocking issue Message-ID: <20170511115447.7622712d@gandalf.local.home> In-Reply-To: <20170511152054.bpgik7etss7umxzq@linutronix.de> References: <20170511152054.bpgik7etss7umxzq@linutronix.de> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 11 May 2017 17:20:54 +0200 Sebastian Sewior wrote: This is the same patch that Thomas wrote, right? Shouldn't this start with: From: Thomas Gleixner ? -- Steve > RT has a problem when the wait on a futex/rtmutex got interrupted by a > timeout or a signal. task->pi_blocked_on is still set when returning from > rt_mutex_wait_proxy_lock(). The task must acquire the hash bucket lock > after this. > > If the hash bucket lock is contended then the > BUG_ON(rt_mutex_real_waiter(task->pi_blocked_on)) in > task_blocks_on_rt_mutex() will trigger. > > This can be avoided by clearing task->pi_blocked_on in the return path of > rt_mutex_wait_proxy_lock() which removes the task from the boosting chain > of the rtmutex. That's correct because the task is not longer blocked on > it. > > Signed-off-by: Thomas Gleixner > Reported-by: Engleder Gerhard > Signed-off-by: Sebastian Andrzej Siewior > --- > v1…v2: reset ->pi_blocked_on only in the error case. > > kernel/locking/rtmutex.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c > index 314fc65a35b1..4675f1197f33 100644 > --- a/kernel/locking/rtmutex.c > +++ b/kernel/locking/rtmutex.c > @@ -2400,6 +2400,7 @@ int rt_mutex_wait_proxy_lock(struct rt_mutex *lock, > struct hrtimer_sleeper *to, > struct rt_mutex_waiter *waiter) > { > + struct task_struct *tsk = current; > int ret; > > raw_spin_lock_irq(&lock->wait_lock); > @@ -2409,6 +2410,24 @@ int rt_mutex_wait_proxy_lock(struct rt_mutex *lock, > /* sleep on the mutex */ > ret = __rt_mutex_slowlock(lock, TASK_INTERRUPTIBLE, to, waiter, NULL); > > + /* > + * RT has a problem here when the wait got interrupted by a timeout > + * or a signal. task->pi_blocked_on is still set. The task must > + * acquire the hash bucket lock when returning from this function. > + * > + * If the hash bucket lock is contended then the > + * BUG_ON(rt_mutex_real_waiter(task->pi_blocked_on)) in > + * task_blocks_on_rt_mutex() will trigger. This can be avoided by > + * clearing task->pi_blocked_on which removes the task from the > + * boosting chain of the rtmutex. That's correct because the task > + * is not longer blocked on it. > + */ > + if (ret) { > + raw_spin_lock(&tsk->pi_lock); > + tsk->pi_blocked_on = NULL; > + raw_spin_unlock(&tsk->pi_lock); > + } > + > raw_spin_unlock_irq(&lock->wait_lock); > > return ret;