Configuration File

A comprehensive guide to all the directives and syntax used in the USM configuration file (e.g., alloc_policy_assignment_strategy.cfg).

The USM configuration file is a simple text file that defines the runtime behavior of an InstanceUSM. It controls global resource allocation and dictates how processes are assigned to the policies you've written.

Syntax

The file uses a simple directive value [value2 ...] format. Lines beginning with # are treated as comments and are ignored.

Global Directives

These directives are typically placed at the top of the file and define the overall resources for the InstanceUSM.

DirectiveExampleDescription
memorymemory 32768(Mandatory) The total amount of physical memory, in Megabytes (MB), that this InstanceUSM will manage. This memory is reserved from the kernel's Contiguous Memory Allocator (CMA) pool.
workersworkers 4The number of kernel-level POSIX threads (kThreads) the InstanceUSM will use to handle memory events. A higher number can improve throughput for workloads with many parallel faulting threads. Defaults to a system-determined value if not set.
pagepage 4096Sets the global page size in bytes for the instance. This should almost always be the system's page size (4096 on most x86 systems).

Assignment Directives

These directives form the core of your memory strategy, mapping processes to specific policies.

DirectiveExampleDescription
processprocess stressapptest policyOneAssigns a specific policy to an application. The format is process <process_name> <policy_name>. The policy_name must match the string you used when you registered the policy with usm_register_alloc_policy() or usm_register_swap_policy(). You can have multiple process lines for different applications.
thresholdthreshold 80 aggressive_evictAn advanced directive for dynamic policy switching. When global memory usage within the InstanceUSM exceeds the specified percentage (e.g., 80%), the default policy can be switched to the one specified. This feature is experimental.
prioritypriority redis-server 10Assigns a scheduling priority to a process. Higher numbers indicate higher priority. This can be used by advanced policies to make decisions (e.g., an OOM policy might choose to kill a process with priority 0 before one with priority 10).

Complete Example

Here is a complete, well-commented example of a configuration file that could be used in a production environment.

# Set global resources for this USM instance.
# Reserve 16 GB of physical memory from the CMA pool.
memory 16384
# Use 4 kernel threads to handle events.
workers 4

# --- Policy Assignments ---

# Assign the critical database server to a high-performance, custom policy.
process redis-server redis_slab_policy

# Assign the batch analytics job to a more generic policy.
process data_cruncher basic_alloc_policy

# Assign a high priority to the redis server to protect it.
priority redis-server 100

# Any other process not listed here will receive the default policy
# that was registered with 'is_default = true' in the C code.