From a820167a0c2272d9cedf3df3381fe10e0db5ed1b Mon Sep 17 00:00:00 2001 From: visa Date: Sat, 9 Jul 2022 12:48:21 +0000 Subject: [PATCH] Unwrap klist from struct selinfo as this code no longer uses selwakeup(). OK jsg@ --- sys/kern/kern_event.c | 17 ++++++++--------- sys/kern/sys_pipe.c | 20 ++++++++++---------- sys/net/bpf.c | 17 +++++++++-------- sys/net/bpfdesc.h | 4 ++-- sys/sys/eventvar.h | 5 +++-- sys/sys/pipe.h | 6 +++--- 6 files changed, 35 insertions(+), 34 deletions(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 5db97df588f..cb65dd9c183 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_event.c,v 1.191 2022/06/27 13:35:21 visa Exp $ */ +/* $OpenBSD: kern_event.c,v 1.192 2022/07/09 12:48:21 visa Exp $ */ /*- * Copyright (c) 1999,2000,2001 Jonathan Lemon @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -221,7 +220,7 @@ KQRELE(struct kqueue *kq) free(kq->kq_knlist, M_KEVENT, kq->kq_knlistsize * sizeof(struct knlist)); hashfree(kq->kq_knhash, KN_HASHSIZE, M_KEVENT); - klist_free(&kq->kq_sel.si_note); + klist_free(&kq->kq_klist); pool_put(&kqueue_pool, kq); } @@ -257,7 +256,7 @@ kqueue_kqfilter(struct file *fp, struct knote *kn) return (EINVAL); kn->kn_fop = &kqread_filtops; - klist_insert(&kq->kq_sel.si_note, kn); + klist_insert(&kq->kq_klist, kn); return (0); } @@ -266,7 +265,7 @@ filt_kqdetach(struct knote *kn) { struct kqueue *kq = kn->kn_fp->f_data; - klist_remove(&kq->kq_sel.si_note, kn); + klist_remove(&kq->kq_klist, kn); } int @@ -849,7 +848,7 @@ kqueue_alloc(struct filedesc *fdp) TAILQ_INIT(&kq->kq_head); mtx_init(&kq->kq_lock, IPL_HIGH); task_set(&kq->kq_task, kqueue_task, kq); - klist_init_mutex(&kq->kq_sel.si_note, &kqueue_klist_lock); + klist_init_mutex(&kq->kq_klist, &kqueue_klist_lock); return (kq); } @@ -1580,7 +1579,7 @@ kqueue_terminate(struct proc *p, struct kqueue *kq) * Any knotes that were attached to this kqueue were deleted * by knote_fdclose() when this kqueue's file descriptor was closed. */ - KASSERT(klist_empty(&kq->kq_sel.si_note)); + KASSERT(klist_empty(&kq->kq_klist)); if (state & KQ_TASK) taskq_del_barrier(systqmp, &kq->kq_task); } @@ -1606,7 +1605,7 @@ kqueue_task(void *arg) struct kqueue *kq = arg; mtx_enter(&kqueue_klist_lock); - KNOTE(&kq->kq_sel.si_note, 0); + KNOTE(&kq->kq_klist, 0); mtx_leave(&kqueue_klist_lock); } @@ -1619,7 +1618,7 @@ kqueue_wakeup(struct kqueue *kq) kq->kq_state &= ~KQ_SLEEP; wakeup(kq); } - if (!klist_empty(&kq->kq_sel.si_note)) { + if (!klist_empty(&kq->kq_klist)) { /* Defer activation to avoid recursion. */ kq->kq_state |= KQ_TASK; task_add(systqmp, &kq->kq_task); diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 78884382d34..9b37fde89c0 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_pipe.c,v 1.140 2022/06/20 01:39:44 visa Exp $ */ +/* $OpenBSD: sys_pipe.c,v 1.141 2022/07/09 12:48:21 visa Exp $ */ /* * Copyright (c) 1996 John S. Dyson @@ -371,7 +371,7 @@ pipeselwakeup(struct pipe *cpipe) { rw_assert_wrlock(cpipe->pipe_lock); - KNOTE(&cpipe->pipe_sel.si_note, 0); + KNOTE(&cpipe->pipe_klist, 0); if (cpipe->pipe_state & PIPE_ASYNC) pgsigio(&cpipe->pipe_sigio, SIGIO, 0); @@ -854,7 +854,7 @@ pipe_kqfilter(struct file *fp, struct knote *kn) case EVFILT_READ: kn->kn_fop = &pipe_rfiltops; kn->kn_hook = rpipe; - klist_insert_locked(&rpipe->pipe_sel.si_note, kn); + klist_insert_locked(&rpipe->pipe_klist, kn); break; case EVFILT_WRITE: if (wpipe == NULL) { @@ -864,7 +864,7 @@ pipe_kqfilter(struct file *fp, struct knote *kn) } kn->kn_fop = &pipe_wfiltops; kn->kn_hook = wpipe; - klist_insert_locked(&wpipe->pipe_sel.si_note, kn); + klist_insert_locked(&wpipe->pipe_klist, kn); break; case EVFILT_EXCEPT: if (kn->kn_flags & __EV_SELECT) { @@ -879,7 +879,7 @@ pipe_kqfilter(struct file *fp, struct knote *kn) } kn->kn_fop = &pipe_efiltops; kn->kn_hook = rpipe; - klist_insert_locked(&rpipe->pipe_sel.si_note, kn); + klist_insert_locked(&rpipe->pipe_klist, kn); break; default: error = EINVAL; @@ -895,7 +895,7 @@ filt_pipedetach(struct knote *kn) { struct pipe *cpipe = kn->kn_hook; - klist_remove(&cpipe->pipe_sel.si_note, kn); + klist_remove(&cpipe->pipe_klist, kn); } int @@ -1011,8 +1011,8 @@ pipe_pair_create(void) pp->pp_wpipe.pipe_lock = &pp->pp_lock; pp->pp_rpipe.pipe_lock = &pp->pp_lock; - klist_init_rwlock(&pp->pp_wpipe.pipe_sel.si_note, &pp->pp_lock); - klist_init_rwlock(&pp->pp_rpipe.pipe_sel.si_note, &pp->pp_lock); + klist_init_rwlock(&pp->pp_wpipe.pipe_klist, &pp->pp_lock); + klist_init_rwlock(&pp->pp_rpipe.pipe_klist, &pp->pp_lock); if (pipe_create(&pp->pp_wpipe) || pipe_create(&pp->pp_rpipe)) goto err; @@ -1026,7 +1026,7 @@ err: void pipe_pair_destroy(struct pipe_pair *pp) { - klist_free(&pp->pp_wpipe.pipe_sel.si_note); - klist_free(&pp->pp_rpipe.pipe_sel.si_note); + klist_free(&pp->pp_wpipe.pipe_klist); + klist_free(&pp->pp_rpipe.pipe_klist); pool_put(&pipe_pair_pool, pp); } diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 091fb0895cc..cadd105134e 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.218 2022/07/05 15:06:16 visa Exp $ */ +/* $OpenBSD: bpf.c,v 1.219 2022/07/09 12:48:21 visa Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -54,10 +54,11 @@ #include #include #include +#include +#include #include #include #include -#include #include #include #include @@ -393,7 +394,7 @@ bpfopen(dev_t dev, int flag, int mode, struct proc *p) task_set(&bd->bd_wake_task, bpf_wakeup_cb, bd); smr_init(&bd->bd_smr); sigio_init(&bd->bd_sigio); - klist_init_mutex(&bd->bd_sel.si_note, &bd->bd_mtx); + klist_init_mutex(&bd->bd_klist, &bd->bd_mtx); bd->bd_rtout = 0; /* no timeout by default */ @@ -585,7 +586,7 @@ bpf_wakeup(struct bpf_d *d) if (d->bd_nreaders) wakeup(d); - KNOTE(&d->bd_sel.si_note, 0); + KNOTE(&d->bd_klist, 0); /* * As long as pgsigio() needs to be protected @@ -1161,7 +1162,7 @@ bpfkqfilter(dev_t dev, struct knote *kn) switch (kn->kn_filter) { case EVFILT_READ: - klist = &d->bd_sel.si_note; + klist = &d->bd_klist; kn->kn_fop = &bpfread_filtops; break; default: @@ -1180,7 +1181,7 @@ filt_bpfrdetach(struct knote *kn) { struct bpf_d *d = kn->kn_hook; - klist_remove(&d->bd_sel.si_note, kn); + klist_remove(&d->bd_klist, kn); bpf_put(d); } @@ -1591,7 +1592,7 @@ bpf_d_smr(void *smr) if (bd->bd_wfilter != NULL) bpf_prog_smr(bd->bd_wfilter); - klist_free(&bd->bd_sel.si_note); + klist_free(&bd->bd_klist); free(bd, M_DEVBUF, sizeof(*bd)); } @@ -1684,7 +1685,7 @@ bpfsdetach(void *p) while ((bd = SMR_SLIST_FIRST_LOCKED(&bp->bif_dlist))) { vdevgone(maj, bd->bd_unit, bd->bd_unit, VCHR); - klist_invalidate(&bd->bd_sel.si_note); + klist_invalidate(&bd->bd_klist); } for (tbp = bpf_iflist; tbp; tbp = tbp->bif_next) { diff --git a/sys/net/bpfdesc.h b/sys/net/bpfdesc.h index 8e03b3e3c01..20a7fd0f0f0 100644 --- a/sys/net/bpfdesc.h +++ b/sys/net/bpfdesc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bpfdesc.h,v 1.46 2022/03/17 14:22:03 visa Exp $ */ +/* $OpenBSD: bpfdesc.h,v 1.47 2022/07/09 12:48:21 visa Exp $ */ /* $NetBSD: bpfdesc.h,v 1.11 1995/09/27 18:30:42 thorpej Exp $ */ /* @@ -99,7 +99,7 @@ struct bpf_d { struct sigio_ref bd_sigio; /* async I/O registration */ struct refcnt bd_refcnt; /* reference count */ - struct selinfo bd_sel; /* bsd select info */ + struct klist bd_klist; /* list of knotes */ int bd_unit; /* logical unit number */ LIST_ENTRY(bpf_d) bd_list; /* descriptor list */ diff --git a/sys/sys/eventvar.h b/sys/sys/eventvar.h index e93b1494767..0617ae1e958 100644 --- a/sys/sys/eventvar.h +++ b/sys/sys/eventvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: eventvar.h,v 1.16 2022/06/27 13:35:21 visa Exp $ */ +/* $OpenBSD: eventvar.h,v 1.17 2022/07/09 12:48:21 visa Exp $ */ /*- * Copyright (c) 1999,2000 Jonathan Lemon @@ -41,6 +41,7 @@ /* * Locking: * I immutable after creation + * L kqueue_klist_lock * a atomic operations * q kq_lock */ @@ -49,7 +50,7 @@ struct kqueue { TAILQ_HEAD(, knote) kq_head; /* [q] list of pending event */ int kq_count; /* [q] # of pending events */ struct refcnt kq_refcnt; /* [a] # of references */ - struct selinfo kq_sel; + struct klist kq_klist; /* [L] knotes of other kqs */ struct filedesc *kq_fdp; /* [I] fd table of this kq */ LIST_ENTRY(kqueue) kq_next; diff --git a/sys/sys/pipe.h b/sys/sys/pipe.h index 7bdcf9bbee3..06146f4d7a3 100644 --- a/sys/sys/pipe.h +++ b/sys/sys/pipe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pipe.h,v 1.28 2022/06/20 01:39:44 visa Exp $ */ +/* $OpenBSD: pipe.h,v 1.29 2022/07/09 12:48:21 visa Exp $ */ /* * Copyright (c) 1996 John S. Dyson @@ -26,9 +26,9 @@ #ifndef _KERNEL #include /* for struct timespec */ -#include /* for struct selinfo */ #endif /* _KERNEL */ +#include /* for struct klist */ #include /* for struct sigio_ref */ /* @@ -80,7 +80,7 @@ struct pipe_pair; struct pipe { struct rwlock *pipe_lock; struct pipebuf pipe_buffer; /* [p] data storage */ - struct selinfo pipe_sel; /* [p] for compat with select */ + struct klist pipe_klist; /* [p] list of knotes */ struct timespec pipe_atime; /* [p] time of last access */ struct timespec pipe_mtime; /* [p] time of last modify */ struct timespec pipe_ctime; /* [I] time of status change */ -- 2.20.1