Skip to content

Commit

Permalink
OS-970 kpreemptpri should be lowered to maxclsyspri
Browse files Browse the repository at this point in the history
  • Loading branch information
bcantrill committed Feb 20, 2012
1 parent 6ccceed commit 75dc036
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions usr/src/uts/common/disp/disp.c
Expand Up @@ -23,6 +23,10 @@
* Use is subject to license terms.
*/

/*
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/

/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */

Expand Down Expand Up @@ -105,7 +109,7 @@ static void cpu_resched(cpu_t *cp, pri_t tpri);
/*
* If this is set, only interrupt threads will cause kernel preemptions.
* This is done by changing the value of kpreemptpri. kpreemptpri
* will either be the max sysclass pri + 1 or the min interrupt pri.
* will either be the max sysclass pri or the min interrupt pri.
*/
int only_intr_kpreempt;

Expand Down Expand Up @@ -252,7 +256,23 @@ dispinit(void)
maxglobpri = cl_maxglobpri;
}
}
kpreemptpri = (pri_t)v.v_maxsyspri + 1;

/*
* Historically, kpreemptpri was set to v_maxsyspri + 1 -- which is
* to say, maxclsyspri + 1. However, over time, the system has used
* more and more asynchronous kernel threads, with an increasing number
* of these doing work on direct behalf of higher-level software (e.g.,
* network processing). This has led to potential priority inversions:
* threads doing low-priority lengthy kernel work can effectively
* delay kernel-level processing of higher-priority data. To minimize
* such inversions, we set kpreemptpri to be v_maxsyspri; anything in
* the kernel that runs at maxclsyspri will therefore induce kernel
* preemption, and this priority should be used if/when an asynchronous
* thread (or, as is often the case, task queue) is performing a task
* on behalf of higher-level software (or any task that is otherwise
* latency-sensitve).
*/
kpreemptpri = (pri_t)v.v_maxsyspri;
if (kpqpri == KPQPRI)
kpqpri = kpreemptpri;

Expand Down

0 comments on commit 75dc036

Please sign in to comment.