From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933878AbcI3QAz (ORCPT ); Fri, 30 Sep 2016 12:00:55 -0400 Received: from smtprelay0053.hostedemail.com ([216.40.44.53]:55295 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933577AbcI3QAo (ORCPT ); Fri, 30 Sep 2016 12:00:44 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:4423:4605:5007:6261:7875:7903:9010:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12198:12291:12438:12555:12683:12740:12760:13069:13311:13357:13439:14096:14097:14181:14659:14721:21080:21324:21451:30051:30054:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:3,LUA_SUMMARY:none X-HE-Tag: owl48_23104152d6b2b X-Filterd-Recvd-Size: 2576 Date: Fri, 30 Sep 2016 12:00:38 -0400 From: Steven Rostedt To: Sebastian Andrzej Siewior Cc: linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, peterz@infradead.org Subject: Re: [PATCH RT] kernel/futex: don't deboost too early Message-ID: <20160930120038.5fe7d535@grimm.local.home> In-Reply-To: <20160930083913.aqjpynzsj5d3xxho@linutronix.de> References: <20160930083913.aqjpynzsj5d3xxho@linutronix.de> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 30 Sep 2016 10:39:14 +0200 Sebastian Andrzej Siewior wrote: > The sequence: > T1 holds futex > T2 blocks on futex and boosts T1 > T1 unlocks futex and holds hb->lock > T1 unlocks rt mutex, so T1 has no more pi waiters > T3 blocks on hb->lock and adds itself to the pi waiters list of T1 > T1 unlocks hb->lock and deboosts itself > T4 preempts T1 so the wakeup of T2 gets delayed > > As a workaround I attempt here do unlock the hb->lock without a deboost > and perform the deboost after the wake up of the waiter. > > Cc: stable-rt@vger.kernel.org > Signed-off-by: Sebastian Andrzej Siewior > --- > include/linux/spinlock.h | 6 +++++ > include/linux/spinlock_rt.h | 2 ++ > kernel/futex.c | 2 +- > kernel/locking/rtmutex.c | 53 +++++++++++++++++++++++++++++++++++++++------ > 4 files changed, 55 insertions(+), 8 deletions(-) > This looks awfully complex. Would something as simple as this work? What harm can happen by moving the holding of the lock after the wakeups for RT? -- Steve diff --git a/kernel/futex.c b/kernel/futex.c index 2d572ed..bb900bd 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -1347,9 +1347,14 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this, * deboost first (and lose our higher priority), then the task might get * scheduled away before the wake up can take place. */ +#ifndef CONFIG_PREEMPT_RT_FULL spin_unlock(&hb->lock); +#endif wake_up_q(&wake_q); wake_up_q_sleeper(&wake_sleeper_q); +#ifdef CONFIG_PREEMPT_RT_FULL + spin_unlock(&hb->lock); +#endif if (deboost) rt_mutex_adjust_prio(current);