Solaris Tunable Parameters Reference Manual

Kernel Memory Allocator

The Solaris kernel memory allocator distributes chunks of memory for use by entities inside the kernel. The allocator creates a number of caches of varying size for use by its clients. Clients can also request the allocator to create a cache for use by that client (for example, to allocate structures of a particular size). Statistics about each of the caches that the allocator manages can be seen with the kstat -c kmem_cache command. Specialized caches can be viewed with the crash(1M) command, using the kmastat operator.

Occasionally, systems might panic because of memory corruption. The kernel memory allocator supports a debugging interface that performs various integrity checks on the buffers as well as collecting information on the allocators. The integrity checks provide the opportunity to detect errors closer to where they actually occurred, and the collected information provides additional data for support people when they try to ascertain the reason for the panic.

Use of the flags incurs additional overhead and memory usage during system operations. The flags should only be used when a memory corruption problem is suspected.

kmem_flags

Description

The Solaris kernel memory allocator has various debugging and test options that were extensively used during the internal development cycle of the Solaris environment. Prior to the Solaris 2.5 release, these options were not usable in released Solaris versions. Starting with the Solaris 2.5 release, a subset of these options are available and they are controlled by the kmem_flags variable, which was set by booting kadb, and then setting the variable before starting the kernel. Because of issues with the timing of the instantiation of the kernel memory allocator and the parsing of /etc/system, it was not possible to set these flags in the /etc/system file until the Solaris 8 release.

Five supported flag settings are described here.

Table 2-1 kmem_flags Settings

Flag 

Setting 

Description 

AUDIT

0x1

The allocator maintains a log that contains recent history of its activity. The number of items logged depends on whether CONTENTS is also set. The log is a fixed size and when space is exhausted, earlier records are reclaimed.

TEST

0x2

The allocator writes a pattern into freed memory and checks that the pattern is unchanged when the buffer is next allocated. If some portion of the buffer is changed, this indicates that the memory was probably used by an entity that had previously allocated and freed the buffer. If an overwrite is seen, the system panics. 

REDZONE

0x4

The allocator provides extra memory at the end of the requested buffer and inserts a special pattern into that memory. When the buffer is freed, the pattern is checked to see if data was written past the end of the buffer. If an overwrite is seen, the kernel panics. 

CONTENTS

0x8

The allocator logs up to 256 bytes of buffer contents when the buffer is freed. Requires that AUDIT also be set.

The numeric value of these flags can be logically added (OR'ed) together and set by the /etc/system file in the Solaris 8 release, or for previous releases, by booting kadb and setting the flags before starting the kernel.

LITE

0x100

Does minimal sanity checking when a buffer is allocated and freed. When enabled, the allocator checks that the redzone has not been written into, that a freed buffer is not being freed again, and that the buffer being freed is the size that was allocated. This flag is available as of the Solaris 7 3/99 release. Do not combine this flag with any other flags. 

Data Type

Signed integer

Default

0 (disabled)

Range

0 (disabled) or 1 - 15 or 256 (0x100)

Dynamic?

Yes. Changes made during runtime only affect new kernel memory caches. After system initialization, the creation of new caches is rare.

Validation

None

When to Change

When memory corruption is suspected.

Commitment Level

Unstable