summaryrefslogtreecommitdiffstats
path: root/sys/vm/uma.h
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-07-14 16:35:13 +0000
committerrwatson <rwatson@FreeBSD.org>2005-07-14 16:35:13 +0000
commit83343a94ec61e610a2a709f05bfd688ca81a0570 (patch)
treee935c60d431d79792cff482c2856e3788d89de86 /sys/vm/uma.h
parentc24543fa5061bf3ea345882d7b2e1d4aba137b60 (diff)
downloadFreeBSD-src-83343a94ec61e610a2a709f05bfd688ca81a0570.zip
FreeBSD-src-83343a94ec61e610a2a709f05bfd688ca81a0570.tar.gz
Introduce a new sysctl, vm.zone_stats, which exports UMA(9) allocator
statistics via a binary structure stream: - Add structure 'uma_stream_header', which defines a stream version, definition of MAXCPUs used in the stream, and the number of zone records in the stream. - Add structure 'uma_type_header', which defines the name, alignment, size, resource allocation limits, current pages allocated, preferred bucket size, and central zone + keg statistics. - Add structure 'uma_percpu_stat', which, for each per-CPU cache, includes the number of allocations and frees, as well as the number of free items in the cache. - When the sysctl is queried, return a stream header, followed by a series of type descriptions, each consisting of a type header followed by a series of MAXCPUs uma_percpu_stat structures holding per-CPU allocation information. Typical values of MAXCPU will be 1 (UP compiled kernel) and 16 (SMP compiled kernel). This query mechanism allows user space monitoring tools to extract memory allocation statistics in a machine-readable form, and to do so at a per-CPU granularity, allowing monitoring of allocation patterns across CPUs in order to better understand the distribution of work and memory flow over multiple CPUs. While here, also export the number of UMA zones as a sysctl vm.uma_count, in order to assist in sizing user swpace buffers to receive the stream. A follow-up commit of libmemstat(3), a library to monitor kernel memory allocation, will occur in the next few days. This change directly supports converting netstat(1)'s "-mb" mode to using UMA-sourced stats rather than separately maintained mbuf allocator statistics. MFC after: 1 week
Diffstat (limited to 'sys/vm/uma.h')
-rw-r--r--sys/vm/uma.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/sys/vm/uma.h b/sys/vm/uma.h
index 2152b4d..283be9f 100644
--- a/sys/vm/uma.h
+++ b/sys/vm/uma.h
@@ -509,4 +509,51 @@ void uma_prealloc(uma_zone_t zone, int itemcnt);
*/
u_int32_t *uma_find_refcnt(uma_zone_t zone, void *item);
+/*
+ * Exported statistics structures to be used by user space monitoring tools.
+ * Statistics stream consusts of a uma_stream_header, followed by a series of
+ * alternative uma_type_header and uma_type_stat structures. Statistics
+ * structures
+ */
+#define UMA_STREAM_VERSION 0x00000001
+struct uma_stream_header {
+ u_int32_t ush_version; /* Stream format version. */
+ u_int32_t ush_maxcpus; /* Value of MAXCPU for stream. */
+ u_int32_t ush_count; /* Number of records. */
+ u_int32_t _ush_pad; /* Pad/reserved field. */
+};
+
+#define UMA_MAX_NAME 32
+struct uma_type_header {
+ /*
+ * Static per-zone data, some extracted from the supporting keg.
+ */
+ char uth_name[UMA_MAX_NAME];
+ u_int32_t uth_align; /* Keg: alignment. */
+ u_int32_t uth_size; /* Keg: requested size of item. */
+ u_int32_t uth_rsize; /* Keg: real size of item. */
+ u_int32_t uth_maxpages; /* Keg: maximum number of pages. */
+ u_int32_t uth_limit; /* Keg: max items to allocate. */
+
+ /*
+ * Current dynamic zone/keg-derived statistics.
+ */
+ u_int32_t uth_pages; /* Keg: pages allocated. */
+ u_int32_t uth_keg_free; /* Keg: items free. */
+ u_int32_t uth_zone_free; /* Zone: items free. */
+ u_int32_t uth_bucketsize; /* Zone: desired bucket size. */
+ u_int32_t _uth_reserved0; /* Reserved. */
+ u_int64_t uth_allocs; /* Zone: number of allocations. */
+ u_int64_t uth_frees; /* Zone: number of frees. */
+ u_int64_t _uth_reserved1[4]; /* Reserved. */
+
+};
+
+struct uma_percpu_stat {
+ u_int64_t ups_allocs; /* Cache: number of alloctions. */
+ u_int64_t ups_frees; /* Cache: number of frees. */
+ u_int64_t ups_cache_free; /* Cache: free items in cache. */
+ u_int64_t _ups_reserved[5]; /* Reserved. */
+};
+
#endif
OpenPOWER on IntegriCloud