Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Use sel{record,remove}_knote().



details:   https://anonhg.NetBSD.org/src/rev/adc2bc51691f
branches:  trunk
changeset: 979004:adc2bc51691f
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Dec 11 03:00:09 2020 +0000

description:
Use sel{record,remove}_knote().

diffstat:

 sys/kern/kern_entropy.c |   8 ++++----
 sys/kern/kern_event.c   |   8 ++++----
 sys/kern/subr_log.c     |  13 ++++++-------
 sys/kern/sys_pipe.c     |  10 ++++++----
 sys/kern/tty.c          |  16 ++++++++--------
 sys/kern/tty_pty.c      |  16 ++++++++--------
 sys/kern/uipc_socket.c  |  18 +++++++++---------
 7 files changed, 45 insertions(+), 44 deletions(-)

diffs (truncated from 353 to 300 lines):

diff -r dac00b8026d9 -r adc2bc51691f sys/kern/kern_entropy.c
--- a/sys/kern/kern_entropy.c   Fri Dec 11 01:25:29 2020 +0000
+++ b/sys/kern/kern_entropy.c   Fri Dec 11 03:00:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_entropy.c,v 1.24 2020/09/29 07:51:01 gson Exp $   */
+/*     $NetBSD: kern_entropy.c,v 1.25 2020/12/11 03:00:09 thorpej Exp $        */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.24 2020/09/29 07:51:01 gson Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.25 2020/12/11 03:00:09 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -1409,7 +1409,7 @@
        KASSERT(E->stage >= ENTROPY_WARM);
 
        mutex_enter(&E->lock);
-       SLIST_REMOVE(&E->selq.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&E->selq, kn);
        mutex_exit(&E->lock);
 }
 
@@ -1480,7 +1480,7 @@
                /* Enter into the global select queue.  */
                mutex_enter(&E->lock);
                kn->kn_fop = &entropy_read_filtops;
-               SLIST_INSERT_HEAD(&E->selq.sel_klist, kn, kn_selnext);
+               selrecord_knote(&E->selq, kn);
                mutex_exit(&E->lock);
                return 0;
        case EVFILT_WRITE:
diff -r dac00b8026d9 -r adc2bc51691f sys/kern/kern_event.c
--- a/sys/kern/kern_event.c     Fri Dec 11 01:25:29 2020 +0000
+++ b/sys/kern/kern_event.c     Fri Dec 11 03:00:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_event.c,v 1.108 2020/10/31 01:08:32 christos Exp $        */
+/*     $NetBSD: kern_event.c,v 1.109 2020/12/11 03:00:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.108 2020/10/31 01:08:32 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.109 2020/12/11 03:00:09 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -481,7 +481,7 @@
        kq = ((file_t *)kn->kn_obj)->f_kqueue;
 
        mutex_spin_enter(&kq->kq_lock);
-       SLIST_REMOVE(&kq->kq_sel.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&kq->kq_sel, kn);
        mutex_spin_exit(&kq->kq_lock);
 }
 
@@ -1780,7 +1780,7 @@
 
        kn->kn_fop = &kqread_filtops;
        mutex_enter(&kq->kq_lock);
-       SLIST_INSERT_HEAD(&kq->kq_sel.sel_klist, kn, kn_selnext);
+       selrecord_knote(&kq->kq_sel, kn);
        mutex_exit(&kq->kq_lock);
 
        return 0;
diff -r dac00b8026d9 -r adc2bc51691f sys/kern/subr_log.c
--- a/sys/kern/subr_log.c       Fri Dec 11 01:25:29 2020 +0000
+++ b/sys/kern/subr_log.c       Fri Dec 11 03:00:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_log.c,v 1.59 2018/09/03 16:29:35 riastradh Exp $  */
+/*     $NetBSD: subr_log.c,v 1.60 2020/12/11 03:00:09 thorpej Exp $    */
 
 /*-
  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_log.c,v 1.59 2018/09/03 16:29:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_log.c,v 1.60 2020/12/11 03:00:09 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -262,7 +262,7 @@
 {
 
        mutex_spin_enter(&log_lock);
-       SLIST_REMOVE(&log_selp.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&log_selp, kn);
        mutex_spin_exit(&log_lock);
 }
 
@@ -299,11 +299,9 @@
 static int
 logkqfilter(dev_t dev, struct knote *kn)
 {
-       struct klist *klist;
 
        switch (kn->kn_filter) {
        case EVFILT_READ:
-               klist = &log_selp.sel_klist;
                kn->kn_fop = &logread_filtops;
                break;
 
@@ -311,9 +309,10 @@
                return (EINVAL);
        }
 
+       kn->kn_hook = NULL;
+
        mutex_spin_enter(&log_lock);
-       kn->kn_hook = NULL;
-       SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+       selrecord_knote(&log_selp, kn);
        mutex_spin_exit(&log_lock);
 
        return (0);
diff -r dac00b8026d9 -r adc2bc51691f sys/kern/sys_pipe.c
--- a/sys/kern/sys_pipe.c       Fri Dec 11 01:25:29 2020 +0000
+++ b/sys/kern/sys_pipe.c       Fri Dec 11 03:00:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_pipe.c,v 1.150 2020/06/25 16:19:07 maxv Exp $      */
+/*     $NetBSD: sys_pipe.c,v 1.151 2020/12/11 03:00:09 thorpej Exp $   */
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.150 2020/06/25 16:19:07 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.151 2020/12/11 03:00:09 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -977,6 +977,8 @@
         * Any knote objects still left in the list are
         * the one attached by peer.  Since no one will
         * traverse this list, we just clear it.
+        *
+        * XXX Exposes select/kqueue internals.
         */
        SLIST_INIT(&pipe->pipe_sel.sel_klist);
 
@@ -1029,7 +1031,7 @@
        }
 
        KASSERT(kn->kn_hook == pipe);
-       SLIST_REMOVE(&pipe->pipe_sel.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&pipe->pipe_sel, kn);
        mutex_exit(lock);
 }
 
@@ -1131,7 +1133,7 @@
        }
 
        kn->kn_hook = pipe;
-       SLIST_INSERT_HEAD(&pipe->pipe_sel.sel_klist, kn, kn_selnext);
+       selrecord_knote(&pipe->pipe_sel, kn);
        mutex_exit(lock);
 
        return (0);
diff -r dac00b8026d9 -r adc2bc51691f sys/kern/tty.c
--- a/sys/kern/tty.c    Fri Dec 11 01:25:29 2020 +0000
+++ b/sys/kern/tty.c    Fri Dec 11 03:00:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.294 2020/10/10 18:53:56 christos Exp $       */
+/*     $NetBSD: tty.c,v 1.295 2020/12/11 03:00:09 thorpej Exp $        */
 
 /*-
  * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.294 2020/10/10 18:53:56 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.295 2020/12/11 03:00:09 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1469,7 +1469,7 @@
 
        tp = kn->kn_hook;
        mutex_spin_enter(&tty_lock);
-       SLIST_REMOVE(&tp->t_rsel.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&tp->t_rsel, kn);
        mutex_spin_exit(&tty_lock);
 }
 
@@ -1494,7 +1494,7 @@
 
        tp = kn->kn_hook;
        mutex_spin_enter(&tty_lock);
-       SLIST_REMOVE(&tp->t_wsel.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&tp->t_wsel, kn);
        mutex_spin_exit(&tty_lock);
 }
 
@@ -1532,18 +1532,18 @@
 ttykqfilter(dev_t dev, struct knote *kn)
 {
        struct tty      *tp;
-       struct klist    *klist;
+       struct selinfo  *sip;
 
        if ((tp = cdev_tty(dev)) == NULL)
                return (ENXIO);
 
        switch (kn->kn_filter) {
        case EVFILT_READ:
-               klist = &tp->t_rsel.sel_klist;
+               sip = &tp->t_rsel;
                kn->kn_fop = &ttyread_filtops;
                break;
        case EVFILT_WRITE:
-               klist = &tp->t_wsel.sel_klist;
+               sip = &tp->t_wsel;
                kn->kn_fop = &ttywrite_filtops;
                break;
        default:
@@ -1553,7 +1553,7 @@
        kn->kn_hook = tp;
 
        mutex_spin_enter(&tty_lock);
-       SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+       selrecord_knote(sip, kn);
        mutex_spin_exit(&tty_lock);
 
        return (0);
diff -r dac00b8026d9 -r adc2bc51691f sys/kern/tty_pty.c
--- a/sys/kern/tty_pty.c        Fri Dec 11 01:25:29 2020 +0000
+++ b/sys/kern/tty_pty.c        Fri Dec 11 03:00:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty_pty.c,v 1.145 2019/02/15 18:57:15 mgorny Exp $     */
+/*     $NetBSD: tty_pty.c,v 1.146 2020/12/11 03:00:09 thorpej Exp $    */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.145 2019/02/15 18:57:15 mgorny Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.146 2020/12/11 03:00:09 thorpej Exp $");
 
 #include "opt_ptm.h"
 
@@ -904,7 +904,7 @@
        pti = kn->kn_hook;
 
        mutex_spin_enter(&tty_lock);
-       SLIST_REMOVE(&pti->pt_selr.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&pti->pt_selr, kn);
        mutex_spin_exit(&tty_lock);
 }
 
@@ -958,7 +958,7 @@
        pti = kn->kn_hook;
 
        mutex_spin_enter(&tty_lock);
-       SLIST_REMOVE(&pti->pt_selw.sel_klist, kn, knote, kn_selnext);
+       selremove_knote(&pti->pt_selw, kn);
        mutex_spin_exit(&tty_lock);
 }
 
@@ -1019,15 +1019,15 @@
 ptckqfilter(dev_t dev, struct knote *kn)
 {
        struct pt_softc *pti = pt_softc[minor(dev)];
-       struct klist    *klist;
+       struct selinfo  *sip;
 
        switch (kn->kn_filter) {
        case EVFILT_READ:
-               klist = &pti->pt_selr.sel_klist;
+               sip = &pti->pt_selr;
                kn->kn_fop = &ptcread_filtops;
                break;
        case EVFILT_WRITE:
-               klist = &pti->pt_selw.sel_klist;
+               sip = &pti->pt_selw;
                kn->kn_fop = &ptcwrite_filtops;
                break;
        default:
@@ -1037,7 +1037,7 @@
        kn->kn_hook = pti;
 
        mutex_spin_enter(&tty_lock);
-       SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+       selrecord_knote(sip, kn);
        mutex_spin_exit(&tty_lock);
 
        return 0;



Home | Main Index | Thread Index | Old Index