Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751486AbbDPPKx (ORCPT ); Thu, 16 Apr 2015 11:10:53 -0400 Received: from smtprelay0011.hostedemail.com ([216.40.44.11]:57682 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750715AbbDPPKp (ORCPT ); Thu, 16 Apr 2015 11:10:45 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 30,2,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1183:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2693:2910:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:4470:5007:6119:6261:6691:7875:7901:7903:8660:9707:10010:10400:10848:10967:11026:11232:11473:11658:11914:12043:12296:12438:12517:12519:12663:12740:13148:13161:13229:13230:14096:14097: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:1:0 X-HE-Tag: beef40_6407d7c2bb08 X-Filterd-Recvd-Size: 3277 Date: Thu, 16 Apr 2015 11:10:41 -0400 From: Steven Rostedt To: Jan Kiszka Cc: Sebastian Andrzej Siewior , RT , Linux Kernel Mailing List Subject: Re: [PATCH RT 3.18] ring-buffer: Mark irq_work as HARD_IRQ to prevent deadlocks Message-ID: <20150416111041.66043164@gandalf.local.home> In-Reply-To: <552FC72A.8060709@siemens.com> References: <552FC1FE.4020406@siemens.com> <552FC6B1.1040000@linutronix.de> <552FC72A.8060709@siemens.com> 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: 2497 Lines: 59 On Thu, 16 Apr 2015 16:28:58 +0200 Jan Kiszka wrote: > On 2015-04-16 16:26, Sebastian Andrzej Siewior wrote: > > On 04/16/2015 04:06 PM, Jan Kiszka wrote: > >> ftrace may trigger rb_wakeups while holding pi_lock which will also be > >> requested via trace_...->...->ring_buffer_unlock_commit->...-> > >> irq_work_queue->raise_softirq->try_to_wake_up. This quickly causes > >> deadlocks when trying to use ftrace under -rt. > >> > >> Resolve this by marking the ring buffer's irq_work as HARD_IRQ. > >> > >> Signed-off-by: Jan Kiszka > >> --- > >> > >> I'm not yet sure if this doesn't push work into hard-irq context that > >> is better not done there on -rt. > > > > everything should be done in the soft-irq. > > > >> > >> I'm also not sure if there aren't more such cases, given that -rt turns > >> the default irq_work wakeup policy around. But maybe we are lucky. > > > > The only thing that is getting done in the hardirq is the FULL_NO_HZ > > thingy. I would be _very_ glad if we could keep it that way. tracing is special, even more so than NO_HZ_FULL, as it also traces that as well (and even RCU). Tracing the kernel is like a debugger. Ideally, it would not be part of the kernel, but just an external observer. Without special hardware that is not the case, so we try to be outside the main system as much as possible. > > Then - to my current understanding - we need an NMI-safe trigger for > soft-irq work. Is there anything like this existing already? Or can we > still use the IPI-based kick without actually doing the work in hard-irq > context? > The reason why it uses irq_work() is because a simple wakeup can deadlock the system if called by the tracing infrastructure (as we see raise_softirq() does too). But yeah, there's no real need to have the ring buffer irq work handler run from hardirq context. The only requirement is that you can not do the raise from the irq_work_queue call. If you want to have the hardirq work handle do the raise softirq, that's fine. Perhaps that's the solution? Have all irq_work_queue() always trigger the hard irq, but the hard irq may just raise a softirq or it will call the handler directly if IRQ_WORK_HARD_IRQ is set. -- 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/