From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161295AbcIZPPa (ORCPT ); Mon, 26 Sep 2016 11:15:30 -0400 Received: from smtprelay0117.hostedemail.com ([216.40.44.117]:55886 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965099AbcIZPP1 (ORCPT ); Mon, 26 Sep 2016 11:15:27 -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:1542:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3354:3622:3865:3867:3868:3870:3874:4250:5007:6261:7875:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12198:12296:12438:12740:12760:13161:13229:13439:14096:14097:14181:14659:14721:21080:21324: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: grip25_865e0020da947 X-Filterd-Recvd-Size: 3528 Date: Mon, 26 Sep 2016 11:15:11 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: mingo@kernel.org, tglx@linutronix.de, juri.lelli@arm.com, xlpang@redhat.com, bigeasy@linutronix.de, linux-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, jdesfossez@efficios.com, bristot@redhat.com, Ingo Molnar Subject: Re: [PATCH -v2 1/9] rtmutex: Deboost before waking up the top waiter Message-ID: <20160926111511.1d963075@grimm.local.home> In-Reply-To: <20160926124127.863639194@infradead.org> References: <20160926123213.851818224@infradead.org> <20160926124127.863639194@infradead.org> 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 Mon, 26 Sep 2016 14:32:14 +0200 Peter Zijlstra wrote: > > --- a/kernel/futex.c > +++ b/kernel/futex.c > @@ -1374,9 +1374,8 @@ static int wake_futex_pi(u32 __user *uad > * scheduled away before the wake up can take place. > */ > spin_unlock(&hb->lock); > - wake_up_q(&wake_q); > - if (deboost) > - rt_mutex_adjust_prio(current); > + > + rt_mutex_postunlock(&wake_q, deboost); Hmm... > > return 0; > } > --- a/kernel/locking/rtmutex.c > +++ b/kernel/locking/rtmutex.c > @@ -1325,6 +1308,16 @@ static bool __sched rt_mutex_slowunlock( > */ > mark_wakeup_next_waiter(wake_q, lock); > > + /* > + * We should deboost before waking the top waiter task such that > + * we don't run two tasks with the 'same' priority. This however > + * can lead to prio-inversion if we would get preempted after > + * the deboost but before waking our high-prio task, hence the > + * preempt_disable before unlock. Pairs with preempt_enable() in > + * rt_mutex_postunlock(); There's a preempt_enable() in rt_mutex_postunlock()? Does wake_futex_pi() know that? -- Steve > + */ > + preempt_disable(); > + > raw_spin_unlock_irqrestore(&lock->wait_lock, flags); > > /* check PI boosting */ > @@ -1390,14 +1383,23 @@ rt_mutex_fastunlock(struct rt_mutex *loc > } else { > bool deboost = slowfn(lock, &wake_q); > > - wake_up_q(&wake_q); > - > - /* Undo pi boosting if necessary: */ > - if (deboost) > - rt_mutex_adjust_prio(current); > + rt_mutex_postunlock(&wake_q, deboost); > } > } > > + > +/* > + * Undo pi boosting (if necessary) and wake top waiter. > + */ > +void rt_mutex_postunlock(struct wake_q_head *wake_q, bool deboost) > +{ > + wake_up_q(wake_q); > + > + /* Pairs with preempt_disable() in rt_mutex_slowunlock() */ > + if (deboost) > + preempt_enable(); > +} > + > /** > * rt_mutex_lock - lock a rt_mutex > * > --- a/kernel/locking/rtmutex_common.h > +++ b/kernel/locking/rtmutex_common.h > @@ -111,6 +111,7 @@ extern int rt_mutex_finish_proxy_lock(st > extern int rt_mutex_timed_futex_lock(struct rt_mutex *l, struct hrtimer_sleeper *to); > extern bool rt_mutex_futex_unlock(struct rt_mutex *lock, > struct wake_q_head *wqh); > +extern void rt_mutex_postunlock(struct wake_q_head *wake_q, bool deboost); > extern void rt_mutex_adjust_prio(struct task_struct *task); > > #ifdef CONFIG_DEBUG_RT_MUTEXES >