Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752929AbbBWShX (ORCPT ); Mon, 23 Feb 2015 13:37:23 -0500 Received: from smtprelay0010.hostedemail.com ([216.40.44.10]:53386 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752489AbbBWShW (ORCPT ); Mon, 23 Feb 2015 13:37:22 -0500 X-Session-Marker: 6E657665747340676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::,RULES_HIT:41:355:379:421: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:2691:2692:2693:2904:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:5007:6261:7875:7903:10004:10400:10471:10848:10967:11026:11232:11658:11914:12198:12294:12296:12438:12517:12519:12740:13141:13161:13229:13230:13255: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:0:0 X-HE-Tag: art45_5d29f6fdead48 X-Filterd-Recvd-Size: 3079 Date: Mon, 23 Feb 2015 13:37:19 -0500 From: Steven Rostedt To: Thavatchai Makphaibulchoke Cc: linux-kernel@vger.kernel.org, mingo@redhat.com, tglx@linutronix.de, linux-rt-users@vger.kernel.org Subject: Re: [PATCH 3.14.25-rt22 1/2] rtmutex Real-Time Linux: Fixing kernel BUG at kernel/locking/rtmutex.c:997! Message-ID: <20150223133719.2b7c604e@gandalf.local.home> In-Reply-To: <1424395866-81589-2-git-send-email-tmac@hp.com> References: <1424395866-81589-1-git-send-email-tmac@hp.com> <1424395866-81589-2-git-send-email-tmac@hp.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: 2305 Lines: 56 On Thu, 19 Feb 2015 18:31:05 -0700 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. > > This could result in an incorrect deadlock detection in function > rt_mutex_adjust_prio_chain(), causing thread to be killed and possibly leading > up to a system hang. > > Here is the approach taken: when calling from an interrupt handler, instead of > attributing ownership to the interrupted task, use a reserved task_struct value > to indicate that the owner is a interrupt handler. This approach avoids the > incorrect deadlock detection. > > This also includes changes in several function in rtmutex.c now that the lock's > requester may be a interrupt handler, not a real task struct. This impacts > the way how the lock is acquired and prioritized and decision whether to do > the house keeping functions required for a real task struct. > > The reserved task_struct values for interrupt handler are > > current | 0x2 > > where current is the task_struct value of the interrupted task. > > Since IH will both acquire and release the lock only during an interrupt > handling, during which current is not changed, the reserved task_struct value > for an IH should be distinct from another instances of IH on a different cpu. > > Kernel version 3.14.25 + patch-3.14.25-rt22 > > Signed-off-by: T. Makphaibulchoke OK, I believe I understand the issue. Perhaps it would be much better to create a fake task per CPU that we use when grabbing locks in interrupt mode. And make these have a priority of 0 (highest), since they can not be preempted, they do have such a priority. Then in the fast trylock and unlock code, we can add: struct task_struct *curr = current; if (unlikely(in_irq())) curr = this_cpu_read(irq_task); This way the priority inheritance will stop when it hits this task (no need to boost a task of highest priority), and we can leave that code alone. -- 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/