From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755003AbdEKHb7 (ORCPT ); Thu, 11 May 2017 03:31:59 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:47653 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754977AbdEKHb6 (ORCPT ); Thu, 11 May 2017 03:31:58 -0400 Date: Thu, 11 May 2017 09:31:53 +0200 (CEST) From: Thomas Gleixner To: Wanpeng Li cc: LKML , Sebastian Sewior , Peter Zijlstra , Steven Rostedt , linux-rt-users , Engleder Gerhard Subject: Re: [PATCH RT] futex/rtmutex: Cure RT double blocking issue In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 11 May 2017, Wanpeng Li wrote: > 2017-05-09 23:11 GMT+08:00 Thomas Gleixner : > > 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 > > --- > > kernel/locking/rtmutex.c | 17 +++++++++++++++++ > > 1 file changed, 17 insertions(+) > > > > --- a/kernel/locking/rtmutex.c > > +++ b/kernel/locking/rtmutex.c > > @@ -2380,6 +2380,7 @@ int rt_mutex_wait_proxy_lock(struct rt_m > > struct hrtimer_sleeper *to, > > struct rt_mutex_waiter *waiter) > > { > > + struct task_struct *tsk = current; > > int ret; > > > > raw_spin_lock_irq(&lock->wait_lock); > > @@ -2389,6 +2390,22 @@ int rt_mutex_wait_proxy_lock(struct rt_m > > /* sleep on the mutex */ > > ret = __rt_mutex_slowlock(lock, TASK_INTERRUPTIBLE, to, waiter, NULL); > > Why not check the ret value to avoid lock/unlock tsk->pi_lock when > acquires the rt_mutex successfully? Make sense. Thanks, tglx