From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 9 20:32:31 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5E7F61065744 for ; Mon, 9 Apr 2012 20:32:31 +0000 (UTC) (envelope-from sushanth_rai@yahoo.com) Received: from nm4.bullet.mail.sp2.yahoo.com (nm4.bullet.mail.sp2.yahoo.com [98.139.91.74]) by mx1.freebsd.org (Postfix) with SMTP id 340A68FC20 for ; Mon, 9 Apr 2012 20:32:31 +0000 (UTC) Received: from [98.139.91.65] by nm4.bullet.mail.sp2.yahoo.com with NNFMP; 09 Apr 2012 20:32:25 -0000 Received: from [98.139.44.82] by tm5.bullet.mail.sp2.yahoo.com with NNFMP; 09 Apr 2012 20:32:25 -0000 Received: from [127.0.0.1] by omp1019.access.mail.sp2.yahoo.com with NNFMP; 09 Apr 2012 20:32:25 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 449626.47445.bm@omp1019.access.mail.sp2.yahoo.com Received: (qmail 66317 invoked by uid 60001); 9 Apr 2012 20:32:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1334003544; bh=JdtMGe22L7R3Gy/cpoHTh+DbYKz6tI3BVrUWneJEXZE=; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=kP2cTt1DjvZAzBxV1qNKCoSNWt7vg692nTf7u/1SmbRdokLKOgi7k859EtaQzNV/pYxvS4zJvTNqgaEdiRc0B8sKGYDnXVsqADereabYhxV52FKiCWqRZZalefBEqnCmEzTbczMGrBiDlq24UaWhIF6cyPMjgQo0rKlrNZ/BV6c= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=UcAGA4iqHGT7d4XvQnxXCu4ODqGqZQdt+n34jpPA+stchbN5Bk6DAXtPAdExZxjr7cexoZbM9Msm6A4k4ToLlK2HMq1C5mi4BeIvGIzMq6bva8iUceu1r8CVSxJ45O7lCzO2Fg4rTBvRNt8Z0XapjAdlzaOBjHCJVnb7+y43Nts=; X-YMail-OSG: 6AkPAYEVM1mbP7V5VgDv8hjzjbp6Df2CDw4XaXd5_k_aODY eSpnPHsSYOE3NAZHyHg9g9HKlqPi6qAKX7pfmLZZJFIOYvriMo87i1KTupTV DgcBI8K5S7iqYBsV1wXwRD2y_q5BgIGC4XUm_VestHdUAm.bwADywkQIWmR_ br7MtoPCmjDtzTWBOO8kiDiNVIzYeFcvszp8bO_SbIjwCnMcQEdSEB4rtnxH qSVhHkvY0iDTIT5dNOsMr6jT_TTK39YnH.RPGVnU.qAUGvB9.RyWL86ezpRA VGyn4QTe4X3IjGYmHCGZoZmgzYqsKraqcllLFwD4PeR3T18DxyA3dCu75N4F FnISKhf1kpJM6EqBaaOfDb8ZH3bdNXD9D3CSzBfV2VWpug1huH2nC4ZXVJXV qI.piCm52bxa4OYkK69sCPgghM03OuaxuEp8Dn3XoUU_OGx1xWguqKze0IaL fytMDkoI- Received: from [209.119.38.67] by web180010.mail.gq1.yahoo.com via HTTP; Mon, 09 Apr 2012 13:32:24 PDT X-Mailer: YahooMailClassic/15.0.5 YahooMailWebService/0.8.117.340979 Message-ID: <1334003544.57349.YahooMailClassic@web180010.mail.gq1.yahoo.com> Date: Mon, 9 Apr 2012 13:32:24 -0700 (PDT) From: Sushanth Rai To: John Baldwin In-Reply-To: <201204091437.55505.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org Subject: Re: Startvation of realtime piority threads X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Apr 2012 20:32:31 -0000 I'm using stock 7.2. The priorities as defined in priority.h are in this ra= nge:=0A=0A/*=0A * Priorities range from 0 to 255, but differences of less t= hen 4 (RQ_PPQ)=0A * are insignificant. Ranges are as follows:=0A *=0A * In= terrupt threads: 0 - 63=0A * Top half kernel threads: 64 - 12= 7=0A * Realtime user threads: 128 - 159=0A * Time sharing user thread= s: 160 - 223=0A * Idle user threads: 224 - 255=0A *=0A * XXX If= /When the specific interrupt thread and top half thread ranges=0A * disappe= ar, a larger range can be used for user processes.=0A */=0A=0AThe trouble i= s with vm_waitpfault(), which explicitly sleeps at PUSER.=0A=0A=0ASushanth= =0A=0A--- On Mon, 4/9/12, John Baldwin wrote:=0A=0A> From= : John Baldwin =0A> Subject: Re: Startvation of realtime p= iority threads=0A> To: "Sushanth Rai" =0A> Cc: free= bsd-hackers@freebsd.org=0A> Date: Monday, April 9, 2012, 11:37 AM=0A> On Mo= nday, April 09, 2012 2:08:50 pm=0A> Sushanth Rai wrote:=0A> > I'm on 7.2. s= ched_sleep() on 7.2 just records the sleep=0A> time. That's why I =0A> thou= gh _sleep might the right place to do the check.=0A> =0A> Nah, sched_sleep(= ) is more accurate since the sleep priority=0A> can have other =0A> side ef= fects.=0A> =0A> Hmm, in stock 7.2, the rtprio range is below things like=0A= > PVM, etc., so that=0A> shouldn't actually be buggy in that regard.=A0 I f= ixed=0A> this in 9.0 and HEAD=0A> when I moved the rtprio range up above th= e kernel sleep=0A> priorities.=A0 Are=0A> you using local patches to 7.2 to= raise the priority of=0A> rtprio threads?=0A> =0A> > Thanks,=0A> > Sushant= h=0A> > =0A> > --- On Mon, 4/9/12, John Baldwin =0A> wrote= :=0A> > =0A> > > From: John Baldwin =0A> > > Subject: Re: = Startvation of realtime piority=0A> threads=0A> > > To: "Sushanth Rai" =0A> > > Cc: freebsd-hackers@freebsd.org=0A> > > Date: = Monday, April 9, 2012, 9:17 AM=0A> > > On Thursday, April 05, 2012 9:08:24= =0A> > > pm Sushanth Rai wrote:=0A> > > > I understand the downside of badl= y written=0A> realtime=0A> > > app.=A0 In my case =0A> > > application runs= in userspace without making much=0A> syscalls=0A> > > and by all means it = =0A> > > is a well behaved application. Yes, I can wire=0A> memory,=0A> > >= change the application =0A> > > to use mutex instead of spinlock and those= changes=0A> should=0A> > > help but they are =0A> > > still working around= the problem. I still believe=0A> kernel=0A> > > should not lower the =0A> = > > realtime priority when blocking on resources. This=0A> can lead=0A> > >= to priority =0A> > > inversion, especially since these threads run at=0A> = fixed=0A> > > priorities and kernel =0A> > > doesn't muck with them.=0A> > = > >=A0 =0A> > > > As you suggested _sleep() should not adjust=0A> the=0A> >= > priorities for realtime =0A> > > threads. =0A> > > =0A> > > Hmm, sched_s= leep() for both SCHED_4BSD and=0A> SCHED_ULE already=0A> > > does the right= =0A> > > thing here in HEAD.=0A> > > =0A> > >=A0 =A0=A0=A0if=0A> (PRI_BASE(= td->td_pri_class) !=3D=0A> > > PRI_TIMESHARE)=0A> > >=A0 =A0 =A0 =A0=A0=A0r= eturn;=0A> > > =0A> > > Which OS version did you see this on?=0A> > > =0A> = > > -- =0A> > > John Baldwin=0A> > > =0A> > =0A> =0A> -- =0A> John Baldwin= =0A>