Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Change if_slowtimo_ch to a pointer
details: https://anonhg.NetBSD.org/src/rev/ad84f6eeeb59
branches: trunk
changeset: 334010:ad84f6eeeb59
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed Nov 26 09:38:42 2014 +0000
description:
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@.
diffstat:
sys/net/if.c | 17 ++++++++++-------
sys/net/if.h | 5 +++--
2 files changed, 13 insertions(+), 9 deletions(-)
diffs (78 lines):
diff -r 64c84b069221 -r ad84f6eeeb59 sys/net/if.c
--- a/sys/net/if.c Wed Nov 26 07:43:04 2014 +0000
+++ b/sys/net/if.c Wed Nov 26 09:38:42 2014 +0000
@@ -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 @@
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 @@
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 @@
(*ifp->if_slowtimo)(ifp);
splx(s);
- callout_schedule(&ifp->if_slowtimo_ch, hz / IFNET_SLOWHZ);
+ callout_schedule(ifp->if_slowtimo_ch, hz / IFNET_SLOWHZ);
}
/*
diff -r 64c84b069221 -r ad84f6eeeb59 sys/net/if.h
--- a/sys/net/if.h Wed Nov 26 07:43:04 2014 +0000
+++ b/sys/net/if.h Wed Nov 26 09:38:42 2014 +0000
@@ -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 @@
struct bridge_softc;
struct bridge_iflist;
+struct callout;
typedef struct ifnet {
void *if_softc; /* lower-level data for this if */
@@ -344,7 +345,7 @@
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;
Home |
Main Index |
Thread Index |
Old Index