svn commit: r261726 - head/lib/libmemstat

Gleb Smirnoff glebius at FreeBSD.org
Mon Feb 10 20:09:11 UTC 2014


Author: glebius
Date: Mon Feb 10 20:09:10 2014
New Revision: 261726
URL: http://svnweb.freebsd.org/changeset/base/261726

Log:
  Expose real size of UMA allocations via libmemstat(3).
  
  Sponsored by:	Nginx, Inc.

Modified:
  head/lib/libmemstat/libmemstat.3
  head/lib/libmemstat/memstat.c
  head/lib/libmemstat/memstat.h
  head/lib/libmemstat/memstat_internal.h
  head/lib/libmemstat/memstat_uma.c

Modified: head/lib/libmemstat/libmemstat.3
==============================================================================
--- head/lib/libmemstat/libmemstat.3	Mon Feb 10 19:59:46 2014	(r261725)
+++ head/lib/libmemstat/libmemstat.3	Mon Feb 10 20:09:10 2014	(r261726)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 25, 2012
+.Dd February 11, 2014
 .Dt LIBMEMSTAT 3
 .Os
 .Sh NAME
@@ -80,6 +80,8 @@
 .Ft uint64_t
 .Fn memstat_get_size "const struct memory_type *mtp"
 .Ft uint64_t
+.Fn memstat_get_rsize "const struct memory_type *mtp"
+.Ft uint64_t
 .Fn memstat_get_memalloced "const struct memory_type *mtp"
 .Ft uint64_t
 .Fn memstat_get_memfreed "const struct memory_type *mtp"
@@ -287,6 +289,11 @@ If the memory type supports variable all
 sizes allocated for the memory type.
 .It Fn memstat_get_size
 If the memory type supports a fixed allocation size, return that size.
+.It Fn memstat_get_rsize
+If the memory type supports a fixed allocation size, return real size
+of an allocation.
+Real size can exceed requested size due to alignment constraints or
+implicit padding.
 .It Fn memstat_get_memalloced
 Return the total number of bytes allocated for the memory type over its
 lifetime.

Modified: head/lib/libmemstat/memstat.c
==============================================================================
--- head/lib/libmemstat/memstat.c	Mon Feb 10 19:59:46 2014	(r261725)
+++ head/lib/libmemstat/memstat.c	Mon Feb 10 20:09:10 2014	(r261726)
@@ -254,6 +254,13 @@ memstat_get_size(const struct memory_typ
 }
 
 uint64_t
+memstat_get_rsize(const struct memory_type *mtp)
+{
+
+	return (mtp->mt_rsize);
+}
+
+uint64_t
 memstat_get_memalloced(const struct memory_type *mtp)
 {
 

Modified: head/lib/libmemstat/memstat.h
==============================================================================
--- head/lib/libmemstat/memstat.h	Mon Feb 10 19:59:46 2014	(r261725)
+++ head/lib/libmemstat/memstat.h	Mon Feb 10 20:09:10 2014	(r261726)
@@ -124,6 +124,7 @@ uint64_t	 memstat_get_countlimit(const s
 uint64_t	 memstat_get_byteslimit(const struct memory_type *mtp);
 uint64_t	 memstat_get_sizemask(const struct memory_type *mtp);
 uint64_t	 memstat_get_size(const struct memory_type *mtp);
+uint64_t	 memstat_get_rsize(const struct memory_type *mtp);
 uint64_t	 memstat_get_memalloced(const struct memory_type *mtp);
 uint64_t	 memstat_get_memfreed(const struct memory_type *mtp);
 uint64_t	 memstat_get_numallocs(const struct memory_type *mtp);

Modified: head/lib/libmemstat/memstat_internal.h
==============================================================================
--- head/lib/libmemstat/memstat_internal.h	Mon Feb 10 19:59:46 2014	(r261725)
+++ head/lib/libmemstat/memstat_internal.h	Mon Feb 10 20:09:10 2014	(r261726)
@@ -51,6 +51,7 @@ struct memory_type {
 	uint64_t	 mt_byteslimit;	/* 0, or maximum bytes. */
 	uint64_t	 mt_sizemask;	/* malloc: allocated size bitmask. */
 	uint64_t	 mt_size;	/* uma: size of objects. */
+	uint64_t	 mt_rsize;	/* uma: real size of objects. */
 
 	/*
 	 * Zone or type information that includes all caches and any central

Modified: head/lib/libmemstat/memstat_uma.c
==============================================================================
--- head/lib/libmemstat/memstat_uma.c	Mon Feb 10 19:59:46 2014	(r261725)
+++ head/lib/libmemstat/memstat_uma.c	Mon Feb 10 20:09:10 2014	(r261726)
@@ -212,6 +212,7 @@ retry:
 		}
 
 		mtp->mt_size = uthp->uth_size;
+		mtp->mt_rsize = uthp->uth_rsize;
 		mtp->mt_memalloced = mtp->mt_numallocs * uthp->uth_size;
 		mtp->mt_memfreed = mtp->mt_numfrees * uthp->uth_size;
 		mtp->mt_bytes = mtp->mt_memalloced - mtp->mt_memfreed;
@@ -435,6 +436,7 @@ memstat_kvm_uma(struct memory_type_list 
 			}
 skip_percpu:
 			mtp->mt_size = kz.uk_size;
+			mtp->mt_rsize = kz.uk_rsize;
 			mtp->mt_memalloced = mtp->mt_numallocs * mtp->mt_size;
 			mtp->mt_memfreed = mtp->mt_numfrees * mtp->mt_size;
 			mtp->mt_bytes = mtp->mt_memalloced - mtp->mt_memfreed;


More information about the svn-src-head mailing list