Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753450AbbDGMmB (ORCPT ); Tue, 7 Apr 2015 08:42:01 -0400 Received: from smtprelay0212.hostedemail.com ([216.40.44.212]:40724 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752822AbbDGMl5 (ORCPT ); Tue, 7 Apr 2015 08:41:57 -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:2901:2904:3138:3139:3140:3141:3142:3355:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4250:4321:5007:6119:6261:7875:7903:10004:10400:10450:10455:10848:10967:11026:11232:11473:11658:11914:12043:12296:12438:12517:12519:12740:13255:13868:14096:14097:19904:19999:21080,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 X-HE-Tag: bite76_4b15f1c691544 X-Filterd-Recvd-Size: 3844 Date: Tue, 7 Apr 2015 08:41:54 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: Mike Galbraith , Thomas Gleixner , Thavatchai Makphaibulchoke , LKML , mingo@redhat.com, linux-rt-users Subject: Re: [PATCH v2 1/2] rtmutex Real-Time Linux: Fixing kernel BUG at kernel/locking/rtmutex.c:997! Message-ID: <20150407084154.74c01a6c@gandalf.local.home> In-Reply-To: <20150407120403.GN21418@twins.programming.kicks-ass.net> References: <1424395866-81589-1-git-send-email-tmac@hp.com> <1428369962-74723-1-git-send-email-tmac@hp.com> <1428369962-74723-2-git-send-email-tmac@hp.com> <1428407236.3152.81.camel@gmail.com> <20150407120403.GN21418@twins.programming.kicks-ass.net> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; 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 Content-Length: 2725 Lines: 81 On Tue, 7 Apr 2015 14:04:03 +0200 Peter Zijlstra wrote: > On Tue, Apr 07, 2015 at 01:47:16PM +0200, Mike Galbraith wrote: > > On Tue, 2015-04-07 at 13:23 +0200, Thomas Gleixner wrote: > > > On Mon, 6 Apr 2015, Thavatchai Makphaibulchoke wrote: > > > > > > > This patch fixes the problem that the ownership of a mutex acquired > > > > by an interrupt handler(IH) gets incorrectly attributed to the > > > > interrupted thread. > > > > > > An hard interrupt handler is not allowed to take a mutex. End of > > > story, nothing to fix here. > > > > Well, the patch that started this thread.. > > > > timers-do-not-raise-softirq-unconditionally.patch > > Aah, that is the problem.. > Yep, all this nonsense came from that patch and trying to get NO_HZ_FULL working with -rt. It's a bit ironic that the push to get NO_HZ_FULL into mainline came from our RT mini summit, but its implementation is broken on -rt :-p Ideally, we don't want to take mutexes in hard interrupt context. > @@ -1454,8 +1452,32 @@ static void run_timer_softirq(struct softirq_action *h) > */ > void run_local_timers(void) > { > + struct tvec_base *base = __this_cpu_read(tvec_bases); > + > hrtimer_run_queues(); > - raise_softirq(TIMER_SOFTIRQ); > + /* > + * We can access this lockless as we are in the timer > + * interrupt. If there are no timers queued, nothing to do in > + * the timer softirq. > + */ > +#ifdef CONFIG_PREEMPT_RT_FULL > + if (!spin_do_trylock(&base->lock)) { > + raise_softirq(TIMER_SOFTIRQ); > + return; > + } > +#endif > + if (!base->active_timers) > + goto out; > + > + /* Check whether the next pending timer has expired */ > + if (time_before_eq(base->next_timer, jiffies)) > + raise_softirq(TIMER_SOFTIRQ); > +out: > +#ifdef CONFIG_PREEMPT_RT_FULL > + rt_spin_unlock_after_trylock_in_irq(&base->lock); > +#endif > + /* The ; ensures that gcc won't complain in the !RT case */ > + ; > } > > That smells like something we should be able to do without a lock. > > If we use {READ,WRITE}_ONCE() on those two fields (->active_timers and > ->next_timer) we should be able to do this without the spinlock. > > Races here aren't really a problem I think, if you manage to install a > timer at the current jiffy and have already missed the tick you're in > the same boat. You get to wait for the next tick. I'll take a deeper look at this code too. If we can get rid of this hack, then we don't need the mutex-in-irq hack either. -- Steve -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/