CVSROOT: /cvs
Module name: src
Changes by: [email protected] 2025/12/01 21:15:07
Modified files:
sys/net : if_tpmr.c
Log message:
use per cpu refs in the input path instead of one refcnt per port.
passing packets into tpmr relies on taking a ref from an smr critical
section so the tprm_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 tpmr_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 tpmr_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 for the outgoing port when pushing
a packet out on the wire.
hrvoje popovski measured tpmr between two ix ports going from 5.4
to 6.5 Mpps, and on mcx going from 5.5 to 7.4 Mpps.
jmatthew@ points out that this approach is similar to hazard pointers.