summaryrefslogtreecommitdiffstats
path: root/lib/libmemstat
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-07-15 11:19:55 +0000
committerrwatson <rwatson@FreeBSD.org>2005-07-15 11:19:55 +0000
commit3aa76a5f8581f6ffda31a88e80f453eef945eeb7 (patch)
treedcdacbd169690dcd75bb4176a5396c7dbfc3f624 /lib/libmemstat
parent7da3a4e78f0d8fd5b4d0c29f6063cd8c292f0587 (diff)
downloadFreeBSD-src-3aa76a5f8581f6ffda31a88e80f453eef945eeb7.zip
FreeBSD-src-3aa76a5f8581f6ffda31a88e80f453eef945eeb7.tar.gz
Increase the number of caller memory storage slots from 2 or 4 to
MEMSTAT_MAXCALLER (8), and expose MEMSTAT_MAXCALLER via memstat.h so that applications can check their assumptions about how many slots are available. Remove 'spare' memory storage in struct malloc_type, since we now don't expose the data structure internals to applications and rely on accessor methods, this approach to ABI stability isn't required. MFC after: 7 days
Diffstat (limited to 'lib/libmemstat')
-rw-r--r--lib/libmemstat/memstat.h8
-rw-r--r--lib/libmemstat/memstat_internal.h12
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/libmemstat/memstat.h b/lib/libmemstat/memstat.h
index 847719c..5269a33 100644
--- a/lib/libmemstat/memstat.h
+++ b/lib/libmemstat/memstat.h
@@ -36,6 +36,14 @@
#define MEMSTAT_MAXCPU 16
/*
+ * Amount of caller data to maintain for each caller data slot. Applications
+ * must not request more than this number of caller save data, or risk
+ * corrupting internal libmemstat(3) data structures. A compile time check
+ * in the application is probably appropriate.
+ */
+#define MEMSTAT_MAXCALLER 8
+
+/*
* libmemstat(3) is able to extract memory data from different allocators;
* when it does so, it tags which allocator it got the data from so that
* consumers can determine which fields are usable, as data returned varies
diff --git a/lib/libmemstat/memstat_internal.h b/lib/libmemstat/memstat_internal.h
index 9431917..1e974df 100644
--- a/lib/libmemstat/memstat_internal.h
+++ b/lib/libmemstat/memstat_internal.h
@@ -65,13 +65,12 @@ struct memory_type {
uint64_t mt_count; /* Number of current allocations. */
uint64_t mt_free; /* Number of cached free items. */
uint64_t mt_failures; /* Number of allocation failures. */
- uint64_t _mt_spare_uint64[4]; /* Spare. */
/*
* Caller-owned memory.
*/
- void *mt_caller_pointer[4]; /* Caller-owned pointers. */
- uint64_t mt_caller_uint64[4]; /* Caller-owned longs. */
+ void *mt_caller_pointer[MEMSTAT_MAXCALLER]; /* Pointers. */
+ uint64_t mt_caller_uint64[MEMSTAT_MAXCALLER]; /* Integers. */
/*
* For allocators making use of per-CPU caches, we also provide raw
@@ -86,7 +85,6 @@ struct memory_type {
* global stats above.
*/
uint64_t mt_zonefree; /* Free items in zone. */
- uint64_t _mt_spare_uint642[4]; /* Spare. */
/*
* Per-CPU measurements fall into two categories: per-CPU allocation,
@@ -98,14 +96,12 @@ struct memory_type {
uint64_t mtp_numallocs; /* Per-CPU mt_numallocs. */
uint64_t mtp_numfrees; /* Per-CPU mt_numfrees. */
uint64_t mtp_sizemask; /* Per-CPU mt_sizemask. */
- void *mtp_caller_pointer[2]; /* Caller data. */
- uint64_t mtp_caller_uint64[2]; /* Caller data. */
- uint64_t _mtp_spare_uint64[3]; /* Per-CPU spare. */
+ void *mtp_caller_pointer[MEMSTAT_MAXCALLER];
+ uint64_t mtp_caller_uint64[MEMSTAT_MAXCALLER];
} mt_percpu_alloc[MEMSTAT_MAXCPU];
struct {
uint64_t mtp_free; /* Per-CPU cache free items. */
- uint64_t _mtp_spare_uint64[3]; /* Per-CPU spare. */
} mt_percpu_cache[MEMSTAT_MAXCPU];
LIST_ENTRY(memory_type) mt_list; /* List of types. */
OpenPOWER on IntegriCloud