Source-Changes-HG archive

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

[src/trunk]: src/sys/net Revert extra wating codes.



details:   https://anonhg.NetBSD.org/src/rev/2ba76c183db3
branches:  trunk
changeset: 812804:2ba76c183db3
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Mon Jan 04 07:50:08 2016 +0000

description:
Revert extra wating codes.

PR kern/50522 is actually fixed by sys/kern/kern_softint.c:r1.42, so waiting
codes in if_gif.c is not required.

diffstat:

 sys/net/if_gif.c |  60 +++++++++----------------------------------------------
 sys/net/if_gif.h |  14 +------------
 2 files changed, 11 insertions(+), 63 deletions(-)

diffs (175 lines):

diff -r ad6593e6c127 -r 2ba76c183db3 sys/net/if_gif.c
--- a/sys/net/if_gif.c  Mon Jan 04 03:00:24 2016 +0000
+++ b/sys/net/if_gif.c  Mon Jan 04 07:50:08 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_gif.c,v 1.102 2015/12/11 07:59:14 knakahara Exp $   */
+/*     $NetBSD: if_gif.c,v 1.103 2016/01/04 07:50:08 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.102 2015/12/11 07:59:14 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.103 2016/01/04 07:50:08 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -53,7 +53,6 @@
 #include <sys/cpu.h>
 #include <sys/intr.h>
 #include <sys/kmem.h>
-#include <sys/atomic.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
@@ -147,10 +146,6 @@
 gifattach0(struct gif_softc *sc)
 {
 
-       sc->gif_si_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
-       KASSERT(sc->gif_si_lock != NULL);
-       cv_init(&sc->gif_si_cv, "if_gif_cv");
-       sc->gif_si_refs = 0;
        sc->encap_cookie4 = sc->encap_cookie6 = NULL;
 
        sc->gif_if.if_addrlen = 0;
@@ -179,8 +174,6 @@
        if_detach(ifp);
        rtcache_free(&sc->gif_ro);
 
-       cv_destroy(&sc->gif_si_cv);
-       mutex_obj_free(sc->gif_si_lock);
        kmem_free(sc, sizeof(struct gif_softc));
 
        return (0);
@@ -356,21 +349,12 @@
        sc = arg;
        ifp = &sc->gif_if;
 
-       atomic_inc_uint(&sc->gif_si_refs);
-
        /*
-        * pattern (a) (see also gif_set_tunnel())
         * 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);
-
-               if (atomic_dec_uint_nv(&sc->gif_si_refs) == 0) {
-                       mutex_enter(sc->gif_si_lock);
-                       cv_broadcast(&sc->gif_si_cv);
-                       mutex_exit(sc->gif_si_lock);
-               }
                return;
        }
 
@@ -425,16 +409,6 @@
                        ifp->if_obytes += len;
                }
        }
-
-       /*
-        * pattern (b) (see also gif_set_tunnel())
-        * other CPUs begin {set,delete}_tunnel while curcpu si doing gifintr.
-        */
-       if (atomic_dec_uint_nv(&sc->gif_si_refs) == 0) {
-               mutex_enter(sc->gif_si_lock);
-               cv_broadcast(&sc->gif_si_cv);
-               mutex_exit(sc->gif_si_lock);
-       }
 }
 
 void
@@ -822,27 +796,20 @@
                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.
-                *     (a) gif_output() has done softint_schedule(),and softint
+                * 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
-                * see also gifintr()
+                *         => This pattern is avoided by waiting SOFTINT_ACTIVE
+                *            CPUs in softint_disestablish()
                 */
 
-               /*
-                * To avoid the above fears, wait for gifintr() completion of
-                * all CPUs here.
-                */
-               mutex_enter(sc->gif_si_lock);
-               while (sc->gif_si_refs > 0) {
-                       aprint_debug("%s: cv_wait on gif_softc\n", __func__);
-                       cv_wait(&sc->gif_si_cv, sc->gif_si_lock);
-               }
-               mutex_exit(sc->gif_si_lock);
-
                softint_disestablish(osi);
                sc->gif_psrc = osrc;
                sc->gif_pdst = odst;
@@ -929,13 +896,6 @@
                sc->gif_pdst = NULL;
                sc->gif_si = NULL;
 
-               mutex_enter(sc->gif_si_lock);
-               while (sc->gif_si_refs > 0) {
-                       aprint_debug("%s: cv_wait on gif_softc\n", __func__);
-                       cv_wait(&sc->gif_si_cv, sc->gif_si_lock);
-               }
-               mutex_exit(sc->gif_si_lock);
-
                softint_disestablish(osi);
                sc->gif_psrc = osrc;
                sc->gif_pdst = odst;
diff -r ad6593e6c127 -r 2ba76c183db3 sys/net/if_gif.h
--- a/sys/net/if_gif.h  Mon Jan 04 03:00:24 2016 +0000
+++ b/sys/net/if_gif.h  Mon Jan 04 07:50:08 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_gif.h,v 1.20 2015/12/11 07:59:14 knakahara Exp $    */
+/*     $NetBSD: if_gif.h,v 1.21 2016/01/04 07:50:08 knakahara Exp $    */
 /*     $KAME: if_gif.h,v 1.23 2001/07/27 09:21:42 itojun Exp $ */
 
 /*
@@ -38,8 +38,6 @@
 #define _NET_IF_GIF_H_
 
 #include <sys/queue.h>
-#include <sys/mutex.h>
-#include <sys/condvar.h>
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -62,21 +60,11 @@
        const struct encaptab *encap_cookie6;
        LIST_ENTRY(gif_softc) gif_list; /* list of all gifs */
        void    *gif_si;                /* softintr handle */
-
-       struct si_sync { /* can access without gif_lock */
-               unsigned int    si_refs;        /* reference count for gif_si */
-               kcondvar_t      si_cv;          /* wait for softint completion */
-               kmutex_t        *si_lock;       /* lock for gif_si_sync */
-       } gif_si_sync;
 };
 #define GIF_ROUTE_TTL  10
 
 #define gif_ro gifsc_gifscr.gifscr_ro
 
-#define gif_si_refs    gif_si_sync.si_refs
-#define gif_si_cv      gif_si_sync.si_cv
-#define gif_si_lock    gif_si_sync.si_lock
-
 #define GIF_MTU                (1280)  /* Default MTU */
 #define        GIF_MTU_MIN     (1280)  /* Minimum MTU */
 #define        GIF_MTU_MAX     (8192)  /* Maximum MTU */



Home | Main Index | Thread Index | Old Index