- Change callout_setfunc() to require that the callout handle is already
initialized. Update the txp(4) to compensate. - Statically initialize the TCP timer callout handles in the tcpcb template. We still use callout_setfunc(), but that call is now much less expensive. Add a comment that the compiler is likely to unroll the loop (so don't sweat that it's there).
This commit is contained in:
parent
e05d95b990
commit
db71356cd1
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: callout.9,v 1.12 2003/10/19 14:37:12 he Exp $
|
||||
.\" $NetBSD: callout.9,v 1.13 2003/10/27 16:52:01 thorpej Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2000, 2003 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
|
@ -34,7 +34,7 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd July 20, 2003
|
||||
.Dd October 26, 2003
|
||||
.Dt CALLOUT 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -134,21 +134,20 @@ status is cleared.
|
|||
.Pp
|
||||
The
|
||||
.Fn callout_setfunc
|
||||
function initializes the callout handle
|
||||
function sets the function and argument of the callout handle
|
||||
.Fa c
|
||||
for use and sets the function and argument to
|
||||
to
|
||||
.Fa func
|
||||
and
|
||||
.Fa arg
|
||||
respectively.
|
||||
The callout handle must already be initialized.
|
||||
If a callout will always be used with the same function and argument,
|
||||
then
|
||||
.Fn callout_setfunc
|
||||
used in conjunction with
|
||||
.Fn callout_schedule
|
||||
is slightly more efficient than using
|
||||
.Fn callout_init
|
||||
and
|
||||
.Fn callout_reset .
|
||||
If it is inconvenient to call
|
||||
.Fn callout_setfunc ,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_txp.c,v 1.4 2003/08/20 17:41:38 drochner Exp $ */
|
||||
/* $NetBSD: if_txp.c,v 1.5 2003/10/27 16:52:01 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.4 2003/08/20 17:41:38 drochner Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.5 2003/10/27 16:52:01 thorpej Exp $");
|
||||
|
||||
#include "bpfilter.h"
|
||||
#include "opt_inet.h"
|
||||
|
@ -342,6 +342,7 @@ txp_attach(parent, self, aux)
|
|||
|
||||
txp_capabilities(sc);
|
||||
|
||||
callout_init(&sc->sc_tick);
|
||||
callout_setfunc(&sc->sc_tick, txp_tick, sc);
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_timeout.c,v 1.11 2003/09/25 10:44:11 scw Exp $ */
|
||||
/* $NetBSD: kern_timeout.c,v 1.12 2003/10/27 16:52:01 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -66,7 +66,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.11 2003/09/25 10:44:11 scw Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.12 2003/10/27 16:52:01 thorpej Exp $");
|
||||
|
||||
/*
|
||||
* Adapted from OpenBSD: kern_timeout.c,v 1.15 2002/12/08 04:21:07 art Exp,
|
||||
|
@ -231,12 +231,13 @@ callout_init(struct callout *c)
|
|||
*
|
||||
* Initialize a callout structure and set the function and
|
||||
* argument.
|
||||
*
|
||||
* NOTE: THE CALLOUT STRUCTURE MUST ALREADY BE INITIALIZED!
|
||||
*/
|
||||
void
|
||||
callout_setfunc(struct callout *c, void (*func)(void *), void *arg)
|
||||
{
|
||||
|
||||
memset(c, 0, sizeof(*c));
|
||||
c->c_func = func;
|
||||
c->c_arg = arg;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tcp_subr.c,v 1.158 2003/10/25 08:13:28 christos Exp $ */
|
||||
/* $NetBSD: tcp_subr.c,v 1.159 2003/10/27 16:52:01 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
|
@ -98,7 +98,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.158 2003/10/25 08:13:28 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.159 2003/10/27 16:52:01 thorpej Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
|
@ -894,6 +894,16 @@ tcp_respond(tp, template, m, th0, ack, seq, flags)
|
|||
* the new TCPCB instead.
|
||||
*/
|
||||
static struct tcpcb tcpcb_template = {
|
||||
/*
|
||||
* If TCP_NTIMERS ever changes, we'll need to update this
|
||||
* initializer.
|
||||
*/
|
||||
.t_timer = {
|
||||
CALLOUT_INITIALIZER,
|
||||
CALLOUT_INITIALIZER,
|
||||
CALLOUT_INITIALIZER,
|
||||
CALLOUT_INITIALIZER,
|
||||
},
|
||||
.t_delack_ch = CALLOUT_INITIALIZER,
|
||||
|
||||
.t_srtt = TCPTV_SRTTBASE,
|
||||
|
@ -962,7 +972,7 @@ tcp_newtcpcb(family, aux)
|
|||
tp->t_family = family; /* may be overridden later on */
|
||||
LIST_INIT(&tp->t_sc); /* XXX can template this */
|
||||
|
||||
/* XXX Figure out a way to make this a bit less painful. */
|
||||
/* Don't sweat this loop; hopefully the compiler will unroll it. */
|
||||
for (i = 0; i < TCPT_NTIMERS; i++)
|
||||
TCP_TIMER_INIT(tp, i);
|
||||
|
||||
|
|
Loading…
Reference in New Issue