Module Name: src
Committed By: ozaki-r
Date: Wed Feb 1 08:16:42 UTC 2017
Modified Files:
src/sys/net: bpf.c bpfdesc.h
Log Message:
Kill tsleep/wakeup and use cv
To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/sys/net/bpf.c
cvs rdiff -u -r1.42 -r1.43 src/sys/net/bpfdesc.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/net/bpf.c
diff -u src/sys/net/bpf.c:1.210 src/sys/net/bpf.c:1.211
--- src/sys/net/bpf.c:1.210 Wed Feb 1 08:15:15 2017
+++ src/sys/net/bpf.c Wed Feb 1 08:16:42 2017
@@ -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 @@ bpfopen(dev_t dev, int flag, int mode, s
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 @@ bpf_close(struct file *fp)
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 @@ bpf_read(struct file *fp, off_t *offp, s
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 @@ done:
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);
Index: src/sys/net/bpfdesc.h
diff -u src/sys/net/bpfdesc.h:1.42 src/sys/net/bpfdesc.h:1.43
--- src/sys/net/bpfdesc.h:1.42 Wed Feb 1 08:13:45 2017
+++ src/sys/net/bpfdesc.h Wed Feb 1 08:16:42 2017
@@ -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 @@ struct bpf_d {
#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
};