Now that poll(2) & select(2) use the kqueue backend under the hood we can start retiring the old machinery.
The diff below does not touch driver definitions, however it : - kills selrecord() & doselwakeup() - make it obvious that `kern.nselcoll' is now always 0 - Change all poll/select hooks to return 0 - Kill a seltid check in wsdisplaystart() which is now always true In a later step we could remove the *_poll() requirement from device drivers and kill seltrue() & selfalse(). ok? Index: arch/sparc64/dev/vldcp.c =================================================================== RCS file: /cvs/src/sys/arch/sparc64/dev/vldcp.c,v retrieving revision 1.22 diff -u -p -r1.22 vldcp.c --- arch/sparc64/dev/vldcp.c 24 Oct 2021 17:05:04 -0000 1.22 +++ arch/sparc64/dev/vldcp.c 11 Apr 2022 16:38:32 -0000 @@ -581,44 +581,7 @@ vldcpioctl(dev_t dev, u_long cmd, caddr_ int vldcppoll(dev_t dev, int events, struct proc *p) { - struct vldcp_softc *sc; - struct ldc_conn *lc; - uint64_t head, tail, state; - int revents = 0; - int s, err; - - sc = vldcp_lookup(dev); - if (sc == NULL) - return (POLLERR); - lc = &sc->sc_lc; - - s = spltty(); - if (events & (POLLIN | POLLRDNORM)) { - err = hv_ldc_rx_get_state(lc->lc_id, &head, &tail, &state); - - if (err == 0 && state == LDC_CHANNEL_UP && head != tail) - revents |= events & (POLLIN | POLLRDNORM); - } - if (events & (POLLOUT | POLLWRNORM)) { - err = hv_ldc_tx_get_state(lc->lc_id, &head, &tail, &state); - - if (err == 0 && state == LDC_CHANNEL_UP && head != tail) - revents |= events & (POLLOUT | POLLWRNORM); - } - if (revents == 0) { - if (events & (POLLIN | POLLRDNORM)) { - cbus_intr_setenabled(sc->sc_bustag, sc->sc_rx_ino, - INTR_ENABLED); - selrecord(p, &sc->sc_rsel); - } - if (events & (POLLOUT | POLLWRNORM)) { - cbus_intr_setenabled(sc->sc_bustag, sc->sc_tx_ino, - INTR_ENABLED); - selrecord(p, &sc->sc_wsel); - } - } - splx(s); - return revents; + return 0; } void Index: dev/audio.c =================================================================== RCS file: /cvs/src/sys/dev/audio.c,v retrieving revision 1.198 diff -u -p -r1.198 audio.c --- dev/audio.c 21 Mar 2022 19:22:39 -0000 1.198 +++ dev/audio.c 11 Apr 2022 16:38:52 -0000 @@ -2053,17 +2053,7 @@ audio_mixer_read(struct audio_softc *sc, int audio_mixer_poll(struct audio_softc *sc, int events, struct proc *p) { - int revents = 0; - - mtx_enter(&audio_lock); - if (sc->mix_isopen && sc->mix_pending) - revents |= events & (POLLIN | POLLRDNORM); - if (revents == 0) { - if (events & (POLLIN | POLLRDNORM)) - selrecord(p, &sc->mix_sel); - } - mtx_leave(&audio_lock); - return revents; + return 0; } int @@ -2101,21 +2091,7 @@ audio_mixer_close(struct audio_softc *sc int audio_poll(struct audio_softc *sc, int events, struct proc *p) { - int revents = 0; - - mtx_enter(&audio_lock); - if ((sc->mode & AUMODE_RECORD) && sc->rec.used > 0) - revents |= events & (POLLIN | POLLRDNORM); - if ((sc->mode & AUMODE_PLAY) && sc->play.used < sc->play.len) - revents |= events & (POLLOUT | POLLWRNORM); - if (revents == 0) { - if (events & (POLLIN | POLLRDNORM)) - selrecord(p, &sc->rec.sel); - if (events & (POLLOUT | POLLWRNORM)) - selrecord(p, &sc->play.sel); - } - mtx_leave(&audio_lock); - return revents; + return 0; } int Index: dev/hotplug.c =================================================================== RCS file: /cvs/src/sys/dev/hotplug.c,v retrieving revision 1.21 diff -u -p -r1.21 hotplug.c --- dev/hotplug.c 25 Dec 2020 12:59:52 -0000 1.21 +++ dev/hotplug.c 11 Apr 2022 16:39:24 -0000 @@ -183,16 +183,7 @@ hotplugioctl(dev_t dev, u_long cmd, cadd int hotplugpoll(dev_t dev, int events, struct proc *p) { - int revents = 0; - - if (events & (POLLIN | POLLRDNORM)) { - if (evqueue_count > 0) - revents |= events & (POLLIN | POLLRDNORM); - else - selrecord(p, &hotplug_sel); - } - - return (revents); + return (0); } int Index: dev/midi.c =================================================================== RCS file: /cvs/src/sys/dev/midi.c,v retrieving revision 1.54 diff -u -p -r1.54 midi.c --- dev/midi.c 6 Apr 2022 18:59:27 -0000 1.54 +++ dev/midi.c 11 Apr 2022 16:39:31 -0000 @@ -334,31 +334,7 @@ done: int midipoll(dev_t dev, int events, struct proc *p) { - struct midi_softc *sc; - int revents; - - sc = (struct midi_softc *)device_lookup(&midi_cd, minor(dev)); - if (sc == NULL) - return POLLERR; - revents = 0; - mtx_enter(&audio_lock); - if (events & (POLLIN | POLLRDNORM)) { - if (!MIDIBUF_ISEMPTY(&sc->inbuf)) - revents |= events & (POLLIN | POLLRDNORM); - } - if (events & (POLLOUT | POLLWRNORM)) { - if (!MIDIBUF_ISFULL(&sc->outbuf)) - revents |= events & (POLLOUT | POLLWRNORM); - } - if (revents == 0) { - if (events & (POLLIN | POLLRDNORM)) - selrecord(p, &sc->inbuf.sel); - if (events & (POLLOUT | POLLWRNORM)) - selrecord(p, &sc->outbuf.sel); - } - mtx_leave(&audio_lock); - device_unref(&sc->dev); - return (revents); + return (0); } int Index: dev/video.c =================================================================== RCS file: /cvs/src/sys/dev/video.c,v retrieving revision 1.56 diff -u -p -r1.56 video.c --- dev/video.c 6 Apr 2022 18:59:27 -0000 1.56 +++ dev/video.c 11 Apr 2022 16:39:41 -0000 @@ -393,49 +393,7 @@ videoioctl(dev_t dev, u_long cmd, caddr_ int videopoll(dev_t dev, int events, struct proc *p) { - int unit = VIDEOUNIT(dev); - struct video_softc *sc; - int error, revents = 0; - - KERNEL_ASSERT_LOCKED(); - - if (unit >= video_cd.cd_ndevs || - (sc = video_cd.cd_devs[unit]) == NULL) - return (POLLERR); - - if (sc->sc_dying) - return (POLLERR); - - if ((error = video_claim(sc, p->p_p))) - return (error); - - DPRINTF(1, "%s: events=0x%x\n", __func__, events); - - if (events & (POLLIN | POLLRDNORM)) { - if (sc->sc_frames_ready > 0) - revents |= events & (POLLIN | POLLRDNORM); - } - if (revents == 0) { - if (events & (POLLIN | POLLRDNORM)) { - /* - * Start the stream in read() mode if not already - * started. If the user wanted mmap() mode, - * he should have called mmap() before now. - */ - if (sc->sc_vidmode == VIDMODE_NONE && - sc->hw_if->start_read) { - error = sc->hw_if->start_read(sc->hw_hdl); - if (error) - return (POLLERR); - sc->sc_vidmode = VIDMODE_READ; - } - selrecord(p, &sc->sc_rsel); - } - } - - DPRINTF(1, "%s: revents=0x%x\n", __func__, revents); - - return (revents); + return (0); } paddr_t Index: dev/vscsi.c =================================================================== RCS file: /cvs/src/sys/dev/vscsi.c,v retrieving revision 1.59 diff -u -p -r1.59 vscsi.c --- dev/vscsi.c 6 Apr 2022 18:59:27 -0000 1.59 +++ dev/vscsi.c 11 Apr 2022 16:39:17 -0000 @@ -530,26 +530,7 @@ gone: int vscsipoll(dev_t dev, int events, struct proc *p) { - struct vscsi_softc *sc = DEV2SC(dev); - int revents = 0; - - if (sc == NULL) - return (POLLERR); - - if (events & (POLLIN | POLLRDNORM)) { - mtx_enter(&sc->sc_state_mtx); - if (!TAILQ_EMPTY(&sc->sc_ccb_i2t)) - revents |= events & (POLLIN | POLLRDNORM); - mtx_leave(&sc->sc_state_mtx); - } - - if (revents == 0) { - if (events & (POLLIN | POLLRDNORM)) - selrecord(p, &sc->sc_sel); - } - - device_unref(&sc->sc_dev); - return (revents); + return (0); } int Index: dev/pci/drm/drm_drv.c =================================================================== RCS file: /cvs/src/sys/dev/pci/drm/drm_drv.c,v retrieving revision 1.184 diff -u -p -r1.184 drm_drv.c --- dev/pci/drm/drm_drv.c 11 Mar 2022 18:00:53 -0000 1.184 +++ dev/pci/drm/drm_drv.c 11 Apr 2022 16:40:13 -0000 @@ -1867,29 +1867,7 @@ out: int drmpoll(dev_t kdev, int events, struct proc *p) { - struct drm_device *dev = drm_get_device_from_kdev(kdev); - struct drm_file *file_priv; - int revents = 0; - - if (dev == NULL) - return (POLLERR); - - mutex_lock(&dev->filelist_mutex); - file_priv = drm_find_file_by_minor(dev, minor(kdev)); - mutex_unlock(&dev->filelist_mutex); - if (file_priv == NULL) - return (POLLERR); - - mtx_enter(&dev->event_lock); - if (events & (POLLIN | POLLRDNORM)) { - if (!list_empty(&file_priv->event_list)) - revents |= events & (POLLIN | POLLRDNORM); - else - selrecord(p, &file_priv->rsel); - } - mtx_leave(&dev->event_lock); - - return (revents); + return (0); } paddr_t Index: dev/usb/ugen.c =================================================================== RCS file: /cvs/src/sys/dev/usb/ugen.c,v retrieving revision 1.115 diff -u -p -r1.115 ugen.c --- dev/usb/ugen.c 5 Feb 2021 08:17:22 -0000 1.115 +++ dev/usb/ugen.c 11 Apr 2022 16:40:26 -0000 @@ -1248,62 +1248,7 @@ ugenioctl(dev_t dev, u_long cmd, caddr_t int ugenpoll(dev_t dev, int events, struct proc *p) { - struct ugen_softc *sc; - struct ugen_endpoint *sce; - int revents = 0; - int s; - - sc = ugen_cd.cd_devs[UGENUNIT(dev)]; - - if (usbd_is_dying(sc->sc_udev)) - return (POLLERR); - - /* XXX always IN */ - sce = &sc->sc_endpoints[UGENENDPOINT(dev)][IN]; - if (sce == NULL) - return (POLLERR); -#ifdef DIAGNOSTIC - if (!sce->edesc) { - printf("ugenpoll: no edesc\n"); - return (POLLERR); - } - if (!sce->pipeh) { - printf("ugenpoll: no pipe\n"); - return (POLLERR); - } -#endif - s = splusb(); - switch (UE_GET_XFERTYPE(sce->edesc->bmAttributes)) { - case UE_INTERRUPT: - if (events & (POLLIN | POLLRDNORM)) { - if (sce->q.c_cc > 0) - revents |= events & (POLLIN | POLLRDNORM); - else - selrecord(p, &sce->rsel); - } - break; - case UE_ISOCHRONOUS: - if (events & (POLLIN | POLLRDNORM)) { - if (sce->cur != sce->fill) - revents |= events & (POLLIN | POLLRDNORM); - else - selrecord(p, &sce->rsel); - } - break; - case UE_BULK: - /* - * We have no easy way of determining if a read will - * yield any data or a write will happen. - * Pretend they will. - */ - revents |= events & - (POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM); - break; - default: - break; - } - splx(s); - return (revents); + return (0); } void filt_ugenrdetach(struct knote *); Index: dev/usb/uhid.c =================================================================== RCS file: /cvs/src/sys/dev/usb/uhid.c,v retrieving revision 1.88 diff -u -p -r1.88 uhid.c --- dev/usb/uhid.c 15 Nov 2021 15:36:24 -0000 1.88 +++ dev/usb/uhid.c 11 Apr 2022 16:40:34 -0000 @@ -417,28 +417,7 @@ uhidioctl(dev_t dev, u_long cmd, caddr_t int uhidpoll(dev_t dev, int events, struct proc *p) { - struct uhid_softc *sc; - int revents = 0; - int s; - - if ((sc = uhid_lookup(dev)) == NULL) - return (POLLERR); - - if (usbd_is_dying(sc->sc_hdev.sc_udev)) - return (POLLHUP); - - s = splusb(); - if (events & (POLLOUT | POLLWRNORM)) - revents |= events & (POLLOUT | POLLWRNORM); - if (events & (POLLIN | POLLRDNORM)) { - if (sc->sc_q.c_cc > 0) - revents |= events & (POLLIN | POLLRDNORM); - else - selrecord(p, &sc->sc_rsel); - } - - splx(s); - return (revents); + return (0); } void filt_uhidrdetach(struct knote *); Index: dev/wscons/wsdisplay.c =================================================================== RCS file: /cvs/src/sys/dev/wscons/wsdisplay.c,v retrieving revision 1.144 diff -u -p -r1.144 wsdisplay.c --- dev/wscons/wsdisplay.c 6 Apr 2022 18:59:30 -0000 1.144 +++ dev/wscons/wsdisplay.c 11 Apr 2022 16:45:39 -0000 @@ -1462,7 +1462,7 @@ wsdisplaystart(struct tty *tp) splx(s); return; } - if (tp->t_outq.c_cc == 0 && tp->t_wsel.si_seltid == 0) + if (tp->t_outq.c_cc == 0) goto low; if ((scr = sc->sc_scr[WSDISPLAYSCREEN(tp->t_dev)]) == NULL) { Index: dev/wscons/wsevent.c =================================================================== RCS file: /cvs/src/sys/dev/wscons/wsevent.c,v retrieving revision 1.25 diff -u -p -r1.25 wsevent.c --- dev/wscons/wsevent.c 25 Dec 2020 12:59:52 -0000 1.25 +++ dev/wscons/wsevent.c 11 Apr 2022 16:40:41 -0000 @@ -203,18 +203,7 @@ wsevent_read(struct wseventvar *ev, stru int wsevent_poll(struct wseventvar *ev, int events, struct proc *p) { - int revents = 0; - int s = splwsevent(); - - if (events & (POLLIN | POLLRDNORM)) { - if (ev->get != ev->put) - revents |= events & (POLLIN | POLLRDNORM); - else - selrecord(p, &ev->sel); - } - - splx(s); - return (revents); + return (0); } int Index: kern/kern_event.c =================================================================== RCS file: /cvs/src/sys/kern/kern_event.c,v retrieving revision 1.186 diff -u -p -r1.186 kern_event.c --- kern/kern_event.c 31 Mar 2022 01:41:22 -0000 1.186 +++ kern/kern_event.c 11 Apr 2022 16:40:51 -0000 @@ -1528,20 +1528,7 @@ kqueue_ioctl(struct file *fp, u_long com int kqueue_poll(struct file *fp, int events, struct proc *p) { - struct kqueue *kq = (struct kqueue *)fp->f_data; - int revents = 0; - - if (events & (POLLIN | POLLRDNORM)) { - mtx_enter(&kq->kq_lock); - if (kq->kq_count) { - revents |= events & (POLLIN | POLLRDNORM); - } else { - selrecord(p, &kq->kq_sel); - kq->kq_state |= KQ_SEL; - } - mtx_leave(&kq->kq_lock); - } - return (revents); + return (0); } int Index: kern/kern_sysctl.c =================================================================== RCS file: /cvs/src/sys/kern/kern_sysctl.c,v retrieving revision 1.402 diff -u -p -r1.402 kern_sysctl.c --- kern/kern_sysctl.c 21 Mar 2022 09:12:34 -0000 1.402 +++ kern/kern_sysctl.c 11 Apr 2022 16:59:34 -0000 @@ -120,7 +120,7 @@ extern struct forkstat forkstat; extern struct nchstats nchstats; -extern int nselcoll, fscale; +extern int fscale; extern fixpt_t ccpu; extern long numvnodes; extern int allowdt; @@ -298,7 +298,7 @@ const struct sysctl_bounded_args kern_va {KERN_NFILES, &numfiles, SYSCTL_INT_READONLY}, {KERN_TTYCOUNT, &tty_count, SYSCTL_INT_READONLY}, {KERN_ARGMAX, &arg_max, SYSCTL_INT_READONLY}, - {KERN_NSELCOLL, &nselcoll, SYSCTL_INT_READONLY}, + {KERN_NSELCOLL, &int_zero, SYSCTL_INT_READONLY}, {KERN_POSIX1, &posix_version, SYSCTL_INT_READONLY}, {KERN_NGROUPS, &ngroups_max, SYSCTL_INT_READONLY}, {KERN_JOB_CONTROL, &int_one, SYSCTL_INT_READONLY}, Index: kern/subr_log.c =================================================================== RCS file: /cvs/src/sys/kern/subr_log.c,v retrieving revision 1.74 diff -u -p -r1.74 subr_log.c --- kern/subr_log.c 18 Mar 2021 08:43:38 -0000 1.74 +++ kern/subr_log.c 11 Apr 2022 16:41:24 -0000 @@ -302,17 +302,7 @@ logread(dev_t dev, struct uio *uio, int int logpoll(dev_t dev, int events, struct proc *p) { - int revents = 0; - - mtx_enter(&log_mtx); - if (events & (POLLIN | POLLRDNORM)) { - if (msgbufp->msg_bufr != msgbufp->msg_bufx) - revents |= events & (POLLIN | POLLRDNORM); - else - selrecord(p, &logsoftc.sc_selp); - } - mtx_leave(&log_mtx); - return (revents); + return (0); } int Index: kern/sys_generic.c =================================================================== RCS file: /cvs/src/sys/kern/sys_generic.c,v retrieving revision 1.147 diff -u -p -r1.147 sys_generic.c --- kern/sys_generic.c 8 Feb 2022 08:56:41 -0000 1.147 +++ kern/sys_generic.c 11 Apr 2022 16:56:49 -0000 @@ -89,7 +89,6 @@ int dopselect(struct proc *, int, fd_set struct timespec *, const sigset_t *, register_t *); int doppoll(struct proc *, struct pollfd *, u_int, struct timespec *, const sigset_t *, register_t *); -void doselwakeup(struct selinfo *); int iovec_copyin(const struct iovec *uiov, struct iovec **iovp, struct iovec *aiov, @@ -522,8 +521,6 @@ out: return (error); } -int selwait, nselcoll; - /* * Select system call. */ @@ -855,27 +852,6 @@ selfalse(dev_t dev, int events, struct p } /* - * Record a select request. - */ -void -selrecord(struct proc *selector, struct selinfo *sip) -{ - struct proc *p; - pid_t mytid; - - KERNEL_ASSERT_LOCKED(); - - mytid = selector->p_tid; - if (sip->si_seltid == mytid) - return; - if (sip->si_seltid && (p = tfind(sip->si_seltid)) && - p->p_wchan == (caddr_t)&selwait) - sip->si_flags |= SI_COLL; - else - sip->si_seltid = mytid; -} - -/* * Do a wakeup when a selectable event occurs. */ void @@ -883,32 +859,7 @@ selwakeup(struct selinfo *sip) { KERNEL_LOCK(); KNOTE(&sip->si_note, NOTE_SUBMIT); - doselwakeup(sip); KERNEL_UNLOCK(); -} - -void -doselwakeup(struct selinfo *sip) -{ - struct proc *p; - - KERNEL_ASSERT_LOCKED(); - - if (sip->si_seltid == 0) - return; - if (sip->si_flags & SI_COLL) { - nselcoll++; - sip->si_flags &= ~SI_COLL; - wakeup(&selwait); - } - p = tfind(sip->si_seltid); - sip->si_seltid = 0; - if (p != NULL) { - if (wakeup_proc(p, &selwait)) { - /* nothing else to do */ - } else if (p->p_flag & P_SELECT) - atomic_clearbits_int(&p->p_flag, P_SELECT); - } } /* Index: kern/sys_pipe.c =================================================================== RCS file: /cvs/src/sys/kern/sys_pipe.c,v retrieving revision 1.136 diff -u -p -r1.136 sys_pipe.c --- kern/sys_pipe.c 13 Feb 2022 13:05:51 -0000 1.136 +++ kern/sys_pipe.c 11 Apr 2022 16:41:17 -0000 @@ -726,41 +726,7 @@ pipe_ioctl(struct file *fp, u_long cmd, int pipe_poll(struct file *fp, int events, struct proc *p) { - struct pipe *rpipe = fp->f_data, *wpipe; - struct rwlock *lock = rpipe->pipe_lock; - int revents = 0; - - rw_enter_write(lock); - wpipe = pipe_peer(rpipe); - - if (events & (POLLIN | POLLRDNORM)) { - if (rpipe->pipe_buffer.cnt > 0 || - (rpipe->pipe_state & PIPE_EOF)) - revents |= events & (POLLIN | POLLRDNORM); - } - - /* NOTE: POLLHUP and POLLOUT/POLLWRNORM are mutually exclusive */ - if ((rpipe->pipe_state & PIPE_EOF) || wpipe == NULL) - revents |= POLLHUP; - else if (events & (POLLOUT | POLLWRNORM)) { - if (wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt >= PIPE_BUF) - revents |= events & (POLLOUT | POLLWRNORM); - } - - if (revents == 0) { - if (events & (POLLIN | POLLRDNORM)) { - selrecord(p, &rpipe->pipe_sel); - rpipe->pipe_state |= PIPE_SEL; - } - if (events & (POLLOUT | POLLWRNORM)) { - selrecord(p, &wpipe->pipe_sel); - wpipe->pipe_state |= PIPE_SEL; - } - } - - rw_exit_write(lock); - - return (revents); + return (0); } int Index: kern/sys_socket.c =================================================================== RCS file: /cvs/src/sys/kern/sys_socket.c,v retrieving revision 1.49 diff -u -p -r1.49 sys_socket.c --- kern/sys_socket.c 25 Feb 2022 23:51:03 -0000 1.49 +++ kern/sys_socket.c 11 Apr 2022 16:41:32 -0000 @@ -152,38 +152,7 @@ soo_ioctl(struct file *fp, u_long cmd, c int soo_poll(struct file *fp, int events, struct proc *p) { - struct socket *so = fp->f_data; - int revents = 0; - int s; - - s = solock(so); - if (events & (POLLIN | POLLRDNORM)) { - if (soreadable(so)) - revents |= events & (POLLIN | POLLRDNORM); - } - /* NOTE: POLLHUP and POLLOUT/POLLWRNORM are mutually exclusive */ - if (so->so_state & SS_ISDISCONNECTED) { - revents |= POLLHUP; - } else if (events & (POLLOUT | POLLWRNORM)) { - if (sowriteable(so)) - revents |= events & (POLLOUT | POLLWRNORM); - } - if (events & (POLLPRI | POLLRDBAND)) { - if (so->so_oobmark || (so->so_state & SS_RCVATMARK)) - revents |= events & (POLLPRI | POLLRDBAND); - } - if (revents == 0) { - if (events & (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) { - selrecord(p, &so->so_rcv.sb_sel); - so->so_rcv.sb_flags |= SB_SEL; - } - if (events & (POLLOUT | POLLWRNORM)) { - selrecord(p, &so->so_snd.sb_sel); - so->so_snd.sb_flags |= SB_SEL; - } - } - sounlock(so, s); - return (revents); + return (0); } int Index: kern/tty.c =================================================================== RCS file: /cvs/src/sys/kern/tty.c,v retrieving revision 1.174 diff -u -p -r1.174 tty.c --- kern/tty.c 15 Feb 2022 03:53:58 -0000 1.174 +++ kern/tty.c 11 Apr 2022 16:41:40 -0000 @@ -1061,33 +1061,7 @@ ttioctl(struct tty *tp, u_long cmd, cadd int ttpoll(dev_t device, int events, struct proc *p) { - struct tty *tp; - int revents, s; - - tp = (*cdevsw[major(device)].d_tty)(device); - - revents = 0; - s = spltty(); - if (events & (POLLIN | POLLRDNORM)) { - if (ttnread(tp) > 0 || (!ISSET(tp->t_cflag, CLOCAL) && - !ISSET(tp->t_state, TS_CARR_ON))) - revents |= events & (POLLIN | POLLRDNORM); - } - /* NOTE: POLLHUP and POLLOUT/POLLWRNORM are mutually exclusive */ - if (!ISSET(tp->t_cflag, CLOCAL) && !ISSET(tp->t_state, TS_CARR_ON)) { - revents |= POLLHUP; - } else if (events & (POLLOUT | POLLWRNORM)) { - if (tp->t_outq.c_cc <= tp->t_lowat) - revents |= events & (POLLOUT | POLLWRNORM); - } - if (revents == 0) { - if (events & (POLLIN | POLLRDNORM)) - selrecord(p, &tp->t_rsel); - if (events & (POLLOUT | POLLWRNORM)) - selrecord(p, &tp->t_wsel); - } - splx(s); - return (revents); + return (0); } const struct filterops ttyread_filtops = { Index: kern/tty_pty.c =================================================================== RCS file: /cvs/src/sys/kern/tty_pty.c,v retrieving revision 1.112 diff -u -p -r1.112 tty_pty.c --- kern/tty_pty.c 15 Dec 2021 15:30:47 -0000 1.112 +++ kern/tty_pty.c 11 Apr 2022 16:41:07 -0000 @@ -605,50 +605,7 @@ done: int ptcpoll(dev_t dev, int events, struct proc *p) { - struct pt_softc *pti = pt_softc[minor(dev)]; - struct tty *tp = pti->pt_tty; - int revents = 0, s; - - if (!ISSET(tp->t_state, TS_ISOPEN) && ISSET(tp->t_state, TS_CARR_ON)) - goto notopen; - - if (events & (POLLIN | POLLRDNORM)) { - /* - * Need to protect access to t_outq - */ - s = spltty(); - if ((tp->t_outq.c_cc && !ISSET(tp->t_state, TS_TTSTOP)) || - ((pti->pt_flags & PF_PKT) && pti->pt_send) || - ((pti->pt_flags & PF_UCNTL) && pti->pt_ucntl)) - revents |= events & (POLLIN | POLLRDNORM); - splx(s); - } - /* NOTE: POLLHUP and POLLOUT/POLLWRNORM are mutually exclusive */ - if (!ISSET(tp->t_state, TS_CARR_ON)) { - revents |= POLLHUP; - } else if (events & (POLLOUT | POLLWRNORM)) { - if ((pti->pt_flags & PF_REMOTE) ? - (tp->t_canq.c_cc == 0) : - ((tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG(tp) - 2) || - (tp->t_canq.c_cc == 0 && ISSET(tp->t_lflag, ICANON)))) - revents |= events & (POLLOUT | POLLWRNORM); - } - if (events & (POLLPRI | POLLRDBAND)) { - /* If in packet or user control mode, check for data. */ - if (((pti->pt_flags & PF_PKT) && pti->pt_send) || - ((pti->pt_flags & PF_UCNTL) && pti->pt_ucntl)) - revents |= events & (POLLPRI | POLLRDBAND); - } - - if (revents == 0) { -notopen: - if (events & (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) - selrecord(p, &pti->pt_selr); - if (events & (POLLOUT | POLLWRNORM)) - selrecord(p, &pti->pt_selw); - } - - return (revents); + return (0); } void Index: miscfs/fifofs/fifo_vnops.c =================================================================== RCS file: /cvs/src/sys/miscfs/fifofs/fifo_vnops.c,v retrieving revision 1.93 diff -u -p -r1.93 fifo_vnops.c --- miscfs/fifofs/fifo_vnops.c 16 Feb 2022 13:19:33 -0000 1.93 +++ miscfs/fifofs/fifo_vnops.c 11 Apr 2022 16:41:51 -0000 @@ -315,48 +315,7 @@ fifo_ioctl(void *v) int fifo_poll(void *v) { - struct vop_poll_args *ap = v; - struct socket *rso = ap->a_vp->v_fifoinfo->fi_readsock; - struct socket *wso = ap->a_vp->v_fifoinfo->fi_writesock; - int events = 0; - int revents = 0; - int s; - - /* - * FIFOs don't support out-of-band or high priority data. - */ - s = solock(rso); - if (ap->a_fflag & FREAD) - events |= ap->a_events & (POLLIN | POLLRDNORM); - if (ap->a_fflag & FWRITE) - events |= ap->a_events & (POLLOUT | POLLWRNORM); - - if (events & (POLLIN | POLLRDNORM)) { - if (soreadable(rso)) - revents |= events & (POLLIN | POLLRDNORM); - } - /* NOTE: POLLHUP and POLLOUT/POLLWRNORM are mutually exclusive */ - if ((rso->so_state & SS_ISDISCONNECTED) && !(ap->a_events & POLL_NOHUP)) { - revents |= POLLHUP; - } else if (events & (POLLOUT | POLLWRNORM)) { - if (sowriteable(wso)) - revents |= events & (POLLOUT | POLLWRNORM); - } - if (revents == 0) { - /* We want to return POLLHUP even if no valid events set. */ - if (events == 0 && !(ap->a_events & POLL_NOHUP)) - events = POLLIN; - if (events & (POLLIN | POLLRDNORM)) { - selrecord(ap->a_p, &rso->so_rcv.sb_sel); - rso->so_rcv.sb_flags |= SB_SEL; - } - if (events & (POLLOUT | POLLWRNORM)) { - selrecord(ap->a_p, &wso->so_snd.sb_sel); - wso->so_snd.sb_flags |= SB_SEL; - } - } - sounlock(rso, s); - return (revents); + return (0); } int Index: miscfs/fuse/fuse_device.c =================================================================== RCS file: /cvs/src/sys/miscfs/fuse/fuse_device.c,v retrieving revision 1.36 diff -u -p -r1.36 fuse_device.c --- miscfs/fuse/fuse_device.c 11 Mar 2021 13:31:35 -0000 1.36 +++ miscfs/fuse/fuse_device.c 11 Apr 2022 16:41:59 -0000 @@ -511,25 +511,7 @@ end: int fusepoll(dev_t dev, int events, struct proc *p) { - struct fuse_d *fd; - int revents = 0; - - fd = fuse_lookup(minor(dev)); - if (fd == NULL) - return (POLLERR); - - if (events & (POLLIN | POLLRDNORM)) - if (!SIMPLEQ_EMPTY(&fd->fd_fbufs_in)) - revents |= events & (POLLIN | POLLRDNORM); - - if (events & (POLLOUT | POLLWRNORM)) - revents |= events & (POLLOUT | POLLWRNORM); - - if (revents == 0) - if (events & (POLLIN | POLLRDNORM)) - selrecord(p, &fd->fd_rsel); - - return (revents); + return (0); } int Index: net/bpf.c =================================================================== RCS file: /cvs/src/sys/net/bpf.c,v retrieving revision 1.216 diff -u -p -r1.216 bpf.c --- net/bpf.c 17 Mar 2022 14:22:03 -0000 1.216 +++ net/bpf.c 11 Apr 2022 16:42:12 -0000 @@ -1149,38 +1149,7 @@ bpf_ifname(struct bpf_if *bif, struct if int bpfpoll(dev_t dev, int events, struct proc *p) { - struct bpf_d *d; - int revents; - - KERNEL_ASSERT_LOCKED(); - - /* - * An imitation of the FIONREAD ioctl code. - */ - d = bpfilter_lookup(minor(dev)); - - /* - * XXX The USB stack manages it to trigger some race condition - * which causes bpfilter_lookup to return NULL when a USB device - * gets detached while it is up and has an open bpf handler (e.g. - * dhclient). We still should recheck if we can fix the root - * cause of this issue. - */ - if (d == NULL) - return (POLLERR); - - /* Always ready to write data */ - revents = events & (POLLOUT | POLLWRNORM); - - if (events & (POLLIN | POLLRDNORM)) { - mtx_enter(&d->bd_mtx); - if (d->bd_hlen != 0 || (d->bd_immediate && d->bd_slen != 0)) - revents |= events & (POLLIN | POLLRDNORM); - else - selrecord(p, &d->bd_sel); - mtx_leave(&d->bd_mtx); - } - return (revents); + return (0); } const struct filterops bpfread_filtops = { Index: net/if_pppx.c =================================================================== RCS file: /cvs/src/sys/net/if_pppx.c,v retrieving revision 1.114 diff -u -p -r1.114 if_pppx.c --- net/if_pppx.c 22 Feb 2022 01:15:02 -0000 1.114 +++ net/if_pppx.c 11 Apr 2022 16:43:01 -0000 @@ -450,22 +450,7 @@ pppxioctl(dev_t dev, u_long cmd, caddr_t int pppxpoll(dev_t dev, int events, struct proc *p) { - struct pppx_dev *pxd = pppx_dev2pxd(dev); - int revents = 0; - - if (events & (POLLIN | POLLRDNORM)) { - if (!mq_empty(&pxd->pxd_svcq)) - revents |= events & (POLLIN | POLLRDNORM); - } - if (events & (POLLOUT | POLLWRNORM)) - revents |= events & (POLLOUT | POLLWRNORM); - - if (revents == 0) { - if (events & (POLLIN | POLLRDNORM)) - selrecord(p, &pxd->pxd_rsel); - } - - return (revents); + return (0); } int @@ -1213,22 +1198,7 @@ pppacioctl(dev_t dev, u_long cmd, caddr_ int pppacpoll(dev_t dev, int events, struct proc *p) { - struct pppac_softc *sc = pppac_lookup(dev); - int revents = 0; - - if (events & (POLLIN | POLLRDNORM)) { - if (!mq_empty(&sc->sc_mq)) - revents |= events & (POLLIN | POLLRDNORM); - } - if (events & (POLLOUT | POLLWRNORM)) - revents |= events & (POLLOUT | POLLWRNORM); - - if (revents == 0) { - if (events & (POLLIN | POLLRDNORM)) - selrecord(p, &sc->sc_rsel); - } - - return (revents); + return (0); } int Index: net/if_tun.c =================================================================== RCS file: /cvs/src/sys/net/if_tun.c,v retrieving revision 1.236 diff -u -p -r1.236 if_tun.c --- net/if_tun.c 26 Feb 2022 02:15:45 -0000 1.236 +++ net/if_tun.c 11 Apr 2022 16:42:33 -0000 @@ -963,28 +963,7 @@ tappoll(dev_t dev, int events, struct pr int tun_dev_poll(dev_t dev, int events, struct proc *p) { - struct tun_softc *sc; - struct ifnet *ifp; - int revents; - - sc = tun_get(dev); - if (sc == NULL) - return (POLLERR); - - ifp = &sc->sc_if; - revents = 0; - - if (events & (POLLIN | POLLRDNORM)) { - if (!ifq_empty(&ifp->if_snd)) - revents |= events & (POLLIN | POLLRDNORM); - else - selrecord(p, &sc->sc_rsel); - } - if (events & (POLLOUT | POLLWRNORM)) - revents |= events & (POLLOUT | POLLWRNORM); - - tun_put(sc); - return (revents); + return (0); } int Index: sys/selinfo.h =================================================================== RCS file: /cvs/src/sys/sys/selinfo.h,v retrieving revision 1.5 diff -u -p -r1.5 selinfo.h --- sys/selinfo.h 18 Jul 2017 19:20:26 -0000 1.5 +++ sys/selinfo.h 11 Apr 2022 16:42:40 -0000 @@ -50,7 +50,6 @@ struct selinfo { #ifdef _KERNEL struct proc; -void selrecord(struct proc *selector, struct selinfo *); void selwakeup(struct selinfo *); #endif