From owner-freebsd-arch@FreeBSD.ORG Mon Dec 13 14:38:19 2010 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7D31710656A4 for ; Mon, 13 Dec 2010 14:38:19 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 4E42F8FC19 for ; Mon, 13 Dec 2010 14:38:19 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id F3F2446B35; Mon, 13 Dec 2010 09:38:18 -0500 (EST) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 0994E8A009; Mon, 13 Dec 2010 09:38:18 -0500 (EST) From: John Baldwin To: Peter Jeremy Date: Mon, 13 Dec 2010 09:38:04 -0500 User-Agent: KMail/1.13.5 (FreeBSD/7.3-CBSD-20101102; KDE/4.4.5; amd64; ; ) References: <201012101050.45214.jhb@freebsd.org> <20101211213918.GB21959@server.vk2pj.dyndns.org> In-Reply-To: <20101211213918.GB21959@server.vk2pj.dyndns.org> MIME-Version: 1.0 Message-Id: <201012130938.04746.jhb@freebsd.org> Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Mon, 13 Dec 2010 09:38:18 -0500 (EST) X-Virus-Scanned: clamav-milter 0.96.3 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.9 required=4.2 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bigwig.baldwin.cx Cc: arch@freebsd.org Subject: Re: Realtime thread priorities X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Dec 2010 14:38:19 -0000 On Saturday, December 11, 2010 4:39:18 pm Peter Jeremy wrote: > On 2010-Dec-10 10:50:45 -0500, John Baldwin wrote: > >The problem I am running into is that when a time-sharing thread goes to sleep > >in the kernel (waiting on select, socket data, tty, etc.) it actually ends up > >in the kernel priorities range (64 - 127). This means when it wakes up it > >will trump (and preempt) a real-time user thread even though these processes > >nominally have a priority down in the 160 - 223 range. We do drop the kernel > >sleep priority during userret(), but we don't recheck the scheduler queues to > >see if we should preempt the thread during userret(), so it effectively runs > >with the kernel sleep priority for the rest of the quantum while it is in > >userland. > > This may also explain the situation I'm seeing where idprio processes > are receiving more than "idle" time (see "idprio processes slowing > down system" in -hackers). Yes, this likely does explain that. We could fix that for just idle priority class threads in sched_userret() easily enough (just call mi_switch() if td->td_pri_class == PRI_CLASS_IDLE). > >2) (harder) make sched_userret() check the run queue to see if it should > >preempt when dropping the kernel sleep priority. > > IMHO, this is the "correct" solution but that needs to be tempered by > the additional overhead this might incur. The other concern (and reason I lean towards 1) is that this is also a feature that we depend on to favor interactive threads over compute-bound threads. -- John Baldwin