CVSROOT:        /cvs
Module name:    src
Changes by:     [email protected]    2025/12/01 21:03:42

Modified files:
        sys/net        : if_veb.c 

Log message:
use per cpu refs in the input path instead of one refcnt per port.

passing packets into veb relies on taking a ref from an smr critical
section so the veb_port struct can be used while interacting with
the larger network stack because you can't sleep while in an smr
critical section and the network stack has sleeping points.

this is fine, but it's atomic ops against the same refcnt in the
one veb_port struct that can be running in parallel on all the
softnet threads. this means the cacheline under this refcnt gets
pulled around a lot, which in turn affects performance.

to compensate for this loss in performance, this diff adds per cpu
refcnts that act as a proxy to the veb_port refcnt. this effectively
hashes the softnet threads into individual refcnts on separate
cache lines.

unfortunately, softnet threads can move between cpus because the
network stack has sleeping points. this prevents us from using the
refcnt on the current cpu for both the take and rele operations,
cos the current cpu changes. this diff handles that by picking the
refcnt on the current cpu, but carries a pointer to it from the
ep_port_take operation to the ep_port_rele operation.

this also uses these per cpu refs in the veb_transmit path.

benchmarks by hrvoje popovski and myself show a(n annoyingly) small
but still present improvement in performance. one of hvroje's tests
showed ix going from 5.6 to 5.7 Mpps on ix(4) interfaces, and 6.0
to 6.1 Mpps on mcx. my stuff didn't go this fast, but noted less
variation in the pps when running this diff.

Reply via email to