From dunstan@freebsd.czest.pl  Mon Aug 15 10:06:23 2005
Return-Path: <dunstan@freebsd.czest.pl>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9720F16A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 15 Aug 2005 10:06:23 +0000 (GMT)
	(envelope-from dunstan@freebsd.czest.pl)
Received: from freebsd.czest.pl (silver.iplus.pl [80.48.250.4])
	by mx1.FreeBSD.org (Postfix) with ESMTP id BCA7443D53
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 15 Aug 2005 10:06:19 +0000 (GMT)
	(envelope-from dunstan@freebsd.czest.pl)
Received: from freebsd.czest.pl (freebsd.czest.pl [80.48.250.4])
	by freebsd.czest.pl (8.12.10/8.12.9) with ESMTP id j7FALBGW051273
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 15 Aug 2005 10:21:11 GMT
	(envelope-from dunstan@freebsd.czest.pl)
Received: (from dunstan@localhost)
	by freebsd.czest.pl (8.12.10/8.12.9/Submit) id j7FALACw051272;
	Mon, 15 Aug 2005 10:21:11 GMT
	(envelope-from dunstan)
Message-Id: <200508151021.j7FALACw051272@freebsd.czest.pl>
Date: Mon, 15 Aug 2005 10:21:11 GMT
From: "Wojciech A. Koszek" <dunstan@freebsd.czest.pl>
Reply-To: "Wojciech A. Koszek" <dunstan@freebsd.czest.pl>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: 'Mbuf' instead of 'mbuf' in libmemstat(3) 
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         84946
>Category:       docs
>Synopsis:       'Mbuf' instead of 'mbuf' in libmemstat(3)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    rwatson
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 15 10:10:21 GMT 2005
>Closed-Date:    Sat Aug 20 21:30:06 GMT 2005
>Last-Modified:  Sat Aug 20 21:30:06 GMT 2005
>Originator:     Wojciech A. Koszek
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD laptop.freebsd.czest.pl 7.0-CURRENT FreeBSD 7.0-CURRENT #15: Mon Aug 15 01:42:34 CEST 2005 dunstan@laptop.freebsd.czest.pl:/usr/obj/usr/src/sys/LAPTOP i386

>Description:
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");
[..]		

>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
>Fix:
http://freebsd.czest.pl/dunstan/FreeBSD/diff.0.libmemstat.3

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: rwatson 
State-Changed-When: Mon Aug 15 10:25:48 GMT 2005 
State-Changed-Why:  

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)); 




Responsible-Changed-From-To: freebsd-doc->rwatson 
Responsible-Changed-By: rwatson 
Responsible-Changed-When: Mon Aug 15 10:25:48 GMT 2005 
Responsible-Changed-Why:  
Take ownership of this PR since I am responsible for libmemstat(3). 
Pointed to by simon. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=84946 
State-Changed-From-To: patched->closed 
State-Changed-By: rwatson 
State-Changed-When: Sat Aug 20 21:29:23 GMT 2005 
State-Changed-Why:  
MFC'd to RELENG_6 as libmemstat.3:1.6.2.2, so will appear in 6.0-RELEASE. 
Thanks! 


http://www.freebsd.org/cgi/query-pr.cgi?pr=84946 
>Unformatted:
