The branch main has been updated by olce:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=8ecc41918066422d6788a67251b22d11a6efeddf

commit 8ecc41918066422d6788a67251b22d11a6efeddf
Author:     Olivier Certner <o...@freebsd.org>
AuthorDate: 2024-05-22 15:29:22 +0000
Commit:     Olivier Certner <o...@freebsd.org>
CommitDate: 2025-06-18 02:08:02 +0000

    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
---
 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 6533bf98011c..e110281f7c85 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -14306,7 +14306,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) {
@@ -14398,7 +14398,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 4d2d282dd22d..d17f7a15785a 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 ccf1661bba7f..2fe95c0e9f6d 100644
--- a/sys/dev/iicbus/iiconf.h
+++ b/sys/dev/iicbus/iiconf.h
@@ -32,7 +32,7 @@
 #include <dev/iicbus/iic.h>
 
 
-#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 d6f5b34d0e60..97e8c59f9282 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 0f6395121fba..66f45634ea6d 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 4c646df20a30..a6c320594064 100644
--- a/sys/dev/smbus/smbconf.h
+++ b/sys/dev/smbus/smbconf.h
@@ -30,7 +30,7 @@
 
 #include <sys/queue.h>
 
-#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 84c52659bfbb..e9d664f51a1f 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 3dbf64063e33..27a7e626fa64 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 b0c886d4b120..52f092c41788 100644
--- a/sys/fs/fuse/fuse_device.c
+++ b/sys/fs/fuse/fuse_device.c
@@ -154,7 +154,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 00b348814642..0760d7641c7d 100644
--- a/sys/fs/fuse/fuse_io.c
+++ b/sys/fs/fuse/fuse_io.c
@@ -932,7 +932,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 d3536e0a2a61..0b6048644d32 100644
--- a/sys/fs/fuse/fuse_ipc.c
+++ b/sys/fs/fuse/fuse_ipc.c
@@ -588,7 +588,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();
@@ -664,7 +664,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 eeeb079a6aa7..68d2f7d993f3 100644
--- a/sys/fs/nfs/nfs_commonsubs.c
+++ b/sys/fs/nfs/nfs_commonsubs.c
@@ -4723,7 +4723,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 bf0ff4e84d98..de72187bbb91 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 074cffd99547..c952c0976c8c 100644
--- a/sys/fs/nfsserver/nfs_nfsdstate.c
+++ b/sys/fs/nfsserver/nfs_nfsdstate.c
@@ -557,7 +557,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();
@@ -634,7 +634,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 324f38abd10e..35454998fc8e 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 0867e9e14fee..c1633dd19de2 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 f5bfd038a030..5380902e602f 100644
--- a/sys/kern/subr_log.c
+++ b/sys/kern/subr_log.c
@@ -47,7 +47,7 @@
 #include <sys/filedesc.h>
 #include <sys/sysctl.h>
 
-#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 1e84d151b4af..11141d197aec 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 ad4243464a96..e399517010fc 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 ea66a81b5903..fa655c43d155 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -756,7 +756,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;
        }
@@ -2659,8 +2659,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);
        }
@@ -5239,7 +5238,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 9b891019bbc6..b29286654f60 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -826,7 +826,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);
@@ -888,7 +888,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;
@@ -1956,7 +1956,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;
@@ -2081,7 +2081,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)
@@ -2166,7 +2166,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
@@ -2187,7 +2187,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 9ad140dcf58f..3bab04aa4d38 100644
--- a/sys/net/if_tuntap.c
+++ b/sys/net/if_tuntap.c
@@ -834,7 +834,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);
@@ -895,7 +895,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 */
        }
@@ -1169,7 +1169,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;
@@ -1703,7 +1703,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 9269b3d16467..e4fcdfc635cb 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 9d916faef4b1..064d5cb05214 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -296,7 +296,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.
@@ -311,7 +311,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 751b6e42a347..3f4aec02ba49 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -497,7 +497,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);
        }
@@ -14572,7 +14572,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);
                }
@@ -14612,7 +14612,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 6e83741975fd..33e1bc3ed88b 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -1399,8 +1399,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 2b79f19fcf77..b132eea658d0 100644
--- a/sys/ufs/ufs/ufs_quota.c
+++ b/sys/ufs/ufs/ufs_quota.c
@@ -179,7 +179,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;
@@ -201,7 +201,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) {
@@ -215,7 +215,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;
@@ -320,7 +320,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
@@ -341,7 +341,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) {
@@ -355,7 +355,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
@@ -855,7 +855,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
@@ -918,7 +918,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.
@@ -1314,7 +1314,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);
@@ -1588,7 +1588,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;
@@ -1742,7 +1742,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;

Reply via email to