CVSROOT:        /cvs
Module name:    src
Changes by:     [email protected]    2026/07/03 05:51:57

Modified files:
        sys/kern       : uipc_mbuf.c 
        sys/sys        : mbuf.h 

Log message:
rework how mbufs share references to external storage

previously mbufs that shared a reference to the same external storage
were linked together with a pair of lists, but operations on these
lists have to be serialised because different cpus can be working
on on mbufs that share the same external storage. this serialisation
was provided by a single global mutex, which has now become contended
when the kernel is doing a lot of work that relies on shared external
storage.

this diff replaces the links with an m_ext_refs struct that "proxies"
the external storage information on mbufs when that storage is first
shared between two mbufs. that struct contains a refcnt that's
increased if the external storage is shared again, and only when
the refcnt drops to zero is the external storage actually released
with the original free handler. these per shared storage refcnts
replace the global mutex for coordinating the "finalisation" and
actual free of the external storage.

the m_ext_refs structs are allocated out of a pool with per cpu
caches enabled to mitigate against the allocator becoming the point
of contention in the system instead of the global mutex.

the contention was noticed by bluhm@, whose testing shows something
like a 50 to 100 percent performance improvement when testing
workloads that rely on sharing external storage, like socket splicing.

ok bluhm@ claudio@

Reply via email to