Source-Changes-HG archive

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

[src/trunk]: src - Change callout_setfunc() to require that the callout handl...



details:   https://anonhg.NetBSD.org/src/rev/a43d24608ac2
branches:  trunk
changeset: 554384:a43d24608ac2
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Oct 27 16:52:01 2003 +0000

description:
- 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).

diffstat:

 share/man/man9/callout.9 |  11 +++++------
 sys/dev/pci/if_txp.c     |   5 +++--
 sys/kern/kern_timeout.c  |   7 ++++---
 sys/netinet/tcp_subr.c   |  16 +++++++++++++---
 4 files changed, 25 insertions(+), 14 deletions(-)

diffs (146 lines):

diff -r 36a9528387f8 -r a43d24608ac2 share/man/man9/callout.9
--- a/share/man/man9/callout.9  Mon Oct 27 16:51:05 2003 +0000
+++ b/share/man/man9/callout.9  Mon Oct 27 16:52:01 2003 +0000
@@ -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 @@
 .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 ,
diff -r 36a9528387f8 -r a43d24608ac2 sys/dev/pci/if_txp.c
--- a/sys/dev/pci/if_txp.c      Mon Oct 27 16:51:05 2003 +0000
+++ b/sys/dev/pci/if_txp.c      Mon Oct 27 16:52:01 2003 +0000
@@ -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_capabilities(sc);
 
+       callout_init(&sc->sc_tick);
        callout_setfunc(&sc->sc_tick, txp_tick, sc);
 
        /*
diff -r 36a9528387f8 -r a43d24608ac2 sys/kern/kern_timeout.c
--- a/sys/kern/kern_timeout.c   Mon Oct 27 16:51:05 2003 +0000
+++ b/sys/kern/kern_timeout.c   Mon Oct 27 16:52:01 2003 +0000
@@ -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 @@
  *
  *     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;
 }
diff -r 36a9528387f8 -r a43d24608ac2 sys/netinet/tcp_subr.c
--- a/sys/netinet/tcp_subr.c    Mon Oct 27 16:51:05 2003 +0000
+++ b/sys/netinet/tcp_subr.c    Mon Oct 27 16:52:01 2003 +0000
@@ -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 @@
  * 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 @@
        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);
 



Home | Main Index | Thread Index | Old Index