cvs commit: src/sys/sys malloc.h src/sys/kern kern_malloc.c

Robert Watson rwatson at FreeBSD.org
Thu Jul 14 11:52:07 GMT 2005


rwatson     2005-07-14 11:52:06 UTC

  FreeBSD src repository

  Modified files:
    sys/sys              malloc.h 
    sys/kern             kern_malloc.c 
  Log:
  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.
  
  While here:
  
  - 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
  to UMA.
  
  Revision  Changes    Path
  1.143     +93 -5     src/sys/kern/kern_malloc.c
  1.81      +28 -8     src/sys/sys/malloc.h


More information about the cvs-src mailing list