From a29140025a618a3e83976d92511f9fd927f09680 Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Wed, 22 May 2024 17:29:22 +0200 Subject: [PATCH] Internal scheduling priorities: Always use symbolic ones Replace priorities specified by a base priority and some hardcoded offset value by symbolic constants. Hardcoded offsets prevent changing the difference between priorities without changing their relative ordering, and is generally a dangerous practice since the resulting priority may inadvertently belong to a different selection policy's range. Since RQ_PPQ is 4, differences of less than 4 are insignificant, so just remove them. These small differences have not been changed for years, so it is likely they have no real meaning (besides having no practical effect). One can still consult the changes history to recover them if ever needed. No functional change (intended). MFC after: 1 month Event: Kitchener-Waterloo Hackathon 202506 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45390 (cherry picked from commit 8ecc41918066422d6788a67251b22d11a6efeddf) --- sys/cam/ctl/ctl.c | 4 ++-- sys/dev/firewire/firewirereg.h | 2 +- sys/dev/iicbus/iiconf.h | 2 +- sys/dev/ppbus/lpt.c | 2 +- sys/dev/ppbus/ppbconf.h | 2 +- sys/dev/smbus/smbconf.h | 2 +- sys/dev/syscons/syscons.c | 2 +- sys/dev/vkbd/vkbd.c | 14 +++++++------- sys/fs/fuse/fuse_device.c | 2 +- sys/fs/fuse/fuse_io.c | 2 +- sys/fs/fuse/fuse_ipc.c | 4 ++-- sys/fs/nfs/nfs_commonsubs.c | 2 +- sys/fs/nfsserver/nfs_nfsdcache.c | 6 +++--- sys/fs/nfsserver/nfs_nfsdstate.c | 4 ++-- sys/fs/smbfs/smbfs_io.c | 2 +- sys/kern/kern_rmlock.c | 7 ++++--- sys/kern/subr_log.c | 2 +- sys/kern/sysv_msg.c | 4 ++-- sys/kern/sysv_sem.c | 2 +- sys/kern/vfs_bio.c | 7 +++---- sys/kern/vfs_vnops.c | 12 ++++++------ sys/net/if_tuntap.c | 8 ++++---- sys/netgraph/ng_device.c | 2 +- sys/sys/buf.h | 4 ++-- sys/ufs/ffs/ffs_softdep.c | 6 +++--- sys/ufs/ffs/ffs_vnops.c | 3 +-- sys/ufs/ufs/ufs_quota.c | 22 +++++++++++----------- 27 files changed, 65 insertions(+), 66 deletions(-) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index f22b6ae924b..0c2c21ba42f 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -13424,7 +13424,7 @@ ctl_work_thread(void *arg) CTL_DEBUG_PRINT(("ctl_work_thread starting\n")); thread_lock(curthread); - sched_prio(curthread, PUSER - 1); + sched_prio(curthread, PRI_MAX_KERN); thread_unlock(curthread); while (!softc->shutdown) { @@ -13494,7 +13494,7 @@ ctl_thresh_thread(void *arg) CTL_DEBUG_PRINT(("ctl_thresh_thread starting\n")); thread_lock(curthread); - sched_prio(curthread, PUSER - 1); + sched_prio(curthread, PRI_MAX_KERN); thread_unlock(curthread); while (!softc->shutdown) { diff --git a/sys/dev/firewire/firewirereg.h b/sys/dev/firewire/firewirereg.h index 4d2d282dd22..d17f7a15785 100644 --- a/sys/dev/firewire/firewirereg.h +++ b/sys/dev/firewire/firewirereg.h @@ -293,7 +293,7 @@ extern int firewire_debug; extern devclass_t firewire_devclass; extern int firewire_phydma_enable; -#define FWPRI ((PZERO + 8) | PCATCH) +#define FWPRI (PWAIT | PCATCH) #define CALLOUT_INIT(x) callout_init(x, 1 /* mpsafe */) diff --git a/sys/dev/iicbus/iiconf.h b/sys/dev/iicbus/iiconf.h index ccf1661bba7..2fe95c0e9f6 100644 --- a/sys/dev/iicbus/iiconf.h +++ b/sys/dev/iicbus/iiconf.h @@ -32,7 +32,7 @@ #include -#define IICPRI (PZERO+8) /* XXX sleep/wakeup queue priority */ +#define IICPRI (PWAIT) /* XXX sleep/wakeup queue priority */ #define LSB 0x1 diff --git a/sys/dev/ppbus/lpt.c b/sys/dev/ppbus/lpt.c index 644e0f08008..27cc7bb28f8 100644 --- a/sys/dev/ppbus/lpt.c +++ b/sys/dev/ppbus/lpt.c @@ -100,7 +100,7 @@ static int volatile lptflag = 1; #define LPINITRDY 4 /* wait up to 4 seconds for a ready */ #define LPTOUTINITIAL 10 /* initial timeout to wait for ready 1/10 s */ #define LPTOUTMAX 1 /* maximal timeout 1 s */ -#define LPPRI (PZERO+8) +#define LPPRI (PWAIT) #define BUFSIZE 1024 #define BUFSTATSIZE 32 diff --git a/sys/dev/ppbus/ppbconf.h b/sys/dev/ppbus/ppbconf.h index 0f6395121fb..66f45634ea6 100644 --- a/sys/dev/ppbus/ppbconf.h +++ b/sys/dev/ppbus/ppbconf.h @@ -63,7 +63,7 @@ /* * Parallel Port Bus sleep/wakeup queue. */ -#define PPBPRI (PZERO+8) +#define PPBPRI (PWAIT) /* * Parallel Port Chipset mode masks. diff --git a/sys/dev/smbus/smbconf.h b/sys/dev/smbus/smbconf.h index 4c646df20a3..a6c32059406 100644 --- a/sys/dev/smbus/smbconf.h +++ b/sys/dev/smbus/smbconf.h @@ -30,7 +30,7 @@ #include -#define SMBPRI (PZERO+8) /* XXX sleep/wakeup queue priority */ +#define SMBPRI (PWAIT) /* XXX sleep/wakeup queue priority */ #define n(flags) (~(flags) & (flags)) diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 0985f03e1cb..9769fafe7b6 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -1310,7 +1310,7 @@ sctty_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) if (i == sc->cur_scp->index) return 0; error = - tsleep(VTY_WCHAN(sc, i), (PZERO + 1) | PCATCH, "waitvt", 0); + tsleep(VTY_WCHAN(sc, i), PZERO | PCATCH, "waitvt", 0); return error; case VT_GETACTIVE: /* get active vty # */ diff --git a/sys/dev/vkbd/vkbd.c b/sys/dev/vkbd/vkbd.c index 3dbf64063e3..27a7e626fa6 100644 --- a/sys/dev/vkbd/vkbd.c +++ b/sys/dev/vkbd/vkbd.c @@ -82,7 +82,7 @@ MALLOC_DEFINE(M_VKBD, KEYBOARD_NAME, "Virtual AT keyboard"); #define VKBD_UNLOCK(s) mtx_unlock(&(s)->ks_lock) #define VKBD_LOCK_ASSERT(s, w) mtx_assert(&(s)->ks_lock, w) #define VKBD_SLEEP(s, f, d, t) \ - msleep(&(s)->f, &(s)->ks_lock, PCATCH | (PZERO + 1), d, t) + msleep(&(s)->f, &(s)->ks_lock, PCATCH | PZERO, d, t) #else #define VKBD_LOCK_DECL #define VKBD_LOCK_INIT(s) @@ -90,7 +90,7 @@ MALLOC_DEFINE(M_VKBD, KEYBOARD_NAME, "Virtual AT keyboard"); #define VKBD_LOCK(s) #define VKBD_UNLOCK(s) #define VKBD_LOCK_ASSERT(s, w) -#define VKBD_SLEEP(s, f, d, t) tsleep(&(s)->f, PCATCH | (PZERO + 1), d, t) +#define VKBD_SLEEP(s, f, d, t) tsleep(&(s)->f, PCATCH | PZERO, d, t) #endif #define VKBD_KEYBOARD(d) \ @@ -268,8 +268,8 @@ vkbd_dev_close(struct cdev *dev, int foo, int bar, struct thread *td) VKBD_SLEEP(state, ks_task, "vkbdc", 0); /* wakeup poll()ers */ - selwakeuppri(&state->ks_rsel, PZERO + 1); - selwakeuppri(&state->ks_wsel, PZERO + 1); + selwakeuppri(&state->ks_rsel, PZERO); + selwakeuppri(&state->ks_wsel, PZERO); state->ks_flags &= ~OPEN; state->ks_dev = NULL; @@ -498,7 +498,7 @@ vkbd_status_changed(vkbd_state_t *state) if (!(state->ks_flags & STATUS)) { state->ks_flags |= STATUS; - selwakeuppri(&state->ks_rsel, PZERO + 1); + selwakeuppri(&state->ks_rsel, PZERO); wakeup(&state->ks_flags); } } @@ -531,7 +531,7 @@ vkbd_data_read(vkbd_state_t *state, int wait) q->head = 0; /* wakeup ks_inq writers/poll()ers */ - selwakeuppri(&state->ks_wsel, PZERO + 1); + selwakeuppri(&state->ks_wsel, PZERO); wakeup(q); return (c); @@ -1246,7 +1246,7 @@ vkbd_clear_state_locked(vkbd_state_t *state) /* flush ks_inq and wakeup writers/poll()ers */ state->ks_inq.head = state->ks_inq.tail = state->ks_inq.cc = 0; - selwakeuppri(&state->ks_wsel, PZERO + 1); + selwakeuppri(&state->ks_wsel, PZERO); wakeup(&state->ks_inq); } diff --git a/sys/fs/fuse/fuse_device.c b/sys/fs/fuse/fuse_device.c index 2fd43bc742d..26f764f1939 100644 --- a/sys/fs/fuse/fuse_device.c +++ b/sys/fs/fuse/fuse_device.c @@ -153,7 +153,7 @@ fdata_dtor(void *arg) FUSE_LOCK(); fuse_lck_mtx_lock(fdata->aw_mtx); /* wakup poll()ers */ - selwakeuppri(&fdata->ks_rsel, PZERO + 1); + selwakeuppri(&fdata->ks_rsel, PZERO); /* Don't let syscall handlers wait in vain */ while ((tick = fuse_aw_pop(fdata))) { fuse_lck_mtx_lock(tick->tk_aw_mtx); diff --git a/sys/fs/fuse/fuse_io.c b/sys/fs/fuse/fuse_io.c index 877da90b580..f64344b6467 100644 --- a/sys/fs/fuse/fuse_io.c +++ b/sys/fs/fuse/fuse_io.c @@ -933,7 +933,7 @@ fuse_io_invalbuf(struct vnode *vp, struct thread *td) if (vp->v_mount->mnt_kern_flag & MNTK_UNMOUNTF) return EIO; fvdat->flag |= FN_FLUSHWANT; - tsleep(&fvdat->flag, PRIBIO + 2, "fusevinv", 2 * hz); + tsleep(&fvdat->flag, PRIBIO, "fusevinv", 2 * hz); error = 0; if (p != NULL) { PROC_LOCK(p); diff --git a/sys/fs/fuse/fuse_ipc.c b/sys/fs/fuse/fuse_ipc.c index 21787b6b543..72dd9970f84 100644 --- a/sys/fs/fuse/fuse_ipc.c +++ b/sys/fs/fuse/fuse_ipc.c @@ -594,7 +594,7 @@ fdata_set_dead(struct fuse_data *data) fuse_lck_mtx_lock(data->ms_mtx); data->dataflags |= FSESS_DEAD; wakeup_one(data); - selwakeuppri(&data->ks_rsel, PZERO + 1); + selwakeuppri(&data->ks_rsel, PZERO); wakeup(&data->ticketer); fuse_lck_mtx_unlock(data->ms_mtx); FUSE_UNLOCK(); @@ -670,7 +670,7 @@ fuse_insert_message(struct fuse_ticket *ftick, bool urgent) else fuse_ms_push(ftick); wakeup_one(ftick->tk_data); - selwakeuppri(&ftick->tk_data->ks_rsel, PZERO + 1); + selwakeuppri(&ftick->tk_data->ks_rsel, PZERO); KNOTE_LOCKED(&ftick->tk_data->ks_rsel.si_note, 0); fuse_lck_mtx_unlock(ftick->tk_data->ms_mtx); } diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index ffd6d3e5065..79f0cb00576 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -4670,7 +4670,7 @@ newnfs_sndlock(int *flagp) ts.tv_sec = 0; ts.tv_nsec = 0; (void) nfsmsleep((caddr_t)flagp, NFSSOCKMUTEXPTR, - PZERO - 1, "nfsndlck", &ts); + PVFS, "nfsndlck", &ts); } *flagp |= NFSR_SNDLOCK; NFSUNLOCKSOCK(); diff --git a/sys/fs/nfsserver/nfs_nfsdcache.c b/sys/fs/nfsserver/nfs_nfsdcache.c index bf0ff4e84d9..de72187bbb9 100644 --- a/sys/fs/nfsserver/nfs_nfsdcache.c +++ b/sys/fs/nfsserver/nfs_nfsdcache.c @@ -392,7 +392,7 @@ loop: nfsaddr_match(NETFAMILY(rp), &rp->rc_haddr, nd->nd_nam)) { if ((rp->rc_flag & RC_LOCKED) != 0) { rp->rc_flag |= RC_WANTED; - (void)mtx_sleep(rp, mutex, (PZERO - 1) | PDROP, + (void)mtx_sleep(rp, mutex, PVFS | PDROP, "nfsrc", 10 * hz); goto loop; } @@ -678,7 +678,7 @@ tryagain: rp = hitrp; if ((rp->rc_flag & RC_LOCKED) != 0) { rp->rc_flag |= RC_WANTED; - (void)mtx_sleep(rp, mutex, (PZERO - 1) | PDROP, + (void)mtx_sleep(rp, mutex, PVFS | PDROP, "nfsrc", 10 * hz); goto tryagain; } @@ -750,7 +750,7 @@ nfsrc_lock(struct nfsrvcache *rp) mtx_assert(mutex, MA_OWNED); while ((rp->rc_flag & RC_LOCKED) != 0) { rp->rc_flag |= RC_WANTED; - (void)mtx_sleep(rp, mutex, PZERO - 1, "nfsrc", 0); + (void)mtx_sleep(rp, mutex, PVFS, "nfsrc", 0); } rp->rc_flag |= RC_LOCKED; } diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 6cd8c1c861e..0f556adb697 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -552,7 +552,7 @@ nfsrv_setclient(struct nfsrv_descript *nd, struct nfsclient **new_clpp, */ while (clp->lc_cbref) { clp->lc_flags |= LCL_WAKEUPWANTED; - (void)mtx_sleep(clp, NFSSTATEMUTEXPTR, PZERO - 1, + (void)mtx_sleep(clp, NFSSTATEMUTEXPTR, PVFS, "nfsd clp", 10 * hz); } NFSUNLOCKSTATE(); @@ -629,7 +629,7 @@ nfsrv_setclient(struct nfsrv_descript *nd, struct nfsclient **new_clpp, NFSLOCKSTATE(); while (clp->lc_cbref) { clp->lc_flags |= LCL_WAKEUPWANTED; - (void)mtx_sleep(clp, NFSSTATEMUTEXPTR, PZERO - 1, + (void)mtx_sleep(clp, NFSSTATEMUTEXPTR, PVFS, "nfsdclp", 10 * hz); } NFSUNLOCKSTATE(); diff --git a/sys/fs/smbfs/smbfs_io.c b/sys/fs/smbfs/smbfs_io.c index 324f38abd10..35454998fc8 100644 --- a/sys/fs/smbfs/smbfs_io.c +++ b/sys/fs/smbfs/smbfs_io.c @@ -629,7 +629,7 @@ smbfs_vinvalbuf(struct vnode *vp, struct thread *td) while (np->n_flag & NFLUSHINPROG) { np->n_flag |= NFLUSHWANT; - error = tsleep(&np->n_flag, PRIBIO + 2, "smfsvinv", 2 * hz); + error = tsleep(&np->n_flag, PRIBIO, "smfsvinv", 2 * hz); error = smb_td_intr(td); if (error == EINTR) return EINTR; diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c index 0867e9e14fe..c1633dd19de 100644 --- a/sys/kern/kern_rmlock.c +++ b/sys/kern/kern_rmlock.c @@ -1010,7 +1010,8 @@ rms_rlock_fallback(struct rmslock *rms) mtx_lock(&rms->mtx); while (rms->writers > 0) - msleep(&rms->readers, &rms->mtx, PUSER - 1, mtx_name(&rms->mtx), 0); + msleep(&rms->readers, &rms->mtx, PRI_MAX_KERN, + mtx_name(&rms->mtx), 0); critical_enter(); rms_int_readers_inc(rms, rms_int_pcpu(rms)); mtx_unlock(&rms->mtx); @@ -1197,7 +1198,7 @@ rms_wlock(struct rmslock *rms) mtx_lock(&rms->mtx); rms->writers++; if (rms->writers > 1) { - msleep(&rms->owner, &rms->mtx, (PUSER - 1), + msleep(&rms->owner, &rms->mtx, PRI_MAX_KERN, mtx_name(&rms->mtx), 0); MPASS(rms->readers == 0); KASSERT(rms->owner == RMS_TRANSIENT, @@ -1213,7 +1214,7 @@ rms_wlock(struct rmslock *rms) rms_assert_no_pcpu_readers(rms); if (rms->readers > 0) { - msleep(&rms->writers, &rms->mtx, (PUSER - 1), + msleep(&rms->writers, &rms->mtx, PRI_MAX_KERN, mtx_name(&rms->mtx), 0); } diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index 5a6ebacb780..993c71b6894 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -50,7 +50,7 @@ #include #include -#define LOG_RDPRI (PZERO + 1) +#define LOG_RDPRI PZERO #define LOG_ASYNC 0x04 diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c index 1e84d151b4a..11141d197ae 100644 --- a/sys/kern/sysv_msg.c +++ b/sys/kern/sysv_msg.c @@ -893,7 +893,7 @@ kern_msgsnd(struct thread *td, int msqid, const void *msgp, we_own_it = 1; } DPRINTF(("msgsnd: goodnight\n")); - error = msleep(msqkptr, &msq_mtx, (PZERO - 4) | PCATCH, + error = msleep(msqkptr, &msq_mtx, PVFS | PCATCH, "msgsnd", hz); DPRINTF(("msgsnd: good morning, error=%d\n", error)); if (we_own_it) @@ -1302,7 +1302,7 @@ kern_msgrcv(struct thread *td, int msqid, void *msgp, size_t msgsz, long msgtyp, */ DPRINTF(("msgrcv: goodnight\n")); - error = msleep(msqkptr, &msq_mtx, (PZERO - 4) | PCATCH, + error = msleep(msqkptr, &msq_mtx, PVFS | PCATCH, "msgrcv", 0); DPRINTF(("msgrcv: good morning (error=%d)\n", error)); diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c index ad4243464a9..e399517010f 100644 --- a/sys/kern/sysv_sem.c +++ b/sys/kern/sysv_sem.c @@ -1308,7 +1308,7 @@ kern_semop(struct thread *td, int usemid, struct sembuf *usops, semptr->semncnt++; DPRINTF(("semop: good night!\n")); - error = msleep_sbt(semakptr, sema_mtxp, (PZERO - 4) | PCATCH, + error = msleep_sbt(semakptr, sema_mtxp, PVFS | PCATCH, "semwait", sbt, precision, C_ABSOLUTE); DPRINTF(("semop: good morning (error=%d)!\n", error)); /* return code is checked below, after sem[nz]cnt-- */ diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 4ae80e7e078..92d850381e0 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -754,7 +754,7 @@ bufspace_wait(struct bufdomain *bd, struct vnode *vp, int gbflags, break; } error = msleep(&bd->bd_wanted, BD_LOCKPTR(bd), - (PRIBIO + 4) | slpflag, "newbuf", slptimeo); + PVFS | slpflag, "newbuf", slptimeo); if (error != 0) break; } @@ -2653,8 +2653,7 @@ bwillwrite(void) mtx_lock(&bdirtylock); while (buf_dirty_count_severe()) { bdirtywait = 1; - msleep(&bdirtywait, &bdirtylock, (PRIBIO + 4), - "flswai", 0); + msleep(&bdirtywait, &bdirtylock, PVFS, "flswai", 0); } mtx_unlock(&bdirtylock); } @@ -5214,7 +5213,7 @@ bufobj_wwait(struct bufobj *bo, int slpflag, int timeo) while (bo->bo_numoutput) { bo->bo_flag |= BO_WWAIT; error = msleep(&bo->bo_numoutput, BO_LOCKPTR(bo), - slpflag | (PRIBIO + 1), "bo_wwait", timeo); + slpflag | PRIBIO, "bo_wwait", timeo); if (error) break; } diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index c447ceea163..b86d5ff6fbd 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -789,7 +789,7 @@ foffset_lock(struct file *fp, int flags) } DROP_GIANT(); sleepq_add(&fp->f_vnread_flags, NULL, "vofflock", 0, 0); - sleepq_wait(&fp->f_vnread_flags, PUSER -1); + sleepq_wait(&fp->f_vnread_flags, PRI_MAX_KERN); PICKUP_GIANT(); sleepq_lock(&fp->f_vnread_flags); state = atomic_load_16(flagsp); @@ -851,7 +851,7 @@ foffset_lock(struct file *fp, int flags) if ((flags & FOF_NOLOCK) == 0) { while (fp->f_vnread_flags & FOFFSET_LOCKED) { fp->f_vnread_flags |= FOFFSET_LOCK_WAITING; - msleep(&fp->f_vnread_flags, mtxp, PUSER -1, + msleep(&fp->f_vnread_flags, mtxp, PRI_MAX_KERN, "vofflock", 0); } fp->f_vnread_flags |= FOFFSET_LOCKED; @@ -1919,7 +1919,7 @@ vn_start_write_refed(struct mount *mp, int flags, bool mplocked) if (flags & V_PCATCH) mflags |= PCATCH; } - mflags |= (PUSER - 1); + mflags |= PRI_MAX_KERN; while ((mp->mnt_kern_flag & MNTK_SUSPEND) != 0) { if ((flags & V_NOWAIT) != 0) { error = EWOULDBLOCK; @@ -2044,7 +2044,7 @@ vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags) if ((flags & V_PCATCH) != 0) mflags |= PCATCH; } - mflags |= (PUSER - 1) | PDROP; + mflags |= PRI_MAX_KERN | PDROP; error = msleep(&mp->mnt_flag, MNT_MTX(mp), mflags, "suspfs", 0); vfs_rel(mp); if (error == 0) @@ -2129,7 +2129,7 @@ vfs_write_suspend(struct mount *mp, int flags) return (EALREADY); } while (mp->mnt_kern_flag & MNTK_SUSPEND) - msleep(&mp->mnt_flag, MNT_MTX(mp), PUSER - 1, "wsuspfs", 0); + msleep(&mp->mnt_flag, MNT_MTX(mp), PRI_MAX_KERN, "wsuspfs", 0); /* * Unmount holds a write reference on the mount point. If we @@ -2150,7 +2150,7 @@ vfs_write_suspend(struct mount *mp, int flags) mp->mnt_susp_owner = curthread; if (mp->mnt_writeopcount > 0) (void) msleep(&mp->mnt_writeopcount, - MNT_MTX(mp), (PUSER - 1)|PDROP, "suspwt", 0); + MNT_MTX(mp), PRI_MAX_KERN | PDROP, "suspwt", 0); else MNT_IUNLOCK(mp); if ((error = VFS_SYNC(mp, MNT_SUSPEND)) != 0) { diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c index a0275a7471e..45d981de9fd 100644 --- a/sys/net/if_tuntap.c +++ b/sys/net/if_tuntap.c @@ -866,7 +866,7 @@ tunstart(struct ifnet *ifp) tp->tun_flags &= ~TUN_RWAIT; wakeup(tp); } - selwakeuppri(&tp->tun_rsel, PZERO + 1); + selwakeuppri(&tp->tun_rsel, PZERO); KNOTE_LOCKED(&tp->tun_rsel.si_note, 0); if (tp->tun_flags & TUN_ASYNC && tp->tun_sigio) { TUN_UNLOCK(tp); @@ -927,7 +927,7 @@ tunstart_l2(struct ifnet *ifp) TUN_LOCK(tp); } - selwakeuppri(&tp->tun_rsel, PZERO+1); + selwakeuppri(&tp->tun_rsel, PZERO); KNOTE_LOCKED(&tp->tun_rsel.si_note, 0); if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* obytes are counted in ether_output */ } @@ -1201,7 +1201,7 @@ out: CURVNET_RESTORE(); funsetown(&tp->tun_sigio); - selwakeuppri(&tp->tun_rsel, PZERO + 1); + selwakeuppri(&tp->tun_rsel, PZERO); KNOTE_LOCKED(&tp->tun_rsel.si_note, 0); TUNDEBUG (ifp, "closed\n"); tp->tun_flags &= ~TUN_OPEN; @@ -1735,7 +1735,7 @@ tunread(struct cdev *dev, struct uio *uio, int flag) return (EWOULDBLOCK); } tp->tun_flags |= TUN_RWAIT; - error = mtx_sleep(tp, &tp->tun_mtx, PCATCH | (PZERO + 1), + error = mtx_sleep(tp, &tp->tun_mtx, PCATCH | PZERO, "tunread", 0); if (error != 0) { TUN_UNLOCK(tp); diff --git a/sys/netgraph/ng_device.c b/sys/netgraph/ng_device.c index 9269b3d1646..e4fcdfc635c 100644 --- a/sys/netgraph/ng_device.c +++ b/sys/netgraph/ng_device.c @@ -462,7 +462,7 @@ ngdread(struct cdev *dev, struct uio *uio, int flag) mtx_lock(&priv->ngd_mtx); priv->flags |= NGDF_RWAIT; if ((error = msleep(priv, &priv->ngd_mtx, - PDROP | PCATCH | (PZERO + 1), + PDROP | PCATCH | PZERO, "ngdread", 0)) != 0) return (error); } diff --git a/sys/sys/buf.h b/sys/sys/buf.h index 7c0ea9605e2..dd05d5a1df7 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -298,7 +298,7 @@ struct buf { * Initialize a lock. */ #define BUF_LOCKINIT(bp, wmesg) \ - lockinit(&(bp)->b_lock, PRIBIO + 4, wmesg, 0, LK_NEW) + lockinit(&(bp)->b_lock, PVFS, wmesg, 0, LK_NEW) /* * * Get a lock sleeping non-interruptably until it becomes available. @@ -313,7 +313,7 @@ struct buf { */ #define BUF_TIMELOCK(bp, locktype, interlock, wmesg, catch, timo) \ _lockmgr_args_rw(&(bp)->b_lock, (locktype) | LK_TIMELOCK, \ - (interlock), (wmesg), (PRIBIO + 4) | (catch), (timo), \ + (interlock), (wmesg), PVFS | (catch), (timo), \ LOCK_FILE, LOCK_LINE) /* diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 316c978e1bd..edf064549d8 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -499,7 +499,7 @@ softdep_check_suspend(struct mount *mp, while (mp->mnt_secondary_writes != 0) { BO_UNLOCK(bo); msleep(&mp->mnt_secondary_writes, MNT_MTX(mp), - (PUSER - 1) | PDROP, "secwr", 0); + PRI_MAX_KERN | PDROP, "secwr", 0); BO_LOCK(bo); MNT_ILOCK(mp); } @@ -14578,7 +14578,7 @@ softdep_check_suspend(struct mount *mp, while (mp->mnt_secondary_writes != 0) { BO_UNLOCK(bo); msleep(&mp->mnt_secondary_writes, MNT_MTX(mp), - (PUSER - 1) | PDROP, "secwr", 0); + PRI_MAX_KERN | PDROP, "secwr", 0); BO_LOCK(bo); MNT_ILOCK(mp); } @@ -14618,7 +14618,7 @@ softdep_check_suspend(struct mount *mp, BO_UNLOCK(bo); msleep(&mp->mnt_secondary_writes, MNT_MTX(mp), - (PUSER - 1) | PDROP, "secwr", 0); + PRI_MAX_KERN | PDROP, "secwr", 0); BO_LOCK(bo); continue; } diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 0f60f806104..03dcb27ff6f 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1402,8 +1402,7 @@ ffs_lock_ea(struct vnode *vp) VI_LOCK(vp); while (ip->i_flag & IN_EA_LOCKED) { UFS_INODE_SET_FLAG(ip, IN_EA_LOCKWAIT); - msleep(&ip->i_ea_refs, &vp->v_interlock, PINOD + 2, "ufs_ea", - 0); + msleep(&ip->i_ea_refs, &vp->v_interlock, PINOD, "ufs_ea", 0); } UFS_INODE_SET_FLAG(ip, IN_EA_LOCKED); VI_UNLOCK(vp); diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c index 78f539bcabd..52fc6c08fdf 100644 --- a/sys/ufs/ufs/ufs_quota.c +++ b/sys/ufs/ufs/ufs_quota.c @@ -181,7 +181,7 @@ chkdq(struct inode *ip, ufs2_daddr_t change, struct ucred *cred, int flags) if ((dq = ip->i_dquot[i]) == NODQUOT) continue; DQI_LOCK(dq); - DQI_WAIT(dq, PINOD+1, "chkdq1"); + DQI_WAIT(dq, PINOD, "chkdq1"); ncurblocks = dq->dq_curblocks + change; if (ncurblocks >= 0) dq->dq_curblocks = ncurblocks; @@ -203,7 +203,7 @@ chkdq(struct inode *ip, ufs2_daddr_t change, struct ucred *cred, int flags) continue; warn = 0; DQI_LOCK(dq); - DQI_WAIT(dq, PINOD+1, "chkdq2"); + DQI_WAIT(dq, PINOD, "chkdq2"); if (do_check) { error = chkdqchg(ip, change, cred, i, &warn); if (error) { @@ -217,7 +217,7 @@ chkdq(struct inode *ip, ufs2_daddr_t change, struct ucred *cred, int flags) if (dq == NODQUOT) continue; DQI_LOCK(dq); - DQI_WAIT(dq, PINOD+1, "chkdq3"); + DQI_WAIT(dq, PINOD, "chkdq3"); ncurblocks = dq->dq_curblocks - change; if (ncurblocks >= 0) dq->dq_curblocks = ncurblocks; @@ -322,7 +322,7 @@ chkiq(struct inode *ip, int change, struct ucred *cred, int flags) if ((dq = ip->i_dquot[i]) == NODQUOT) continue; DQI_LOCK(dq); - DQI_WAIT(dq, PINOD+1, "chkiq1"); + DQI_WAIT(dq, PINOD, "chkiq1"); if (dq->dq_curinodes >= -change) dq->dq_curinodes += change; else @@ -343,7 +343,7 @@ chkiq(struct inode *ip, int change, struct ucred *cred, int flags) continue; warn = 0; DQI_LOCK(dq); - DQI_WAIT(dq, PINOD+1, "chkiq2"); + DQI_WAIT(dq, PINOD, "chkiq2"); if (do_check) { error = chkiqchg(ip, change, cred, i, &warn); if (error) { @@ -357,7 +357,7 @@ chkiq(struct inode *ip, int change, struct ucred *cred, int flags) if (dq == NODQUOT) continue; DQI_LOCK(dq); - DQI_WAIT(dq, PINOD+1, "chkiq3"); + DQI_WAIT(dq, PINOD, "chkiq3"); if (dq->dq_curinodes >= change) dq->dq_curinodes -= change; else @@ -857,7 +857,7 @@ _setquota(struct thread *td, struct mount *mp, uint64_t id, int type, return (error); dq = ndq; DQI_LOCK(dq); - DQI_WAIT(dq, PINOD+1, "setqta"); + DQI_WAIT(dq, PINOD, "setqta"); /* * Copy all but the current values. * Reset time limit if previously had no soft limit or were @@ -920,7 +920,7 @@ _setuse(struct thread *td, struct mount *mp, uint64_t id, int type, return (error); dq = ndq; DQI_LOCK(dq); - DQI_WAIT(dq, PINOD+1, "setuse"); + DQI_WAIT(dq, PINOD, "setuse"); /* * Reset time limit if have a soft limit and were * previously under it, but are now over it. @@ -1316,7 +1316,7 @@ dqget(struct vnode *vp, uint64_t id, struct ufsmount *ump, int type, if (dq != NULL) { DQH_UNLOCK(); hfound: DQI_LOCK(dq); - DQI_WAIT(dq, PINOD+1, "dqget"); + DQI_WAIT(dq, PINOD, "dqget"); DQI_UNLOCK(dq); if (dq->dq_ump == NULL) { dqrele(vp, dq); @@ -1590,7 +1590,7 @@ dqsync(struct vnode *vp, struct dquot *dq) vn_lock(dqvp, LK_EXCLUSIVE | LK_RETRY); DQI_LOCK(dq); - DQI_WAIT(dq, PINOD+2, "dqsync"); + DQI_WAIT(dq, PINOD, "dqsync"); if ((dq->dq_flags & DQ_MOD) == 0) goto out; dq->dq_flags |= DQ_LOCK; @@ -1744,7 +1744,7 @@ quotaadj(struct dquot **qrp, struct ufsmount *ump, int64_t blkcount) if ((dq = qrp[i]) == NODQUOT) continue; DQI_LOCK(dq); - DQI_WAIT(dq, PINOD+1, "adjqta"); + DQI_WAIT(dq, PINOD, "adjqta"); ncurblocks = dq->dq_curblocks + blkcount; if (ncurblocks >= 0) dq->dq_curblocks = ncurblocks;