From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034686AbcIZQJ6 (ORCPT ); Mon, 26 Sep 2016 12:09:58 -0400 Received: from smtprelay0038.hostedemail.com ([216.40.44.38]:35347 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1161405AbcIZQJ4 (ORCPT ); Mon, 26 Sep 2016 12:09:56 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::::::,RULES_HIT:41:69:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1535:1544:1593:1594:1605:1711:1730:1747:1777:1792:2393:2553:2559:2562:2693:2895:3138:3139:3140:3141:3142:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:4605:5007:6261:7875:7903:8660:10004:10848:10967:11026:11232:11473:11658:11914:12043:12198:12296:12438:12740:12760:13141:13148:13153:13228:13230:13439:14096:14097:14181:14659:14721:21080:21324:21450:21451:30012:30051:30054:30055: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:4,LUA_SUMMARY:none X-HE-Tag: milk36_1c1c20bcc2816 X-Filterd-Recvd-Size: 5780 Date: Mon, 26 Sep 2016 12:09:43 -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 Subject: Re: [PATCH -v2 5/9] rtmutex: Clean up Message-ID: <20160926120943.6d685a2f@grimm.local.home> In-Reply-To: <20160926124128.136301172@infradead.org> References: <20160926123213.851818224@infradead.org> <20160926124128.136301172@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:18 +0200 Peter Zijlstra wrote: > Previous patches changed the meaning of the return value of > rt_mutex_slowunlock(); update comments and code to reflect this. > > Signed-off-by: Peter Zijlstra (Intel) > --- > kernel/futex.c | 12 ++++++------ > kernel/locking/rtmutex.c | 20 +++++++++----------- > kernel/locking/rtmutex_common.h | 2 +- > 3 files changed, 16 insertions(+), 18 deletions(-) > > --- a/kernel/futex.c > +++ b/kernel/futex.c > @@ -1261,7 +1261,7 @@ static int wake_futex_pi(u32 __user *uad > struct futex_pi_state *pi_state = this->pi_state; > u32 uninitialized_var(curval), newval; > WAKE_Q(wake_q); > - bool deboost; > + bool postunlock; > int ret = 0; > > if (!pi_state) > @@ -1327,17 +1327,17 @@ static int wake_futex_pi(u32 __user *uad > > raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock); > > - deboost = rt_mutex_futex_unlock(&pi_state->pi_mutex, &wake_q); > + postunlock = rt_mutex_futex_unlock(&pi_state->pi_mutex, &wake_q); > > /* > * First unlock HB so the waiter does not spin on it once he got woken > - * up. Second wake up the waiter before the priority is adjusted. If we > - * deboost first (and lose our higher priority), then the task might get > - * scheduled away before the wake up can take place. > + * up. Then wakeup the waiter by calling rt_mutex_postunlock(). Priority > + * is already adjusted and preemption is disabled to avoid inversion. Can we specify here that preemption is only disabled if rt_mutex_futex_unlock() returns true, and will be enabled again with rt_mutex_postunlock(). > */ > spin_unlock(&hb->lock); > > - rt_mutex_postunlock(&wake_q, deboost); > + if (postunlock) > + rt_mutex_postunlock(&wake_q); > > return 0; > } > --- a/kernel/locking/rtmutex.c > +++ b/kernel/locking/rtmutex.c > @@ -1254,7 +1254,8 @@ static inline int rt_mutex_slowtrylock(s > > /* > * Slow path to release a rt-mutex. > - * Return whether the current task needs to undo a potential priority boosting. > + * > + * Return whether the current task needs to call rt_mutex_postunlock(). > */ > static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock, > struct wake_q_head *wake_q) > @@ -1327,7 +1328,7 @@ static bool __sched rt_mutex_slowunlock( > > raw_spin_unlock_irqrestore(&lock->wait_lock, flags); > > - /* check PI boosting */ > + /* call rt_mutex_postunlock() */ Can we rephrase this to "A call to rt_mutex_postunlock() is required". > return true; > } > > @@ -1378,15 +1379,14 @@ rt_mutex_fasttrylock(struct rt_mutex *lo > } > > /* > - * Undo pi boosting (if necessary) and wake top waiter. > + * Performs the wakeup of the the top-waiter and re-enables preemption. > */ > -void rt_mutex_postunlock(struct wake_q_head *wake_q, bool deboost) > +void rt_mutex_postunlock(struct wake_q_head *wake_q) > { > wake_up_q(wake_q); > > /* Pairs with preempt_disable() in rt_mutex_slowunlock() */ > - if (deboost) > - preempt_enable(); > + preempt_enable(); > } > > /** > @@ -1489,9 +1489,8 @@ void __sched rt_mutex_unlock(struct rt_m > rt_mutex_deadlock_account_unlock(current); > > } else { > - bool deboost = rt_mutex_slowunlock(lock, &wake_q); > - > - rt_mutex_postunlock(&wake_q, deboost); > + if (rt_mutex_slowunlock(lock, &wake_q)) > + rt_mutex_postunlock(&wake_q); > } > } > EXPORT_SYMBOL_GPL(rt_mutex_unlock); > @@ -1500,8 +1499,7 @@ EXPORT_SYMBOL_GPL(rt_mutex_unlock); > * rt_mutex_futex_unlock - Futex variant of rt_mutex_unlock > * @lock: the rt_mutex to be unlocked > * > - * Returns: true/false indicating whether priority adjustment is > - * required or not. > + * Returns: true/false indicating whether we should call rt_mutex_postunlock(). Can this be rephrased to: "Returns true if preemption has been disabled and a call to rt_mutex_postunlock() is required (which will re-enable preemption)" -- Steve > */ > bool __sched rt_mutex_futex_unlock(struct rt_mutex *lock, > struct wake_q_head *wqh) > --- a/kernel/locking/rtmutex_common.h > +++ b/kernel/locking/rtmutex_common.h > @@ -111,7 +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_postunlock(struct wake_q_head *wake_q); > extern void rt_mutex_adjust_prio(struct task_struct *task); > > #ifdef CONFIG_DEBUG_RT_MUTEXES >