Module Name: src Committed By: ozaki-r Date: Wed Nov 26 09:38:42 UTC 2014
Modified Files: src/sys/net: if.c if.h Log Message: Change if_slowtimo_ch to a pointer One benefit to do so is to reduce memory used for struct callout; we can avoid to allocate struct callout for interfaces that don't use callout. Requested by uebayasi@. To generate a diff of this commit: cvs rdiff -u -r1.296 -r1.297 src/sys/net/if.c cvs rdiff -u -r1.178 -r1.179 src/sys/net/if.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.c diff -u src/sys/net/if.c:1.296 src/sys/net/if.c:1.297 --- src/sys/net/if.c:1.296 Wed Nov 26 07:43:04 2014 +++ src/sys/net/if.c Wed Nov 26 09:38:42 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.296 2014/11/26 07:43:04 ozaki-r Exp $ */ +/* $NetBSD: if.c,v 1.297 2014/11/26 09:38:42 ozaki-r Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc. @@ -90,7 +90,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.296 2014/11/26 07:43:04 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.297 2014/11/26 09:38:42 ozaki-r Exp $"); #include "opt_inet.h" @@ -635,8 +635,10 @@ if_attach(ifnet_t *ifp) rt_ifannouncemsg(ifp, IFAN_ARRIVAL); if (ifp->if_slowtimo != NULL) { - callout_init(&ifp->if_slowtimo_ch, 0); - callout_setfunc(&ifp->if_slowtimo_ch, if_slowtimo, ifp); + ifp->if_slowtimo_ch = + kmem_zalloc(sizeof(*ifp->if_slowtimo_ch), KM_SLEEP); + callout_init(ifp->if_slowtimo_ch, 0); + callout_setfunc(ifp->if_slowtimo_ch, if_slowtimo, ifp); if_slowtimo(ifp); } } @@ -739,8 +741,9 @@ if_detach(struct ifnet *ifp) s = splnet(); if (ifp->if_slowtimo != NULL) { - callout_halt(&ifp->if_slowtimo_ch, NULL); - callout_destroy(&ifp->if_slowtimo_ch); + callout_halt(ifp->if_slowtimo_ch, NULL); + callout_destroy(ifp->if_slowtimo_ch); + kmem_free(ifp->if_slowtimo_ch, sizeof(*ifp->if_slowtimo_ch)); } /* @@ -1516,7 +1519,7 @@ if_slowtimo(void *arg) (*ifp->if_slowtimo)(ifp); splx(s); - callout_schedule(&ifp->if_slowtimo_ch, hz / IFNET_SLOWHZ); + callout_schedule(ifp->if_slowtimo_ch, hz / IFNET_SLOWHZ); } /* Index: src/sys/net/if.h diff -u src/sys/net/if.h:1.178 src/sys/net/if.h:1.179 --- src/sys/net/if.h:1.178 Wed Nov 26 07:43:04 2014 +++ src/sys/net/if.h Wed Nov 26 09:38:42 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: if.h,v 1.178 2014/11/26 07:43:04 ozaki-r Exp $ */ +/* $NetBSD: if.h,v 1.179 2014/11/26 09:38:42 ozaki-r Exp $ */ /*- * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -245,6 +245,7 @@ TAILQ_HEAD(ifnet_head, ifnet); /* the a struct bridge_softc; struct bridge_iflist; +struct callout; typedef struct ifnet { void *if_softc; /* lower-level data for this if */ @@ -344,7 +345,7 @@ typedef struct ifnet { int (*if_setflags)(struct ifnet *, const short); struct ifnet_lock *if_ioctl_lock; #ifdef _KERNEL /* XXX kvm(3) */ - callout_t if_slowtimo_ch; + struct callout *if_slowtimo_ch; #endif } ifnet_t;