Date: Fri, 14 Jan 2011 17:06:54 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r217410 - in head/sys: kern sys Message-ID: <201101141706.p0EH6sXq094823@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101141706.p0EH6sXq094823>