Multi-queue NIC drivers and multi-port lagg tend to use the same lower

bits of the flowid as each other, resulting in a poor distribution of
packets among queues in certain cases.  Work around this by adding a
set of sysctls for controlling a bit-shift on the flowid when doing
multi-port aggrigation in lagg and lacp.  By default, lagg/lacp will
now use bits 16 and higher instead of 0 and higher.

Reviewed by:	max
Obtained from:	Netflix
MFC after:	3 days
This commit is contained in:
Scott Long 2013-12-30 01:32:17 +00:00
parent 9a2fcb2e6b
commit 1a8959dac6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=260070
3 changed files with 15 additions and 4 deletions

View File

@ -877,7 +877,7 @@ lacp_select_tx_port(struct lagg_softc *sc, struct mbuf *m)
}
if (sc->use_flowid && (m->m_flags & M_FLOWID))
hash = m->m_pkthdr.flowid;
hash = m->m_pkthdr.flowid >> sc->flowid_shift;
else
hash = lagg_hashmbuf(sc, m, lsc->lsc_hashkey);
hash %= pm->pm_count;

View File

@ -184,6 +184,11 @@ TUNABLE_INT("net.link.lagg.default_use_flowid", &def_use_flowid);
SYSCTL_INT(_net_link_lagg, OID_AUTO, default_use_flowid, CTLFLAG_RW,
&def_use_flowid, 0,
"Default setting for using flow id for load sharing");
static int def_flowid_shift = 16; /* Default value for using M_FLOWID */
TUNABLE_INT("net.link.lagg.default_flowid_shift", &def_flowid_shift);
SYSCTL_INT(_net_link_lagg, OID_AUTO, default_flowid_shift, CTLFLAG_RW,
&def_flowid_shift, 0,
"Default setting for flowid shift for load sharing");
static int
lagg_modevent(module_t mod, int type, void *data)
@ -293,12 +298,17 @@ lagg_clone_create(struct if_clone *ifc, int unit, caddr_t params)
sysctl_ctx_init(&sc->ctx);
snprintf(num, sizeof(num), "%u", unit);
sc->use_flowid = def_use_flowid;
sc->flowid_shift = def_flowid_shift;
sc->sc_oid = oid = SYSCTL_ADD_NODE(&sc->ctx,
&SYSCTL_NODE_CHILDREN(_net_link, lagg),
OID_AUTO, num, CTLFLAG_RD, NULL, "");
SYSCTL_ADD_INT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
"use_flowid", CTLTYPE_INT|CTLFLAG_RW, &sc->use_flowid, sc->use_flowid,
"Use flow id for load sharing");
"use_flowid", CTLTYPE_INT|CTLFLAG_RW, &sc->use_flowid,
sc->use_flowid, "Use flow id for load sharing");
SYSCTL_ADD_INT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
"flowid_shift", CTLTYPE_INT|CTLFLAG_RW, &sc->flowid_shift,
sc->flowid_shift,
"Shift flowid bits to prevent multiqueue collisions");
SYSCTL_ADD_INT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
"count", CTLTYPE_INT|CTLFLAG_RD, &sc->sc_count, sc->sc_count,
"Total number of ports");
@ -1850,7 +1860,7 @@ lagg_lb_start(struct lagg_softc *sc, struct mbuf *m)
uint32_t p = 0;
if (sc->use_flowid && (m->m_flags & M_FLOWID))
p = m->m_pkthdr.flowid;
p = m->m_pkthdr.flowid >> sc->flowid_shift;
else
p = lagg_hashmbuf(sc, m, lb->lb_key);
p %= sc->sc_count;

View File

@ -231,6 +231,7 @@ struct lagg_softc {
struct sysctl_ctx_list ctx; /* sysctl variables */
struct sysctl_oid *sc_oid; /* sysctl tree oid */
int use_flowid; /* use M_FLOWID */
int flowid_shift; /* shift the flowid */
};
struct lagg_port {