Index | Thread | Search

From:
Jan Klemkow <jan@openbsd.org>
Subject:
Limit interface queues to no. of softnets
To:
tech@openbsd.org
Date:
Thu, 26 Jun 2025 14:09:46 +0200

Download raw body.

Thread
  • Jan Klemkow:

    Limit interface queues to no. of softnets

Hi,

The following diff limits the no. of queue per network interface to the
no. of running softnets threads.  So, the no. of packet producers it
never higher than the no. of consumers and we save a lot of interrupt
slots.  Thus, we can support more network interfaces per system.

ok?

bye,
Jan

Index: dev/pci/if_bnxt.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_bnxt.c,v
diff -u -p -r1.52 if_bnxt.c
--- dev/pci/if_bnxt.c	6 Oct 2024 23:43:18 -0000	1.52
+++ dev/pci/if_bnxt.c	26 Jun 2025 11:30:07 -0000
@@ -546,7 +546,8 @@ bnxt_attach(struct device *parent, struc
 			sc->sc_ih = pci_intr_establish(sc->sc_pc, ih,
 			    IPL_NET | IPL_MPSAFE, bnxt_admin_intr, sc, DEVNAME(sc));
 			sc->sc_intrmap = intrmap_create(&sc->sc_dev,
-			    nmsix - 1, BNXT_MAX_QUEUES, INTRMAP_POWEROF2);
+			    nmsix - 1, MIN(BNXT_MAX_QUEUES, net_sn_count()),
+			    INTRMAP_POWEROF2);
 			sc->sc_nqueues = intrmap_count(sc->sc_intrmap);
 			KASSERT(sc->sc_nqueues > 0);
 			KASSERT(powerof2(sc->sc_nqueues));
Index: dev/pci/if_ix.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_ix.c,v
diff -u -p -r1.220 if_ix.c
--- dev/pci/if_ix.c	22 May 2025 10:50:10 -0000	1.220
+++ dev/pci/if_ix.c	26 Jun 2025 11:31:20 -0000
@@ -1854,7 +1854,8 @@ ixgbe_setup_msix(struct ix_softc *sc)
 	/* XXX the number of queues is limited to what we can keep stats on */
 	maxq = (sc->hw.mac.type == ixgbe_mac_82598EB) ? 8 : 16;
 
-	sc->sc_intrmap = intrmap_create(&sc->dev, nmsix, maxq, 0);
+	sc->sc_intrmap = intrmap_create(&sc->dev, nmsix,
+	    MIN(maxq, net_sn_count()), 0);
 	sc->num_queues = intrmap_count(sc->sc_intrmap);
 }
 
Index: dev/pci/if_ixl.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_ixl.c,v
diff -u -p -r1.107 if_ixl.c
--- dev/pci/if_ixl.c	22 May 2025 06:41:20 -0000	1.107
+++ dev/pci/if_ixl.c	26 Jun 2025 11:30:25 -0000
@@ -1781,7 +1781,8 @@ ixl_attach(struct device *parent, struct
 			nmsix--;
 
 			sc->sc_intrmap = intrmap_create(&sc->sc_dev,
-			    nmsix, IXL_MAX_VECTORS, INTRMAP_POWEROF2);
+			    nmsix, MIN(IXL_MAX_VECTORS, net_sn_count()),
+			    INTRMAP_POWEROF2);
 			nqueues = intrmap_count(sc->sc_intrmap);
 			KASSERT(nqueues > 0);
 			KASSERT(powerof2(nqueues));
Index: dev/pci/if_mcx.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_mcx.c,v
diff -u -p -r1.119 if_mcx.c
--- dev/pci/if_mcx.c	5 Mar 2025 06:44:02 -0000	1.119
+++ dev/pci/if_mcx.c	26 Jun 2025 11:34:48 -0000
@@ -2933,8 +2933,8 @@ mcx_attach(struct device *parent, struct
 	}
 
 	msix--; /* admin ops took one */
-	sc->sc_intrmap = intrmap_create(&sc->sc_dev, msix, MCX_MAX_QUEUES,
-	    INTRMAP_POWEROF2);
+	sc->sc_intrmap = intrmap_create(&sc->sc_dev, msix,
+	    MIN(MCX_MAX_QUEUES, net_sn_count()), INTRMAP_POWEROF2);
 	if (sc->sc_intrmap == NULL) {
 		printf(": unable to create interrupt map\n");
 		goto teardown;