netstat(1) -mb changes to support libmemstat(3)

From: Robert Watson <rwatson_at_FreeBSD.org>
Date: Tue, 19 Jul 2005 15:43:28 +0100 (BST)
With the below-referenced change, netstat(1) now uses libmemstat(3) for 
its "-mb" statistics display.  This moves netstat to using a higher 
consistency statistics set from UMA, rather than low consistency 
statistics from the mbuf allocator (which will eventually be removed, once 
libmemstat(3) also supports kvm so can read statistics from kernel cores). 
There are also several new statistics available, including the number of 
cached (free) mbufs in the per-cpu caches and zone cache.

However!  This involved a substantial rearrangement of statistics 
gathering, attempting to handle statistics management between several 
zones, kegs, etc, in UMA, and so on.  There are likely a few bugs in this, 
and I'd like to shake them out sooner rather than later.

To use the new netstat, you need a recent kernel and libmemstat, as well 
as the below changes.  Any checkout and build as of July 19 should contain 
the necessary changes.

If you run into a problem, such as rediculously high amounts of memory 
(probably negative wrapped to unsigned), it would be helpful if you could 
e-mail me the complete output of vmstat -z, the new netstat, and an older 
netstat binary (just back out the changed below to mbuf.c and you'll be 
back where you started, as all the old stats are still exported by the 
kernel).

I've had one report so far of a nit that appears to have to do with free 
mbufs in the packet zone, whose clusters aren't properly accounted for. 
I'm investigating that today.

Robert N M Watson

---------- Forwarded message ----------
Date: Mon, 18 Jul 2005 08:34:15 +0000 (UTC)
From: Robert Watson <rwatson_at_FreeBSD.org>
To: src-committers_at_FreeBSD.org, cvs-src_at_FreeBSD.org, cvs-all_at_FreeBSD.org
Subject: cvs commit: src/usr.bin/netstat Makefile mbuf.c

rwatson     2005-07-18 08:34:15 UTC

   FreeBSD src repository

   Modified files:
     usr.bin/netstat      Makefile mbuf.c
   Log:
   Modify "netstat -mb" to use libmemstat(3) when acting on a live system,
   with a number of positive benefits:

   - Start using UMA(9) statistics for mbufs and clusters, which avoids
     using the mbuf allocator statistics which suffer from races under
     load on SMP.  This should eliminate "negative" mbuf counts in
     netstat -mb.

   - We are now able to track cached (free) mbufs and clusters and count
     it towards memory allocated by the network stack.

   - We are now also able to track memory allocated to mbuf tags since
     libmemstat(3) can also query malloc(9).  We don't print this except
     as part of the total (for now - #if 0).

   - We are now able to track mbuf/cluster/packet allocation failures,
     although they are not currently printed (#if 0).

   - Don't print out sfbuf statistics when running on a kernel core, as
     currently that code is able only to query sysctl for statistics.

   MFC after:      1 week

   Revision  Changes    Path
   1.27      +2 -2      src/usr.bin/netstat/Makefile
   1.43      +195 -34   src/usr.bin/netstat/mbuf.c
Received on Tue Jul 19 2005 - 12:43:19 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:39 UTC