bnx: Dispatch state timer to the same CPU as MSI/legacy interrupt CPU
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 24 Jul 2012 12:47:22 +0000 (20:47 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 26 Jul 2012 09:21:20 +0000 (17:21 +0800)
Mainly avoid possible serializer contention

sys/dev/netif/bnx/if_bnx.c
sys/dev/netif/bnx/if_bnxvar.h

index 6d7048c..9217e45 100644 (file)
@@ -2151,6 +2151,8 @@ bnx_attach(device_t dev)
        ifp->if_cpuid = rman_get_cpuid(sc->bnx_irq);
        KKASSERT(ifp->if_cpuid >= 0 && ifp->if_cpuid < ncpus);
 
+       sc->bnx_stat_cpuid = ifp->if_cpuid;
+
        return(0);
 fail:
        bnx_detach(dev);
@@ -2700,6 +2702,8 @@ bnx_tick(void *xsc)
 
        lwkt_serialize_enter(ifp->if_serializer);
 
+       KKASSERT(mycpuid == sc->bnx_stat_cpuid);
+
        bnx_stats_update_regs(sc);
 
        if (sc->bnx_flags & BNX_FLAG_TBI) {
@@ -3062,7 +3066,8 @@ bnx_init(void *xsc)
        ifp->if_flags |= IFF_RUNNING;
        ifp->if_flags &= ~IFF_OACTIVE;
 
-       callout_reset(&sc->bnx_stat_timer, hz, bnx_tick, sc);
+       callout_reset_bycpu(&sc->bnx_stat_timer, hz, bnx_tick, sc,
+           sc->bnx_stat_cpuid);
 }
 
 /*
index 5cbd264..9ad9c4e 100644 (file)
@@ -239,6 +239,7 @@ struct bnx_softc {
        int                     bnx_txcnt;
        int                     bnx_link;
        int                     bnx_link_evt;
+       int                     bnx_stat_cpuid;
        struct callout          bnx_stat_timer;
 
        struct sysctl_ctx_list  bnx_sysctl_ctx;