diff options
author | glebius <glebius@FreeBSD.org> | 2014-02-10 20:09:10 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2014-02-10 20:09:10 +0000 |
commit | 665c1c091948d69989e5e6296fab06a38ece50d5 (patch) | |
tree | c7d13d374bcdc0e2ba810d4128330058b24f9322 /lib/libmemstat | |
parent | 45bf1cc68359f3dc27c38acb53ea225c5af1e2c5 (diff) | |
download | FreeBSD-src-665c1c091948d69989e5e6296fab06a38ece50d5.zip FreeBSD-src-665c1c091948d69989e5e6296fab06a38ece50d5.tar.gz |
Expose real size of UMA allocations via libmemstat(3).
Sponsored by: Nginx, Inc.
Diffstat (limited to 'lib/libmemstat')
-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 9b749f0..3eff156 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 c7957c8..40bdc9d 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 cca75b3..8394dc1 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 2416e09..9fdc228 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 b8ff3a1..8e89585 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; |