CVSROOT:        /cvs
Module name:    src
Changes by:     [email protected]    2025/12/01 20:50:56

Modified files:
        sys/net        : if_aggr.c 

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

previously aggr (and trunk) would swap the if_input handler on their
port interfaces to intercept packets and make them appear to be
received by aggr, but this relied on the net lock to coordinate and
ensure the references to everything were safe. making aggr safe to
call without the netlock meant using refcnts to ensure the aggr_port
struct would stay alive while it's being used, but this means a
couple of atomic operations were added to every packet going through
aggr.

this is fine, but it's atomic ops against the same refcnt in the
one aggr_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 aggr_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.

im bad at science and i lost some of the benchmark results, but
this does provide a noticable performance bump.

Reply via email to