Date: Thu, 16 Jul 2009 19:00:32 GMT From: Gabor Pali <pgj@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 166171 for review Message-ID: <200907161900.n6GJ0WXo016622@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=166171 Change 166171 by pgj@petymeg-current on 2009/07/16 18:59:33 Add "ABI-proof" structures and sysctl(8) variables to support live monitoring functions of libnetstat: - kern.ipc.sfbstats -- sendfile(2) statistics - kern.ipc.mbstats -- mbuf(9) statistics Affected files ... .. //depot/projects/soc2009/pgj_libstat/src/sys/kern/kern_mbuf.c#2 edit .. //depot/projects/soc2009/pgj_libstat/src/sys/kern/uipc_syscalls.c#3 edit .. //depot/projects/soc2009/pgj_libstat/src/sys/sys/mbuf.h#2 edit Differences ... ==== //depot/projects/soc2009/pgj_libstat/src/sys/kern/kern_mbuf.c#2 (text+ko) ==== @@ -207,6 +207,25 @@ SYSCTL_STRUCT(_kern_ipc, OID_AUTO, mbstat, CTLFLAG_RD, &mbstat, mbstat, "Mbuf general information and statistics"); +static int +mbuf_stats(SYSCTL_HANDLER_ARGS) +{ + struct mbstat_data mbsd; + int error; + + error = 0; + bzero(&mbsd, sizeof(mbsd)); + + mbsd.mbd_version = MBSTAT_DATA_VERSION; + mbsd.mbd_drain = mbstat.m_drain; + + error = SYSCTL_OUT(req, &mbsd, sizeof(mbsd)); + return (error); +} + +SYSCTL_PROC(_kern_ipc, OID_AUTO, mbstats, CTLFLAG_RD|CTLTYPE_STRUCT, 0, 0, + mbuf_stats, "s,struct mbstat_data", "Statistics on mbuf"); + /* * Zones from which we allocate. */ ==== //depot/projects/soc2009/pgj_libstat/src/sys/kern/uipc_syscalls.c#3 (text+ko) ==== @@ -107,6 +107,30 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, nsfbufsused, CTLFLAG_RD, &nsfbufsused, 0, "Number of sendfile(2) sf_bufs in use"); +static int +sfbuf_stats(SYSCTL_HANDLER_ARGS) +{ + struct sfbuf_data sfd; + int error; + + error = 0; + bzero(&sfd, sizeof(sfd)); + + sfd.sfd_version = SFBUF_DATA_VERSION; + sfd.sfd_nbufs = nsfbufs; + sfd.sfd_nbufs_peak = nsfbufspeak; + sfd.sfd_nbufs_used = nsfbufsused; + sfd.sfd_iocnt = mbstat.sf_iocnt; + sfd.sfd_allocfail = mbstat.sf_allocfail; + sfd.sfd_allocwait = mbstat.sf_allocwait; + + error = SYSCTL_OUT(req, &sfd, sizeof(sfd)); + return (error); +} + +SYSCTL_PROC(_kern_ipc, OID_AUTO, sfbstats, CTLFLAG_RD|CTLTYPE_STRUCT, 0, 0, + sfbuf_stats, "s,struct sfbuf_data", "Statistics on sendfile(2) buffers"); + /* * Convert a user file descriptor to a kernel file entry. A reference on the * file entry is held upon returning. This is lighter weight than ==== //depot/projects/soc2009/pgj_libstat/src/sys/sys/mbuf.h#2 (text+ko) ==== @@ -302,6 +302,32 @@ }; /* + * Statistics structures to be used by user space monitoring tools. + */ +#define MBSTAT_DATA_VERSION 0x00000001 + +/* Exported by: kern.ipc.mbstats */ +struct mbstat_data { + u_int32_t mbd_version; + u_int64_t mbd_drain; + u_int8_t __mbd_pad[4]; +}; + +#define SFBUF_DATA_VERSION 0x00000001 + +/* Exported by: kern.ipc.sfbstats */ +struct sfbuf_data { + u_int32_t sfd_version; + u_int64_t sfd_nbufs; + u_int64_t sfd_nbufs_peak; + u_int64_t sfd_nbufs_used; + u_int64_t sfd_iocnt; + u_int64_t sfd_allocfail; + u_int64_t sfd_allocwait; + u_int8_t __sfd_pad[12]; +}; + +/* * Flags specifying how an allocation should be made. * * The flag to use is as follows:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907161900.n6GJ0WXo016622>