Accounting for mbufs and clusters assigned to a socket buffer
Andre Oppermann
andre at freebsd.org
Fri Apr 25 14:26:28 UTC 2008
gnn at freebsd.org wrote:
> Howdy,
>
> The following patch updates the kernel (CURRENT as of 23 April or so)
> and netstat(1) to show not only the bytes in the receive and send
> queues but also the mbuf and cluster usage per socket buffer. I'd be
> interested in people's comments on this. I'd like to extend such
> counting to show more information, in particular how much of a cluster
> or mbuf is actually in use.
The intent of tracking that information is good. However there are some
problems with your approach: M_EXT does not mean the mbuf has a 2k cluster
attached. It could by any external storage. That is a 2k (classic) cluster,
a 4k (page size) cluster, a 9k cluster, a VM page (sendfile), and so on.
The field sb_mbcnt already gives you the aggregated gross storage space in
use for the socket. And sb_cc tells how much actual payload it contains.
Just printing the already available sb_mbcnt in netstat is probably sufficient
to get a good real memory usage picture. sb_mbcnt is already exported in xsb
and doesn't require a KPI change.
--
Andre
More information about the freebsd-arch
mailing list