From owner-svn-src-head@FreeBSD.ORG Fri Jan 14 17:06:54 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6999610656A6; Fri, 14 Jan 2011 17:06:54 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 57D1A8FC34; Fri, 14 Jan 2011 17:06:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p0EH6sae094828; Fri, 14 Jan 2011 17:06:54 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EH6sXq094823; Fri, 14 Jan 2011 17:06:54 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201101141706.p0EH6sXq094823@svn.freebsd.org> From: John Baldwin Date: Fri, 14 Jan 2011 17:06:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217410 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 17:06:54 -0000 Author: jhb Date: Fri Jan 14 17:06:54 2011 New Revision: 217410 URL: http://svn.freebsd.org/changeset/base/217410 Log: Rework realtime priority support: - Move the realtime priority range up above kernel sleep priorities and just below interrupt thread priorities. - Contract the interrupt and kernel sleep priority ranges a bit so that the timesharing priority band can be increased. The new timeshare range is now slightly larger than the old realtime + timeshare ranges. - Change the ULE scheduler to no longer use realtime priorities for interactive threads. Instead, the larger timeshare range is now split into separate subranges for interactive and non-interactive ("batch") threads. The end result is that interactive threads and non-interactive threads still use the same priority ranges as before, but realtime threads now have a separate, dedicated priority range. - Do not modify the priority of non-timeshare threads in sched_sleep() or via cv_broadcastpri(). Realtime and idle priority threads will no longer have their priorities affected by sleeping in the kernel. Reviewed by: jeff Modified: head/sys/kern/sched_4bsd.c head/sys/kern/sched_ule.c head/sys/kern/subr_sleepqueue.c head/sys/sys/priority.h Modified: head/sys/kern/sched_4bsd.c ============================================================================== --- head/sys/kern/sched_4bsd.c Fri Jan 14 16:42:13 2011 (r217409) +++ head/sys/kern/sched_4bsd.c Fri Jan 14 17:06:54 2011 (r217410) @@ -908,7 +908,7 @@ sched_sleep(struct thread *td, int pri) THREAD_LOCK_ASSERT(td, MA_OWNED); td->td_slptick = ticks; td->td_sched->ts_slptime = 0; - if (pri) + if (pri != 0 && PRI_BASE(td->td_pri_class) == PRI_TIMESHARE) sched_prio(td, pri); if (TD_IS_SUSPENDED(td) || pri >= PSOCK) td->td_flags |= TDF_CANSWAP; Modified: head/sys/kern/sched_ule.c ============================================================================== --- head/sys/kern/sched_ule.c Fri Jan 14 16:42:13 2011 (r217409) +++ head/sys/kern/sched_ule.c Fri Jan 14 17:06:54 2011 (r217410) @@ -118,11 +118,17 @@ static struct td_sched td_sched0; /* * Priority ranges used for interactive and non-interactive timeshare - * threads. Interactive threads use realtime priorities. - */ -#define PRI_MIN_INTERACT PRI_MIN_REALTIME -#define PRI_MAX_INTERACT PRI_MAX_REALTIME -#define PRI_MIN_BATCH PRI_MIN_TIMESHARE + * threads. The timeshare priorities are split up into four ranges. + * The first range handles interactive threads. The last three ranges + * (NHALF, x, and NHALF) handle non-interactive threads with the outer + * ranges supporting nice values. + */ +#define PRI_TIMESHARE_RANGE (PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE + 1) +#define PRI_INTERACT_RANGE ((PRI_TIMESHARE_RANGE - SCHED_PRI_NRESV) / 2) + +#define PRI_MIN_INTERACT PRI_MIN_TIMESHARE +#define PRI_MAX_INTERACT (PRI_MIN_TIMESHARE + PRI_INTERACT_RANGE - 1) +#define PRI_MIN_BATCH (PRI_MIN_TIMESHARE + PRI_INTERACT_RANGE) #define PRI_MAX_BATCH PRI_MAX_TIMESHARE /* @@ -1893,6 +1899,8 @@ sched_sleep(struct thread *td, int prio) td->td_slptick = ticks; if (TD_IS_SUSPENDED(td) || prio >= PSOCK) td->td_flags |= TDF_CANSWAP; + if (PRI_BASE(td->td_pri_class) != PRI_TIMESHARE) + return; if (static_boost == 1 && prio) sched_prio(td, prio); else if (static_boost && td->td_priority > static_boost) Modified: head/sys/kern/subr_sleepqueue.c ============================================================================== --- head/sys/kern/subr_sleepqueue.c Fri Jan 14 16:42:13 2011 (r217409) +++ head/sys/kern/subr_sleepqueue.c Fri Jan 14 17:06:54 2011 (r217410) @@ -745,7 +745,8 @@ sleepq_resume_thread(struct sleepqueue * /* Adjust priority if requested. */ MPASS(pri == 0 || (pri >= PRI_MIN && pri <= PRI_MAX)); - if (pri != 0 && td->td_priority > pri) + if (pri != 0 && td->td_priority > pri && + PRI_BASE(td->td_pri_class) == PRI_TIMESHARE) sched_prio(td, pri); /* Modified: head/sys/sys/priority.h ============================================================================== --- head/sys/sys/priority.h Fri Jan 14 16:42:13 2011 (r217409) +++ head/sys/sys/priority.h Fri Jan 14 17:06:54 2011 (r217410) @@ -67,10 +67,10 @@ * Priorities range from 0 to 255, but differences of less then 4 (RQ_PPQ) * are insignificant. Ranges are as follows: * - * Interrupt threads: 0 - 63 - * Top half kernel threads: 64 - 127 - * Realtime user threads: 128 - 159 - * Time sharing user threads: 160 - 223 + * Interrupt threads: 0 - 47 + * Realtime user threads: 48 - 79 + * Top half kernel threads: 80 - 119 + * Time sharing user threads: 120 - 223 * Idle user threads: 224 - 255 * * XXX If/When the specific interrupt thread and top half thread ranges @@ -81,7 +81,7 @@ #define PRI_MAX (255) /* Lowest priority. */ #define PRI_MIN_ITHD (PRI_MIN) -#define PRI_MAX_ITHD (PRI_MIN_KERN - 1) +#define PRI_MAX_ITHD (PRI_MIN_REALTIME - 1) #define PI_REALTIME (PRI_MIN_ITHD + 0) #define PI_AV (PRI_MIN_ITHD + 4) @@ -92,8 +92,11 @@ #define PI_SOFT (PRI_MIN_ITHD + 24) #define PI_SWI(x) (PI_SOFT + (x) * RQ_PPQ) -#define PRI_MIN_KERN (64) -#define PRI_MAX_KERN (PRI_MIN_REALTIME - 1) +#define PRI_MIN_REALTIME (48) +#define PRI_MAX_REALTIME (PRI_MIN_KERN - 1) + +#define PRI_MIN_KERN (80) +#define PRI_MAX_KERN (PRI_MIN_TIMESHARE - 1) #define PSWP (PRI_MIN_KERN + 0) #define PVM (PRI_MIN_KERN + 4) @@ -106,10 +109,7 @@ #define PLOCK (PRI_MIN_KERN + 32) #define PPAUSE (PRI_MIN_KERN + 36) -#define PRI_MIN_REALTIME (128) -#define PRI_MAX_REALTIME (PRI_MIN_TIMESHARE - 1) - -#define PRI_MIN_TIMESHARE (160) +#define PRI_MIN_TIMESHARE (120) #define PRI_MAX_TIMESHARE (PRI_MIN_IDLE - 1) #define PUSER (PRI_MIN_TIMESHARE)