diff options
-rw-r--r-- | lib/libmemstat/libmemstat.3 | 9 | ||||
-rw-r--r-- | lib/libmemstat/memstat.c | 7 | ||||
-rw-r--r-- | lib/libmemstat/memstat.h | 1 | ||||
-rw-r--r-- | lib/libmemstat/memstat_internal.h | 1 | ||||
-rw-r--r-- | lib/libmemstat/memstat_uma.c | 2 |
5 files changed, 19 insertions, 1 deletions
diff --git a/lib/libmemstat/libmemstat.3 b/lib/libmemstat/libmemstat.3 index 9b749f053c71d..3eff1566d03e3 100644 --- a/lib/libmemstat/libmemstat.3 +++ b/lib/libmemstat/libmemstat.3 @@ -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 allocation sizes, return a bitmask of 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. diff --git a/lib/libmemstat/memstat.c b/lib/libmemstat/memstat.c index c7957c8b576c0..40bdc9d19f0f7 100644 --- a/lib/libmemstat/memstat.c +++ b/lib/libmemstat/memstat.c @@ -254,6 +254,13 @@ memstat_get_size(const struct memory_type *mtp) } uint64_t +memstat_get_rsize(const struct memory_type *mtp) +{ + + return (mtp->mt_rsize); +} + +uint64_t memstat_get_memalloced(const struct memory_type *mtp) { diff --git a/lib/libmemstat/memstat.h b/lib/libmemstat/memstat.h index cca75b32092d3..8394dc1c1221d 100644 --- a/lib/libmemstat/memstat.h +++ b/lib/libmemstat/memstat.h @@ -124,6 +124,7 @@ uint64_t memstat_get_countlimit(const struct memory_type *mtp); 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); diff --git a/lib/libmemstat/memstat_internal.h b/lib/libmemstat/memstat_internal.h index 2416e09b115a6..9fdc22813b2ab 100644 --- a/lib/libmemstat/memstat_internal.h +++ b/lib/libmemstat/memstat_internal.h @@ -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 diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c index b8ff3a1f2c036..8e89585300b0a 100644 --- a/lib/libmemstat/memstat_uma.c +++ b/lib/libmemstat/memstat_uma.c @@ -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 *list, void *kvm_handle) } 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; |