From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034882AbcIZPkI (ORCPT ); Mon, 26 Sep 2016 11:40:08 -0400 Received: from merlin.infradead.org ([205.233.59.134]:36142 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1034803AbcIZPkF (ORCPT ); Mon, 26 Sep 2016 11:40:05 -0400 Date: Mon, 26 Sep 2016 17:39:59 +0200 From: Peter Zijlstra To: Steven Rostedt 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: <20160926153959.GG5016@twins.programming.kicks-ass.net> References: <20160926123213.851818224@infradead.org> <20160926124127.863639194@infradead.org> <20160926111511.1d963075@grimm.local.home> <20160926152228.GE5016@twins.programming.kicks-ass.net> <20160926113503.7d0528de@grimm.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160926113503.7d0528de@grimm.local.home> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 26, 2016 at 11:35:03AM -0400, Steven Rostedt wrote: > On Mon, 26 Sep 2016 17:22:28 +0200 > Peter Zijlstra wrote: > > > > > + /* > > > > + * 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? > > > > > > > Not sure I see your point. rt_mutex_futex_unlock() calls > > rt_mutex_slowunlock() which does the preempt_disable(), we then pass the > > return of that into deboost, which we pass into rt_mutex_postunlock() > > and everything should be balanced. > > Can we please add more comments explaining this. Having side effects of > functions disabling preemption, passing a bool saying that it did, and > needing to call another function (somewhat seemingly unrelated) to > re-enable preemption, just seems a bit of a stretch for maintainable > code. > > Especially now that the code after the spin_unlock(&hb->lock) is now a > critical section (preemption is disable). There's nothing obvious in > futex.c that says it is. > > Just think about looking at this code in another 5 years. Are you going > to remember all this? There's some cleanups later in the series that should clear this up.