cvs commit: src/sys/kern kern_malloc.c src/sys/sys malloc.h
rwatson at FreeBSD.org
Sat Jul 23 17:11:34 GMT 2005
rwatson 2005-07-23 17:11:33 UTC
FreeBSD src repository
Modified files: (Branch: RELENG_6)
Merge kern_malloc.c:1.143,1.144 malloc.h:1.81 from HEAD to RELENG_6:
Introduce a new sysctl, kern.malloc_stats, which exports kernel malloc
statistics via a binary structure stream:
- Add structure 'malloc_type_stream_header', which defines a stream
version, definition of MAXCPUS used in the stream, and a number of
malloc_type records in the stream.
- Add structure 'malloc_type_header', which defines the name of the
malloc type being reported on.
- 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 malloc_type_stats structures holding
per-CPU allocation information. Typical values of MAXCPUS 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.
- Bump statistics width to uint64_t, and hard code using fixed-width
type in order to be more sure about structure layout in the stream.
We allocate and free a lot of memory.
- Add kmemcount, a counter of the number of registered malloc types,
in order to avoid excessive manual counting of types. Export via a
new sysctl to allow user-space code to better size buffers.
- De-XXX comment on no longer maintaining the high watermark in old
sysctl monitoring code.
A follow-up commit of libmemstat(3), a library to monitor kernel memory
allocation, will occur in the next few days. Likewise, similar changes
Correct build on 64-bit: cast u_int64_t to (unsigned long long) before
printfing as (unsigned long long). 32-bit build on i386 didn't notice
Reported by: arved
Tested by: sledge
Approved by: re (kensmith)
Revision Changes Path
126.96.36.199 +94 -6 src/sys/kern/kern_malloc.c
188.8.131.52 +28 -8 src/sys/sys/malloc.h
More information about the cvs-all