summaryrefslogtreecommitdiff
path: root/sys/kern/kern_event.c
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-10-11 08:01:11 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-10-11 08:01:11 +0000
commit468b28ae293ee0ce375257e8a6f0c3eb5a4efc18 (patch)
tree275ad7b746b27751e113679c6417b7c965a31319 /sys/kern/kern_event.c
parenta8b9a59b6861914d150e5c88c10c1c0539481947 (diff)
Move kq_kev from struct kqueue to the stack.
It turns this set of events per-thread without having to lock anything. From Dragonfly 10f6680a4f6684751aaae0965abfe140f19e9231 ok kettenis@, visa@, bluhm@
Diffstat (limited to 'sys/kern/kern_event.c')
-rw-r--r--sys/kern/kern_event.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index e9a66f6fc4b..be6c7a5798f 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_event.c,v 1.79 2017/05/31 14:52:05 mikeb Exp $ */
+/* $OpenBSD: kern_event.c,v 1.80 2017/10/11 08:01:10 mpi Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
@@ -476,6 +476,7 @@ sys_kevent(struct proc *p, void *v, register_t *retval)
struct file *fp;
struct timespec ts;
int i, n, nerrors, error;
+ struct kevent kev[KQ_NEVENTS];
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL ||
(fp->f_type != DTYPE_KQUEUE))
@@ -500,16 +501,16 @@ sys_kevent(struct proc *p, void *v, register_t *retval)
while (SCARG(uap, nchanges) > 0) {
n = SCARG(uap, nchanges) > KQ_NEVENTS ?
KQ_NEVENTS : SCARG(uap, nchanges);
- error = copyin(SCARG(uap, changelist), kq->kq_kev,
+ error = copyin(SCARG(uap, changelist), kev,
n * sizeof(struct kevent));
if (error)
goto done;
#ifdef KTRACE
if (KTRPOINT(p, KTR_STRUCT))
- ktrevent(p, kq->kq_kev, n);
+ ktrevent(p, kev, n);
#endif
for (i = 0; i < n; i++) {
- kevp = &kq->kq_kev[i];
+ kevp = &kev[i];
kevp->flags &= ~EV_SYSFLAGS;
error = kqueue_register(kq, kevp, p);
if (error || (kevp->flags & EV_RECEIPT)) {
@@ -691,6 +692,7 @@ kqueue_scan(struct kqueue *kq, int maxevents, struct kevent *ulistp,
struct timeval atv, rtv, ttv;
struct knote *kn, marker;
int s, count, timeout, nkev = 0, error = 0;
+ struct kevent kev[KQ_NEVENTS];
count = maxevents;
if (count == 0)
@@ -737,7 +739,7 @@ start:
goto done;
}
- kevp = kq->kq_kev;
+ kevp = &kev[0];
s = splhigh();
if (kq->kq_count == 0) {
if (timeout < 0) {
@@ -805,13 +807,13 @@ start:
splx(s);
#ifdef KTRACE
if (KTRPOINT(p, KTR_STRUCT))
- ktrevent(p, kq->kq_kev, nkev);
+ ktrevent(p, kev, nkev);
#endif
- error = copyout(kq->kq_kev, ulistp,
+ error = copyout(kev, ulistp,
sizeof(struct kevent) * nkev);
ulistp += nkev;
nkev = 0;
- kevp = kq->kq_kev;
+ kevp = &kev[0];
s = splhigh();
if (error)
break;
@@ -823,9 +825,9 @@ done:
if (nkev != 0) {
#ifdef KTRACE
if (KTRPOINT(p, KTR_STRUCT))
- ktrevent(p, kq->kq_kev, nkev);
+ ktrevent(p, kev, nkev);
#endif
- error = copyout(kq->kq_kev, ulistp,
+ error = copyout(kev, ulistp,
sizeof(struct kevent) * nkev);
}
*retval = maxevents - count;