Module Name: src Committed By: riastradh Date: Sun Mar 13 21:32:43 UTC 2022
Modified Files: src/sys/net: if_tun.c if_tun.h Log Message: tun(4): Omit TUN_RWAIT micro-optimization. cv_broadcast aleady has a fast path for no-waiters. To generate a diff of this commit: cvs rdiff -u -r1.169 -r1.170 src/sys/net/if_tun.c cvs rdiff -u -r1.21 -r1.22 src/sys/net/if_tun.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/if_tun.c diff -u src/sys/net/if_tun.c:1.169 src/sys/net/if_tun.c:1.170 --- src/sys/net/if_tun.c:1.169 Sun Mar 13 21:32:35 2022 +++ src/sys/net/if_tun.c Sun Mar 13 21:32:43 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_tun.c,v 1.169 2022/03/13 21:32:35 riastradh Exp $ */ +/* $NetBSD: if_tun.c,v 1.170 2022/03/13 21:32:43 riastradh Exp $ */ /* * Copyright (c) 1988, Julian Onions <j...@cs.nott.ac.uk> @@ -19,7 +19,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.169 2022/03/13 21:32:35 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.170 2022/03/13 21:32:43 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -330,10 +330,7 @@ tun_clone_destroy(struct ifnet *ifp) } mutex_exit(&tun_softc_lock); - if (tp->tun_flags & TUN_RWAIT) { - tp->tun_flags &= ~TUN_RWAIT; - cv_broadcast(&tp->tun_cv); - } + cv_broadcast(&tp->tun_cv); if (tp->tun_flags & TUN_ASYNC && tp->tun_pgid) fownsignal(tp->tun_pgid, SIGIO, POLL_HUP, 0, NULL); selnotify(&tp->tun_rsel, 0, NOTE_SUBMIT); @@ -654,15 +651,10 @@ tun_output(struct ifnet *ifp, struct mbu } mutex_enter(&tp->tun_lock); - if (tp->tun_flags & TUN_RWAIT) { - tp->tun_flags &= ~TUN_RWAIT; - cv_broadcast(&tp->tun_cv); - } + cv_broadcast(&tp->tun_cv); if (tp->tun_flags & TUN_ASYNC && tp->tun_pgid) softint_schedule(tp->tun_isih); - selnotify(&tp->tun_rsel, 0, NOTE_SUBMIT); - mutex_exit(&tp->tun_lock); out: if (error && m0) @@ -823,8 +815,6 @@ tunread(dev_t dev, struct uio *uio, int goto out; } - tp->tun_flags &= ~TUN_RWAIT; - do { IFQ_DEQUEUE(&ifp->if_snd, m0); if (m0 == 0) { @@ -832,7 +822,6 @@ tunread(dev_t dev, struct uio *uio, int error = EWOULDBLOCK; goto out; } - tp->tun_flags |= TUN_RWAIT; if (cv_wait_sig(&tp->tun_cv, &tp->tun_lock)) { error = EINTR; goto out; @@ -1024,10 +1013,7 @@ tunstart(struct ifnet *ifp) mutex_enter(&tp->tun_lock); if (!IF_IS_EMPTY(&ifp->if_snd)) { - if (tp->tun_flags & TUN_RWAIT) { - tp->tun_flags &= ~TUN_RWAIT; - cv_broadcast(&tp->tun_cv); - } + cv_broadcast(&tp->tun_cv); if (tp->tun_flags & TUN_ASYNC && tp->tun_pgid) softint_schedule(tp->tun_osih); Index: src/sys/net/if_tun.h diff -u src/sys/net/if_tun.h:1.21 src/sys/net/if_tun.h:1.22 --- src/sys/net/if_tun.h:1.21 Sun Mar 13 21:31:58 2022 +++ src/sys/net/if_tun.h Sun Mar 13 21:32:43 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_tun.h,v 1.21 2022/03/13 21:31:58 riastradh Exp $ */ +/* $NetBSD: if_tun.h,v 1.22 2022/03/13 21:32:43 riastradh Exp $ */ /* * Copyright (c) 1988, Julian Onions <j...@cs.nott.ac.uk> @@ -41,7 +41,7 @@ struct tun_softc { #define TUN_RCOLL 0x0004 #define TUN_IASET 0x0008 #define TUN_DSTADDR 0x0010 -#define TUN_RWAIT 0x0040 +#define TUN_UNUSED0 0x0040 /* was TUN_RWAIT */ #define TUN_ASYNC 0x0080 #define TUN_NBIO 0x0100 #define TUN_PREPADDR 0x0200