diff options
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_event.c | 12 | ||||
-rw-r--r-- | sys/kern/kern_physio.c | 19 | ||||
-rw-r--r-- | sys/kern/kern_proc.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_synch.c | 14 | ||||
-rw-r--r-- | sys/kern/subr_unit.c | 45 | ||||
-rw-r--r-- | sys/kern/uipc_mbuf.c | 8 | ||||
-rw-r--r-- | sys/kern/uipc_socket.c | 9 | ||||
-rw-r--r-- | sys/kern/vfs_cluster.c | 4 |
8 files changed, 54 insertions, 59 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index d75ba22..dfd1c46 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -565,7 +565,7 @@ filt_timerattach(struct knote *kn) memory_order_relaxed)); kn->kn_flags |= EV_CLEAR; /* automatically set */ - kn->kn_status &= ~KN_DETACHED; /* knlist_add usually sets it */ + kn->kn_status &= ~KN_DETACHED; /* knlist_add clears it */ calloutp = malloc(sizeof(*calloutp), M_KQUEUE, M_WAITOK); callout_init(calloutp, CALLOUT_MPSAFE); kn->kn_hook = calloutp; @@ -587,7 +587,7 @@ filt_timerdetach(struct knote *kn) free(calloutp, M_KQUEUE); old = atomic_fetch_sub_explicit(&kq_ncallouts, 1, memory_order_relaxed); KASSERT(old > 0, ("Number of callouts cannot become negative")); - kn->kn_status |= KN_DETACHED; /* knlist_remove usually clears it */ + kn->kn_status |= KN_DETACHED; /* knlist_remove sets it */ } static int @@ -1467,7 +1467,7 @@ retry: *kevp = kn->kn_kevent; KQ_LOCK(kq); KQ_GLOBAL_UNLOCK(&kq_global, haskqglobal); - if (kn->kn_flags & (EV_CLEAR | EV_DISPATCH)) { + if (kn->kn_flags & (EV_CLEAR | EV_DISPATCH)) { /* * Manually clear knotes who weren't * 'touch'ed. @@ -1859,7 +1859,7 @@ knlist_remove_kq(struct knlist *knl, struct knote *kn, int knlislocked, int kqis } /* - * remove all knotes from a specified klist + * remove knote from the specified knlist */ void knlist_remove(struct knlist *knl, struct knote *kn, int islocked) @@ -1869,7 +1869,7 @@ knlist_remove(struct knlist *knl, struct knote *kn, int islocked) } /* - * remove knote from a specified klist while in f_event handler. + * remove knote from the specified knlist while in f_event handler. */ void knlist_remove_inevent(struct knlist *knl, struct knote *kn) @@ -2002,7 +2002,7 @@ knlist_destroy(struct knlist *knl) #ifdef INVARIANTS /* * if we run across this error, we need to find the offending - * driver and have it call knlist_clear. + * driver and have it call knlist_clear or knlist_delete. */ if (!SLIST_EMPTY(&knl->kl_list)) printf("WARNING: destroying knlist w/ knotes on it!\n"); diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c index 4e818fc..b37b9f3 100644 --- a/sys/kern/kern_physio.c +++ b/sys/kern/kern_physio.c @@ -58,25 +58,22 @@ physio(struct cdev *dev, struct uio *uio, int ioflag) * If the driver does not want I/O to be split, that means that we * need to reject any requests that will not fit into one buffer. */ - if ((dev->si_flags & SI_NOSPLIT) && - ((uio->uio_resid > dev->si_iosize_max) || - (uio->uio_resid > MAXPHYS) || - (uio->uio_iovcnt > 1))) { + if (dev->si_flags & SI_NOSPLIT && + (uio->uio_resid > dev->si_iosize_max || uio->uio_resid > MAXPHYS || + uio->uio_iovcnt > 1)) { /* * Tell the user why his I/O was rejected. */ if (uio->uio_resid > dev->si_iosize_max) - printf("%s: request size %zd > si_iosize_max=%d, " + uprintf("%s: request size=%zd > si_iosize_max=%d; " "cannot split request\n", devtoname(dev), uio->uio_resid, dev->si_iosize_max); - if (uio->uio_resid > MAXPHYS) - printf("%s: request size %zd > MAXPHYS=%d, " + uprintf("%s: request size=%zd > MAXPHYS=%d; " "cannot split request\n", devtoname(dev), uio->uio_resid, MAXPHYS); - if (uio->uio_iovcnt > 1) - printf("%s: request vectors=%d > 1, " + uprintf("%s: request vectors=%d > 1; " "cannot split request\n", devtoname(dev), uio->uio_iovcnt); @@ -117,8 +114,8 @@ physio(struct cdev *dev, struct uio *uio, int ioflag) * This device does not want I/O to be split. */ if (dev->si_flags & SI_NOSPLIT) { - printf("%s: request ptr %p is not " - "on a page boundary, cannot split " + uprintf("%s: request ptr %p is not " + "on a page boundary; cannot split " "request\n", devtoname(dev), bp->b_data); error = EFBIG; diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 45920c4..3fa7a7f 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -862,6 +862,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) kp->ki_swtime = (ticks - p->p_swtick) / hz; kp->ki_pid = p->p_pid; kp->ki_nice = p->p_nice; + kp->ki_fibnum = p->p_fibnum; kp->ki_start = p->p_stats->p_start; timevaladd(&kp->ki_start, &boottime); PROC_SLOCK(p); @@ -1160,6 +1161,7 @@ freebsd32_kinfo_proc_out(const struct kinfo_proc *ki, struct kinfo_proc32 *ki32) bcopy(ki->ki_comm, ki32->ki_comm, COMMLEN + 1); bcopy(ki->ki_emul, ki32->ki_emul, KI_EMULNAMELEN + 1); bcopy(ki->ki_loginclass, ki32->ki_loginclass, LOGINCLASSLEN + 1); + CP(*ki, *ki32, ki_fibnum); CP(*ki, *ki32, ki_cr_flags); CP(*ki, *ki32, ki_jid); CP(*ki, *ki32, ki_numthreads); diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 0996f4e..b0e1908 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -356,10 +356,7 @@ msleep_spin_sbt(void *ident, struct mtx *mtx, const char *wmesg, int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags) { - int sbt_sec; - - sbt_sec = sbintime_getsec(sbt); - KASSERT(sbt_sec >= 0, ("pause: timo must be >= 0")); + KASSERT(sbt >= 0, ("pause: timeout must be >= 0")); /* silently convert invalid timeouts */ if (sbt == 0) @@ -370,11 +367,14 @@ pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags) * We delay one second at a time to avoid overflowing the * system specific DELAY() function(s): */ - while (sbt_sec > 0) { + while (sbt >= SBT_1S) { DELAY(1000000); - sbt_sec--; + sbt -= SBT_1S; } - DELAY((sbt & 0xffffffff) / SBT_1US); + /* Do the delay remainder, if any */ + sbt = (sbt + SBT_1US - 1) / SBT_1US; + if (sbt > 0) + DELAY(sbt); return (0); } return (_sleep(&pause_wchan[curcpu], NULL, 0, wmesg, sbt, pr, flags)); diff --git a/sys/kern/subr_unit.c b/sys/kern/subr_unit.c index 9cf1781..3bf7aaf 100644 --- a/sys/kern/subr_unit.c +++ b/sys/kern/subr_unit.c @@ -68,8 +68,8 @@ */ #include <sys/types.h> -#include <sys/queue.h> #include <sys/bitstring.h> +#include <sys/_unrhdr.h> #ifdef _KERNEL @@ -187,22 +187,6 @@ CTASSERT(sizeof(struct unr) == sizeof(struct unrb)); /* Number of bits in the bitmap */ #define NBITS ((int)sizeof(((struct unrb *)NULL)->map) * 8) -/* Header element for a unr number space. */ - -struct unrhdr { - TAILQ_HEAD(unrhd,unr) head; - u_int low; /* Lowest item */ - u_int high; /* Highest item */ - u_int busy; /* Count of allocated items */ - u_int alloc; /* Count of memory allocations */ - u_int first; /* items in allocated from start */ - u_int last; /* items free at end */ - struct mtx *mtx; - TAILQ_HEAD(unrfr,unr) ppfree; /* Items to be freed after mtx - lock dropped */ -}; - - #if defined(DIAGNOSTIC) || !defined(_KERNEL) /* * Consistency check function. @@ -315,20 +299,12 @@ clean_unrhdr(struct unrhdr *uh) mtx_unlock(uh->mtx); } -/* - * Allocate a new unrheader set. - * - * Highest and lowest valid values given as parameters. - */ - -struct unrhdr * -new_unrhdr(int low, int high, struct mtx *mutex) +void +init_unrhdr(struct unrhdr *uh, int low, int high, struct mtx *mutex) { - struct unrhdr *uh; KASSERT(low >= 0 && low <= high, ("UNR: use error: new_unrhdr(%d, %d)", low, high)); - uh = Malloc(sizeof *uh); if (mutex != NULL) uh->mtx = mutex; else @@ -340,6 +316,21 @@ new_unrhdr(int low, int high, struct mtx *mutex) uh->first = 0; uh->last = 1 + (high - low); check_unrhdr(uh, __LINE__); +} + +/* + * Allocate a new unrheader set. + * + * Highest and lowest valid values given as parameters. + */ + +struct unrhdr * +new_unrhdr(int low, int high, struct mtx *mutex) +{ + struct unrhdr *uh; + + uh = Malloc(sizeof *uh); + init_unrhdr(uh, low, high, mutex); return (uh); } diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 98ec889..8e278a4 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -85,6 +85,14 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, m_defragrandomfailures, CTLFLAG_RW, #endif /* + * Ensure the correct size of various mbuf parameters. It could be off due + * to compiler-induced padding and alignment artifacts. + */ +CTASSERT(sizeof(struct mbuf) == MSIZE); +CTASSERT(MSIZE - offsetof(struct mbuf, m_dat) == MLEN); +CTASSERT(MSIZE - offsetof(struct mbuf, m_pktdat) == MHLEN); + +/* * m_get2() allocates minimum mbuf that would fit "size" argument. */ struct mbuf * diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 4d0eac4..75fd04b 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2698,17 +2698,12 @@ sosetopt(struct socket *so, struct sockopt *sopt) sizeof tv); if (error) goto bad; - - if (tv.tv_sec < 0 || tv.tv_sec > INT_MAX / hz || - tv.tv_usec < 0 || tv.tv_usec >= 1000000) { + if (tv.tv_sec < 0 || tv.tv_usec < 0 || + tv.tv_usec >= 1000000) { error = EDOM; goto bad; } val = tvtohz(&tv); - if (val == INT_MAX) { - error = EDOM; - goto bad; - } switch (sopt->sopt_name) { case SO_SNDTIMEO: diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index c98db81..9601082 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -837,7 +837,9 @@ cluster_wbuild(struct vnode *vp, long size, daddr_t start_lbn, int len, (tbp->b_bcount != tbp->b_bufsize) || (tbp->b_bcount != size) || (len == 1) || - ((bp = getpbuf(&cluster_pbuf_freecnt)) == NULL)) { + ((bp = (vp->v_vflag & VV_MD) != 0 ? + trypbuf(&cluster_pbuf_freecnt) : + getpbuf(&cluster_pbuf_freecnt)) == NULL)) { totalwritten += tbp->b_bufsize; bawrite(tbp); ++start_lbn; |