diff options
author | jake <jake@FreeBSD.org> | 2001-02-26 23:27:35 +0000 |
---|---|---|
committer | jake <jake@FreeBSD.org> | 2001-02-26 23:27:35 +0000 |
commit | 3d95b58cac052a546c50e19bcf2ffaee25d0b127 (patch) | |
tree | 008ddc14d7d265be71f0919ec666ec624e507369 /sys/kern | |
parent | 88383c1fc469dc0031b59f9f8ce8c41a8bb37d96 (diff) | |
download | FreeBSD-src-3d95b58cac052a546c50e19bcf2ffaee25d0b127.zip FreeBSD-src-3d95b58cac052a546c50e19bcf2ffaee25d0b127.tar.gz |
Initialize native priority to PRI_MAX. It was usually 0 which made a
process's priority go through the roof when it released a (contested)
mutex. Only set the native priority in mtx_lock if hasn't already
been set.
Reviewed by: jhb
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/init_main.c | 1 | ||||
-rw-r--r-- | sys/kern/kern_fork.c | 1 | ||||
-rw-r--r-- | sys/kern/kern_mutex.c | 13 | ||||
-rw-r--r-- | sys/kern/subr_turnstile.c | 13 | ||||
-rw-r--r-- | sys/kern/subr_witness.c | 13 |
5 files changed, 8 insertions, 33 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 8c59342..4231390 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -306,6 +306,7 @@ proc0_init(void *dummy __unused) p->p_nice = NZERO; p->p_pri.pri_class = PRI_TIMESHARE; p->p_pri.pri_level = PVM; + p->p_pri.pri_native = PRI_MAX; p->p_pri.pri_user = PUSER; p->p_peers = 0; diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 9f19669..e99ef22 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -357,6 +357,7 @@ again: p2 = newproc; p2->p_intr_nesting_level = 0; + p2->p_pri.pri_native = PRI_MAX; p2->p_stat = SIDL; /* protect against others */ p2->p_pid = trypid; LIST_INSERT_HEAD(&allproc, p2, p_list); diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index 2e7ef30..fbee435 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -339,17 +339,6 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) "_mtx_lock_sleep: %s contested (lock=%p) at %s:%d", m->mtx_description, (void *)m->mtx_lock, file, line); - /* - * Save our priority. Even though p_nativepri is protected by - * sched_lock, we don't obtain it here as it can be expensive. - * Since this is the only place p_nativepri is set, and since two - * CPUs will not be executing the same process concurrently, we know - * that no other CPU is going to be messing with this. Also, - * p_nativepri is only read when we are blocked on a mutex, so that - * can't be happening right now either. - */ - p->p_pri.pri_native = p->p_pri.pri_level; - while (!_obtain_lock(m, p)) { uintptr_t v; struct proc *p1; @@ -437,6 +426,8 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) p->p_blocked = m; p->p_mtxname = m->mtx_description; p->p_stat = SMTX; + if (p->p_pri.pri_native == PRI_MAX) + p->p_pri.pri_native = p->p_pri.pri_level; propagate_priority(p); if ((opts & MTX_QUIET) == 0) diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c index 2e7ef30..fbee435 100644 --- a/sys/kern/subr_turnstile.c +++ b/sys/kern/subr_turnstile.c @@ -339,17 +339,6 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) "_mtx_lock_sleep: %s contested (lock=%p) at %s:%d", m->mtx_description, (void *)m->mtx_lock, file, line); - /* - * Save our priority. Even though p_nativepri is protected by - * sched_lock, we don't obtain it here as it can be expensive. - * Since this is the only place p_nativepri is set, and since two - * CPUs will not be executing the same process concurrently, we know - * that no other CPU is going to be messing with this. Also, - * p_nativepri is only read when we are blocked on a mutex, so that - * can't be happening right now either. - */ - p->p_pri.pri_native = p->p_pri.pri_level; - while (!_obtain_lock(m, p)) { uintptr_t v; struct proc *p1; @@ -437,6 +426,8 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) p->p_blocked = m; p->p_mtxname = m->mtx_description; p->p_stat = SMTX; + if (p->p_pri.pri_native == PRI_MAX) + p->p_pri.pri_native = p->p_pri.pri_level; propagate_priority(p); if ((opts & MTX_QUIET) == 0) diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 2e7ef30..fbee435 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -339,17 +339,6 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) "_mtx_lock_sleep: %s contested (lock=%p) at %s:%d", m->mtx_description, (void *)m->mtx_lock, file, line); - /* - * Save our priority. Even though p_nativepri is protected by - * sched_lock, we don't obtain it here as it can be expensive. - * Since this is the only place p_nativepri is set, and since two - * CPUs will not be executing the same process concurrently, we know - * that no other CPU is going to be messing with this. Also, - * p_nativepri is only read when we are blocked on a mutex, so that - * can't be happening right now either. - */ - p->p_pri.pri_native = p->p_pri.pri_level; - while (!_obtain_lock(m, p)) { uintptr_t v; struct proc *p1; @@ -437,6 +426,8 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) p->p_blocked = m; p->p_mtxname = m->mtx_description; p->p_stat = SMTX; + if (p->p_pri.pri_native == PRI_MAX) + p->p_pri.pri_native = p->p_pri.pri_level; propagate_priority(p); if ((opts & MTX_QUIET) == 0) |