How to Manage Persistent Profiling Settings in Linux Using perf config

When operating the Linux perf profiling subsystem across production servers, multi-tenant developer sandboxes, or embedded test benches, repetitive manual flag declarations—such as specifying DWARF call graph unwinding (--call-graph dwarf), defining sample buffer sizes, overriding default color schemes, or toggling browser interfaces—can introduce command-line friction and lead to inconsistent profiling data. Rather than passing dozens of CLI switches on every execution of perf record, perf report, or perf top, the Linux kernel tracing infrastructure provides a unified configuration architecture. Managed via perf config, administrators and performance engineers can query, declare, and persist global system defaults (in /etc/perfconfig) and per-user personal preferences (in ~/.perfconfig) across the entire profiling lifecycle.

Architecture of the Linux perf Configuration Hierarchy

The Linux perf configuration engine follows a layered precedence hierarchy modelled similarly to Git configuration files. When any perf subcommand executes, it reads configurations in the following order:

  1. System-Wide Configuration (/etc/perfconfig): Defines baseline parameters applied to all users across the host operating system. Ideal for enforcing company-wide DWARF unwinding limits, default pager bindings, or restricted hardware counter access.
  2. User-Level Configuration (~/.perfconfig): Personal settings maintained within the user’s home directory. Overrides system-level settings and personalizes terminal colour themes, interactive TUI bindings, or custom script paths.
  3. Command-Line Flags: Explicit arguments passed at runtime (such as -g or --no-children) hold the highest precedence, temporarily overriding configuration files for that invocation.

Auditing and Listing Active Configurations with perf config

Before modifying persistent variables, review the current configuration landscape. Execute perf config without arguments or with the --list switch:

# List all currently active configuration variables
perf config --list

# Inspect user-specific configurations only
perf config --user --list

# Inspect system-wide configurations only
perf config --system --list

If no configuration file exists, the command returns nothing, confirming that perf is operating entirely on built-in compile-time defaults.

Configuring Call Graph Defaults for perf record

One of the most valuable optimizations in perf config is establishing persistent call-chain unwinding standards. Storing these settings eliminates the need to pass complex call-graph flags during live incident triage:

# Set DWARF as the default call graph unwinding method
perf config call-graph.record-mode=dwarf

# Define the maximum stack dump size in bytes (e.g. 8192 bytes)
perf config call-graph.dump-limit=8192

# Configure the default print mode in reports (graph, flat, fractal, or folded)
perf config call-graph.print-type=graph

# Set the call graph sorting order (caller or callee)
perf config call-graph.order=caller

Immediately after setting these values, invoking perf record -g -- ./workload automatically employs DWARF unwinding with the designated dump limit without requiring explicit syntax on the terminal.

Customising Terminal UI and Interactive Display Defaults

For engineers analyzing traces interactively, customizing terminal pager behaviours and visual presentation enhances legibility during deep stack trace navigation:

# Enable interactive header visibility in perf report
perf config ui.show-headers=true

# Set the preferred text editor for source code annotations
perf config ui.editor=/usr/bin/nano

# Customize terminal color thresholds (percentages) for hot code paths
perf config colors.top=red
perf config colors.medium=yellow
perf config colors.normal=green

Configuring custom colour boundaries allows developers to quickly distinguish execution bottlenecks exceeding critical threshold percentages during live perf top inspections.

Setting Default Build ID Cache Locations and Pager Behaviours

When working across multi-drive servers or containerized hosts with limited root storage, redirect the Build ID symbol cache to a high-capacity storage volume:

# Redirect the buildid cache directory
perf config buildid.dir=/var/cache/perf-debug/

# Force perf report and perf annotate to invoke less with specific options
perf config pager.cmd="less -R -i"

Inspecting and Editing Configuration Files Directly

Because perf config stores variables using standard INI syntax, you can review the structured file directly:

# Display the generated user configuration file
cat ~/.perfconfig

Review the clean section hierarchy produced by the utility:

[call-graph]
	record-mode = dwarf
	dump-limit = 8192
	print-type = graph
	order = caller
[ui]
	show-headers = true
	editor = /usr/bin/nano
[colors]
	top = red
	medium = yellow
	normal = green

Removing Configuration Entries and Resetting to Defaults

To purge a specific setting or revert a parameter back to compile-time hypervisor defaults, execute perf config with the variable name and an empty assignment or delete the key:

# Remove a specific configuration key from ~/.perfconfig
perf config --user --remove call-graph.dump-limit

# Verify the removal
perf config --list

Leveraging perf config standardises profiling workflows across development teams, eliminates command-line clutter, and guarantees consistent, reproducible performance traces across enterprise Linux environments.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.