Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net eliminate gif(4) Tx softint
details: https://anonhg.NetBSD.org/src/rev/c18e8fde1325
branches: trunk
changeset: 346083:c18e8fde1325
user: knakahara <knakahara%NetBSD.org@localhost>
date: Fri Jun 24 04:38:12 2016 +0000
description:
eliminate gif(4) Tx softint
- remove gif_si from struct gif_softc
- directly call gifintr() from gif_output()
- rename gifintr() to gif_start()
- remove Tx softint processing from gif_set_tunnel() and gif_delete_tunnel()
diffstat:
sys/net/if_gif.c | 100 +++++++++---------------------------------------------
sys/net/if_gif.h | 3 +-
2 files changed, 18 insertions(+), 85 deletions(-)
diffs (220 lines):
diff -r 876c3054e470 -r c18e8fde1325 sys/net/if_gif.c
--- a/sys/net/if_gif.c Thu Jun 23 20:32:40 2016 +0000
+++ b/sys/net/if_gif.c Fri Jun 24 04:38:12 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gif.c,v 1.110 2016/06/10 13:27:16 ozaki-r Exp $ */
+/* $NetBSD: if_gif.c,v 1.111 2016/06/24 04:38:12 knakahara Exp $ */
/* $KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.110 2016/06/10 13:27:16 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.111 2016/06/24 04:38:12 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -85,8 +85,6 @@
#include "ioconf.h"
-static void gifintr(void *);
-
/*
* gif global variable definitions
*/
@@ -95,6 +93,7 @@
static void gifattach0(struct gif_softc *);
static int gif_output(struct ifnet *, struct mbuf *,
const struct sockaddr *, const struct rtentry *);
+static void gif_start(struct ifnet *);
static int gif_ioctl(struct ifnet *, u_long, void *);
static int gif_set_tunnel(struct ifnet *, struct sockaddr *,
struct sockaddr *);
@@ -329,8 +328,7 @@
m->m_flags &= ~(M_BCAST|M_MCAST);
if (!(ifp->if_flags & IFF_UP) ||
- sc->gif_psrc == NULL || sc->gif_pdst == NULL ||
- sc->gif_si == NULL) {
+ sc->gif_psrc == NULL || sc->gif_pdst == NULL) {
m_freem(m);
error = ENETDOWN;
goto end;
@@ -356,10 +354,9 @@
splx(s);
goto end;
}
+ splx(s);
- /* softint_schedule() must be called with kpreempt_disabled() */
- softint_schedule(sc->gif_si);
- splx(s);
+ gif_start(ifp);
error = 0;
@@ -370,27 +367,16 @@
}
static void
-gifintr(void *arg)
+gif_start(struct ifnet *ifp)
{
struct gif_softc *sc;
- struct ifnet *ifp;
struct mbuf *m;
int family;
int len;
int s;
int error;
- sc = arg;
- ifp = &sc->gif_if;
-
- /*
- * other CPUs does {set,delete}_tunnel after curcpu have done
- * softint_schedule().
- */
- if (sc->gif_pdst == NULL || sc->gif_psrc == NULL) {
- IFQ_PURGE(&ifp->if_snd);
- return;
- }
+ sc = ifp->if_softc;
/* output processing */
while (1) {
@@ -418,16 +404,21 @@
switch (sc->gif_psrc->sa_family) {
#ifdef INET
case AF_INET:
- mutex_enter(softnet_lock);
+ /* XXX
+ * To add mutex_enter(softnet_lock) or
+ * KASSERT(mutex_owned(softnet_lock)) here, we shold
+ * coordinate softnet_lock between in6_if_up() and
+ * in6_purgeif().
+ */
error = in_gif_output(ifp, family, m);
- mutex_exit(softnet_lock);
break;
#endif
#ifdef INET6
case AF_INET6:
- mutex_enter(softnet_lock);
+ /* XXX
+ * the same as in_gif_output()
+ */
error = in6_gif_output(ifp, family, m);
- mutex_exit(softnet_lock);
break;
#endif
default:
@@ -790,7 +781,6 @@
struct gif_softc *sc2;
struct sockaddr *osrc, *odst;
struct sockaddr *nsrc, *ndst;
- void *osi;
int s;
int error;
@@ -823,33 +813,6 @@
}
/* Firstly, clear old configurations. */
- if (sc->gif_si) {
- osrc = sc->gif_psrc;
- odst = sc->gif_pdst;
- osi = sc->gif_si;
- sc->gif_psrc = NULL;
- sc->gif_pdst = NULL;
- sc->gif_si = NULL;
- /*
- * At this point, gif_output() does not softint_schedule()
- * any more. However, there are below 2 fears of other CPUs
- * which would cause panic because of the race between
- * softint_execute() and softint_disestablish().
- * (a) gif_output() has done softint_schedule(), and softint
- * (gifintr()) is waiting for execution
- * => This pattern is avoided by waiting SOFTINT_PENDING
- * CPUs in softint_disestablish()
- * (b) gifintr() is already running
- * => This pattern is avoided by waiting SOFTINT_ACTIVE
- * CPUs in softint_disestablish()
- */
-
- softint_disestablish(osi);
- sc->gif_psrc = osrc;
- sc->gif_pdst = odst;
- osrc = NULL;
- odst = NULL;
- }
/* XXX we can detach from both, but be polite just in case */
if (sc->gif_psrc)
(void)gif_encap_detach(sc);
@@ -874,20 +837,6 @@
continue;
}
-
- sc->gif_si = softint_establish(SOFTINT_NET, gifintr, sc);
- if (sc->gif_si == NULL) {
- (void)gif_encap_detach(sc);
-
- /* rollback to the last configuration. */
- nsrc = osrc;
- ndst = odst;
- osrc = sc->gif_psrc;
- odst = sc->gif_pdst;
-
- error = ENOMEM;
- continue;
- }
} while (error != 0 && (nsrc != NULL && ndst != NULL));
/* Thirdly, even rollback failed, clear configurations. */
if (error) {
@@ -915,25 +864,10 @@
gif_delete_tunnel(struct ifnet *ifp)
{
struct gif_softc *sc = ifp->if_softc;
- struct sockaddr *osrc, *odst;
- void *osi;
int s;
s = splsoftnet();
- if (sc->gif_si) {
- osrc = sc->gif_psrc;
- odst = sc->gif_pdst;
- osi = sc->gif_si;
-
- sc->gif_psrc = NULL;
- sc->gif_pdst = NULL;
- sc->gif_si = NULL;
-
- softint_disestablish(osi);
- sc->gif_psrc = osrc;
- sc->gif_pdst = odst;
- }
if (sc->gif_psrc) {
sockaddr_free(sc->gif_psrc);
sc->gif_psrc = NULL;
diff -r 876c3054e470 -r c18e8fde1325 sys/net/if_gif.h
--- a/sys/net/if_gif.h Thu Jun 23 20:32:40 2016 +0000
+++ b/sys/net/if_gif.h Fri Jun 24 04:38:12 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gif.h,v 1.23 2016/05/31 03:52:40 knakahara Exp $ */
+/* $NetBSD: if_gif.h,v 1.24 2016/06/24 04:38:12 knakahara Exp $ */
/* $KAME: if_gif.h,v 1.23 2001/07/27 09:21:42 itojun Exp $ */
/*
@@ -59,7 +59,6 @@
const struct encaptab *encap_cookie4;
const struct encaptab *encap_cookie6;
LIST_ENTRY(gif_softc) gif_list; /* list of all gifs */
- void *gif_si; /* softintr handle */
};
#define GIF_ROUTE_TTL 10
Home |
Main Index |
Thread Index |
Old Index