Bug 84946

Summary: 'Mbuf' instead of 'mbuf' in libmemstat(3)
Product: Documentation Reporter: Wojciech A. Koszek <dunstan>
Component: Books & ArticlesAssignee: Robert Watson <rwatson>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Wojciech A. Koszek 2005-08-15 11:10:21 UTC
libmemstat(3) is case-sensitive in memstat_mtl_find():

        LIST_FOREACH(mtp, &list->mtl_list, mt_list) {
                if ((mtp->mt_allocator == allocator ||
                    allocator == ALLOCATOR_ANY) &&
                    strcmp(mtp->mt_name, name) == 0)

Example in manual page says:
dunstan@laptop:(~)$ man libmemstat | grep Mbuf
[..]
		mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, "Mbuf");
[..]

Fix: 

http://freebsd.czest.pl/dunstan/FreeBSD/diff.0.libmemstat.3
How-To-Repeat: dunstan@laptop:(~)$ vmstat -z | grep mbuf
mbuf_cluster:   2048,    17088,    128,      6,      128
mbuf:            256,        0,    385,    140,   426657
mbuf_packet:     256,        0,    388,    137,   150050
Comment 1 Robert Watson freebsd_committer freebsd_triage 2005-08-15 11:25:48 UTC
State Changed
From-To: open->patched


Slightly expanded version of patch applied (also renamed other references 
to Mbuf) to HEAD, will MFC with re@'s permission.  Thanks for the bug 
report! 

FYI: I've actually been considering committing a slightly larger example 
that also retrieves the count from the mbuf_packet zone, since those are 
also allocated mbufs.  Something like the following: 

struct memory_type_list *mtlp; 
struct memory_type *mtp; 
uint64_t mbuf_count, mbuf_packet_count; 

mtlp = memstat_mtl_alloc(); 
if (mtlp == NULL) 
err(-1, "memstat_mtl_alloc"); 
if (memstat_sysctl_uma(mtlp, 0) < 0) 
err(-1, "memstat_sysctl_uma"); 
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, "mbuf"); 
if (mtp == NULL) 
errx(-1, "memstat_mtl_find: mbuf not found"); 
mbuf_count = memstat_get_count(mtp); 
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, "mbuf_packet"); 
if (mtp == NULL) 
errx(-1, "memstat_mtl_find: mbuf_packet not found"); 
mbuf_packet_count = memstat_get_count(mtp); 
memstat_mtl_free(mtlp); 

printf("mbufs: %llun", (unsigned long long)(mbuf_count + 
mbuf_packet_count)); 




Comment 2 Robert Watson freebsd_committer freebsd_triage 2005-08-15 11:25:48 UTC
Responsible Changed
From-To: freebsd-doc->rwatson

Take ownership of this PR since I am responsible for libmemstat(3). 
Pointed to by simon.
Comment 3 Robert Watson freebsd_committer freebsd_triage 2005-08-20 22:29:23 UTC
State Changed
From-To: patched->closed

MFC'd to RELENG_6 as libmemstat.3:1.6.2.2, so will appear in 6.0-RELEASE. 
Thanks!