Source-Changes-HG archive

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

[src/trunk]: src/sys/net Kill tsleep/wakeup and use cv



details:   https://anonhg.NetBSD.org/src/rev/7a09d77b449d
branches:  trunk
changeset: 821315:7a09d77b449d
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Wed Feb 01 08:16:42 2017 +0000

description:
Kill tsleep/wakeup and use cv

diffstat:

 sys/net/bpf.c     |  22 +++++++++++++++++-----
 sys/net/bpfdesc.h |   6 +++++-
 2 files changed, 22 insertions(+), 6 deletions(-)

diffs (91 lines):

diff -r 7a81b31cf6fb -r 7a09d77b449d sys/net/bpf.c
--- a/sys/net/bpf.c     Wed Feb 01 08:15:15 2017 +0000
+++ b/sys/net/bpf.c     Wed Feb 01 08:16:42 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpf.c,v 1.210 2017/02/01 08:15:15 ozaki-r Exp $        */
+/*     $NetBSD: bpf.c,v 1.211 2017/02/01 08:16:42 ozaki-r Exp $        */
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.210 2017/02/01 08:15:15 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.211 2017/02/01 08:16:42 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -523,6 +523,8 @@
        d->bd_jitcode = NULL;
        BPF_DLIST_ENTRY_INIT(d);
        BPFIF_DLIST_ENTRY_INIT(d);
+       d->bd_mtx = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
+       cv_init(&d->bd_cv, "bpf");
 
        mutex_enter(&bpf_mtx);
        BPF_DLIST_WRITER_INSEART_HEAD(d);
@@ -577,6 +579,9 @@
        callout_destroy(&d->bd_callout);
        seldestroy(&d->bd_sel);
        softint_disestablish(d->bd_sih);
+       mutex_obj_free(d->bd_mtx);
+       cv_destroy(&d->bd_cv);
+
        kmem_free(d, sizeof(*d));
 
        return (0);
@@ -644,8 +649,11 @@
                        ROTATE_BUFFERS(d);
                        break;
                }
-               error = tsleep(d, PRINET|PCATCH, "bpf",
-                               d->bd_rtout);
+
+               mutex_enter(d->bd_mtx);
+               error = cv_timedwait_sig(&d->bd_cv, d->bd_mtx, d->bd_rtout);
+               mutex_exit(d->bd_mtx);
+
                if (error == EINTR || error == ERESTART) {
                        splx(s);
                        KERNEL_UNLOCK_ONE(NULL);
@@ -705,7 +713,11 @@
 static inline void
 bpf_wakeup(struct bpf_d *d)
 {
-       wakeup(d);
+
+       mutex_enter(d->bd_mtx);
+       cv_broadcast(&d->bd_cv);
+       mutex_exit(d->bd_mtx);
+
        if (d->bd_async)
                softint_schedule(d->bd_sih);
        selnotify(&d->bd_sel, 0, 0);
diff -r 7a81b31cf6fb -r 7a09d77b449d sys/net/bpfdesc.h
--- a/sys/net/bpfdesc.h Wed Feb 01 08:15:15 2017 +0000
+++ b/sys/net/bpfdesc.h Wed Feb 01 08:16:42 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpfdesc.h,v 1.42 2017/02/01 08:13:45 ozaki-r Exp $     */
+/*     $NetBSD: bpfdesc.h,v 1.43 2017/02/01 08:16:42 ozaki-r Exp $     */
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -47,6 +47,8 @@
 #include <net/bpfjit.h>                        /* for bpfjit_function_t */
 #ifdef _KERNEL
 #include <sys/pslist.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
 #endif
 
 /*
@@ -111,6 +113,8 @@
 #ifdef _KERNEL
        struct pslist_entry     bd_bif_dlist_entry; /* For bpf_if */
        struct pslist_entry     bd_bpf_dlist_entry; /* For the global list */
+       kmutex_t        *bd_mtx;
+       kcondvar_t      bd_cv;
 #endif
 };
 



Home | Main Index | Thread Index | Old Index