From owner-cvs-all@FreeBSD.ORG Thu Dec 30 20:59:22 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E125016A4D0 for ; Thu, 30 Dec 2004 20:59:22 +0000 (GMT) Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by mx1.FreeBSD.org (Postfix) with ESMTP id F422443D1F for ; Thu, 30 Dec 2004 20:59:21 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: (qmail 1872 invoked from network); 30 Dec 2004 20:59:21 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 30 Dec 2004 20:59:21 -0000 Received: from [10.50.41.243] (gw1.twc.weather.com [216.133.140.1]) (authenticated bits=0) by server.baldwin.cx (8.12.11/8.12.11) with ESMTP id iBUKxEvP012148; Thu, 30 Dec 2004 15:59:15 -0500 (EST) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: src-committers@FreeBSD.org Date: Thu, 30 Dec 2004 15:56:24 -0500 User-Agent: KMail/1.6.2 References: <200412302052.iBUKqi2T045071@repoman.freebsd.org> In-Reply-To: <200412302052.iBUKqi2T045071@repoman.freebsd.org> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200412301556.24858.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx cc: cvs-src@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/kern sched_4bsd.c sched_ule.c subr_turnstile.c src/sys/sys proc.h sched.h turnstile.h X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Dec 2004 20:59:23 -0000 On Thursday 30 December 2004 03:52 pm, John Baldwin wrote: > jhb 2004-12-30 20:52:44 UTC > > FreeBSD src repository > > Modified files: > sys/kern sched_4bsd.c sched_ule.c subr_turnstile.c > sys/sys proc.h sched.h turnstile.h > Log: > Rework the interface between priority propagation (lending) and the > schedulers a bit to ensure more correct handling of priorities and fewer > priority inversions: > - Add two functions to the sched(9) API to handle priority lending: > sched_lend_prio() and sched_unlend_prio(). The turnstile code uses > these functions to ask the scheduler to lend a thread a set priority and to > tell the scheduler when it thinks it is ok for a thread to stop borrowing > priority. The unlend case is slightly complex in that the turnstile code > tells the scheduler what the minimum priority of the thread needs to be to > satisfy the requirements of any other threads blocked on locks owned by the > thread in question. The scheduler then decides where the thread can go > back to normal mode (if it's normal priority is high enough to satisfy the > pending lock requests) or it it should continue to use the priority > specified to the sched_unlend_prio() call. This involves adding a new > per-thread flag TDF_BORROWING that replaces the ULE-only kse flag for > priority elevation. > - Schedulers now refuse to lower the priority of a thread that is > currently borrowing another therad's priority. > - If a scheduler changes the priority of a thread that is currently > sitting on a turnstile, it will call a new function turnstile_adjust() to > inform the turnstile code of the change. This function resorts the thread > on the priority list of the turnstile if needed, and if the thread ends up > at the head of the list (due to having the highest priority) and its > priority was raised, then it will propagate that new priority to the owner > of the lock it is blocked on. > > Some additional fixes specific to the 4BSD scheduler include: > - Common code for updating the priority of a thread when the user > priority of its associated kse group has been consolidated in a new static > function resetpriority_thread(). One change to this function is that it > will now only adjust the priority of a thread if it already has a time > sharing priority, thus preserving any boosts from a tsleep() until the > thread returns to userland. Also, resetpriority() no longer calls > maybe_resched() on each thread in the group. Instead, the code calling > resetpriority() is responsible for calling resetpriority_thread() on any > threads that need to be updated. > - schedcpu() now uses resetpriority_thread() instead of just calling > sched_prio() directly after it updates a kse group's user priority. > - sched_clock() now uses resetpriority_thread() rather than writing > directly to td_priority. > - sched_nice() now updates all the priorities of the threads after the > group priority has been adjusted. > > Discussed with: bde > Reviewed by: ups, jeffr > Tested on: 4bsd, ule > Tested on: i386, alpha, sparc64 I just noticed while committing this that I lost part of the recent change to ULE to handle priority elevation in that it doesn't reevaluate a kse's slice after ending priority lending. I will work up a patch for this and test it shortly followed by a commit once all is well. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org