Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci user-friendly interrupt affinity offset



details:   https://anonhg.NetBSD.org/src/rev/ff97e93ebef5
branches:  trunk
changeset: 345322:ff97e93ebef5
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Thu May 19 08:22:37 2016 +0000

description:
user-friendly interrupt affinity offset

diffstat:

 sys/dev/pci/if_wm.c |  32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)

diffs (81 lines):

diff -r 4623a1c2c738 -r ff97e93ebef5 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Thu May 19 08:20:06 2016 +0000
+++ b/sys/dev/pci/if_wm.c       Thu May 19 08:22:37 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.403 2016/05/19 08:20:06 knakahara Exp $    */
+/*     $NetBSD: if_wm.c,v 1.404 2016/05/19 08:22:37 knakahara Exp $    */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.403 2016/05/19 08:20:06 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.404 2016/05/19 08:22:37 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -408,6 +408,8 @@
        int sc_nrxqueues;
        struct wm_rxqueue *sc_rxq;
 
+       int sc_affinity_offset;
+
 #ifdef WM_EVENT_COUNTERS
        /* Event counters. */
        struct evcnt sc_ev_txsstall;    /* Tx stalled due to no txs */
@@ -4377,11 +4379,20 @@
        const char *intrstr = NULL;
        char intrbuf[PCI_INTRSTR_LEN];
        char intr_xname[INTRDEVNAMEBUF];
-       /*
-        * To avoid other devices' interrupts, the affinity of Tx/Rx interrupts
-        * start from CPU#1.
-        */
-       int affinity_offset = 1;
+
+       if (sc->sc_ntxqueues + sc->sc_nrxqueues < ncpu) {
+               /*
+                * To avoid other devices' interrupts, the affinity of Tx/Rx
+                * interrupts start from CPU#1.
+                */
+               sc->sc_affinity_offset = 1;
+       } else {
+               /*
+                * In this case, this device use all CPUs. So, we unify
+                * affinitied cpu_index to msix vector number for readability.
+                */
+               sc->sc_affinity_offset = 0;
+       }
 
        error = wm_alloc_txrx_queues(sc);
        if (error) {
@@ -4399,7 +4410,7 @@
        tx_established = 0;
        for (qidx = 0; qidx < sc->sc_ntxqueues; qidx++) {
                struct wm_txqueue *txq = &sc->sc_txq[qidx];
-               int affinity_to = (affinity_offset + intr_idx) % ncpu;
+               int affinity_to = (sc->sc_affinity_offset + intr_idx) % ncpu;
 
                intrstr = pci_intr_string(pc, sc->sc_intrs[intr_idx], intrbuf,
                    sizeof(intrbuf));
@@ -4446,7 +4457,7 @@
        rx_established = 0;
        for (qidx = 0; qidx < sc->sc_nrxqueues; qidx++) {
                struct wm_rxqueue *rxq = &sc->sc_rxq[qidx];
-               int affinity_to = (affinity_offset + intr_idx) % ncpu;
+               int affinity_to = (sc->sc_affinity_offset + intr_idx) % ncpu;
 
                intrstr = pci_intr_string(pc, sc->sc_intrs[intr_idx], intrbuf,
                    sizeof(intrbuf));
@@ -6745,8 +6756,7 @@
         * TODO:
         * destribute by flowid(RSS has value).
         */
-
-       return cpuid % sc->sc_ntxqueues;
+       return (cpuid + sc->sc_affinity_offset) % sc->sc_ntxqueues;
 }
 
 static int



Home | Main Index | Thread Index | Old Index