Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752613AbbD3R2q (ORCPT ); Thu, 30 Apr 2015 13:28:46 -0400 Received: from smtprelay0049.hostedemail.com ([216.40.44.49]:42962 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752549AbbD3R2p (ORCPT ); Thu, 30 Apr 2015 13:28:45 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 40,2.5,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::,RULES_HIT:41:355:379:541:599:800:960:967:973:988:989:1260:1263:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1543:1593:1594:1605:1711:1730:1747:1777:1792:1801:2194:2199:2393:2525:2553:2565:2682:2685:2689:2693:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3421:3622:3657:3865:3866:3867:3868:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4361:4362:4470:4605:5007:6117:6261:7514:7576:7875:7903:8599:8660:9010:9025:9108:9121:9388:10011:10400:10848:10967:11026:11232:11233:11253:11658:11854:11914:12043:12050:12198:12214:12295:12296:12438:12517:12519:12663:12740:12776:13095:13148:13230:14096:14097:21063: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: chess70_862c1517e9421 X-Filterd-Recvd-Size: 4891 Date: Thu, 30 Apr 2015 13:28:40 -0400 From: Steven Rostedt To: Mike Galbraith Cc: Ronny Meeus , linux-kernel@vger.kernel.org, Thomas Gleixner Subject: Re: Issue in PI boosting code in __sched_setscheduler Message-ID: <20150430132840.6d550b64@gandalf.local.home> In-Reply-To: <1430413502.3180.157.camel@gmail.com> References: <1430413502.3180.157.camel@gmail.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: 4119 Lines: 99 On Thu, 30 Apr 2015 19:05:02 +0200 Mike Galbraith wrote: > LKML is a very high volume list, if you're seeing problems that were > introduced by a particular patch, it's a good idea to CC the author of > that patch. > > /me adds CC, and tags (again) to take a peek. Thanks Mike, although I'm not the author of the patch ;-) See the "From:" tag at the beginning of the patch. > > On Tue, 2015-03-17 at 21:10 +0100, Ronny Meeus wrote: > > I'm using a patched kernel I get from Monta-Vista, it is based on the > > 3.10 kernel with some RT patches. > > We ported an application from pSOS RTOS to Linux using the > > Xenomai-Mercury (=library to map pSOS task to POSIX threads). > > > > One of the patches applied to our kernel is: > > "[PATCH RT 3/4] sched: Consider pi boosting in setscheduler" (see > > https://lkml.org/lkml/2012/12/22/77). > > I see that the code is today also present in the mainline kernel (for > > example in 3.19). > > > > We have several threads running in the real-time priority domain. > > ThreadA: running at prio -33. > > ThreadB: running at prio -35. > > > > ThreadA obtains a PI protected mutex and continues to execute code in > > the critical section. > > ThreadB tries to obtain the same mutex and this makes the kernel boost > > the priority of ThreadA to -35. > > > > While holding the lock, ThreadA changes its priority to -99 to > > implement a critical section (Xenomai internals). After a short > > period, the latter critical section is left and the call to lower the > > priority to its original one (-33) is issued to the kernel. > > > > I would expect that at this moment the priority is lowered to -35 > > since this is the priority of the thread waiting on the mutex (TheadB) > > but instead the priority is not changed and stays at -99. (Because of > > the patch mentioned before. The relevant part of the code is also > > copied below). > > Since the critical section takes rather long, we start to miss > > important events processed by higher priority threads. > > > > If I disable the code introduced by the patch, the events are not missed. > > > > My question about this behavior: According to me it is not correct to > > keep the thread at the higher priority and "assume" that the critical > > section will not take long anymore. > > In my opinion the only correct solution is to lower the priority of > > the calling thread to the highest prio of "the new-priority (-33)" and > > "the priority of the tasks waiting on the mutex (-35)". I agree, the proper solution is to change it back to -35. And we have a way to do that too. I think I can come up with a solution. -- Steve > > > > Thanks. > > > > Best regards, > > Ronny > > > > > > 3408 static int __sched_setscheduler(struct task_struct *p, > > 3409 const struct sched_attr *attr, > > 3410 bool user) > > > > 3596 /* > > 3597 * Special case for priority boosted tasks. > > 3598 * > > 3599 * If the new priority is lower or equal (user space view) > > 3600 * than the current (boosted) priority, we just store the new > > 3601 * normal parameters and do not touch the scheduler class and > > 3602 * the runqueue. This will be done when the task deboost > > 3603 * itself. > > 3604 */ > > 3605 if (rt_mutex_check_prio(p, newprio)) { > > 3606 __setscheduler_params(p, attr); > > 3607 task_rq_unlock(rq, p, &flags); > > 3608 return 0; > > 3609 } > > -- > > 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/ > -- 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/