Operations 8 min read

What Is Linux loadavg? Understanding Run Queues and Kernel Calculation

This article explains the Linux load average metric, the run queue structure, why both running (R) and uninterruptible (D) processes are counted, and how the kernel uses an exponential weighted moving average to compute the 1‑, 5‑, and 15‑minute load values.

Efficient Ops
Efficient Ops
Efficient Ops
What Is Linux loadavg? Understanding Run Queues and Kernel Calculation

Linux loadavg: What It Is and Where It Comes From

In interviews I often start with the question “What is loadavg?” to gauge a candidate’s understanding. Most answer with the standard definition: the average number of processes in the run queue over a specific time interval, calculated by the kernel.

From there I ask deeper questions:

What exactly is the run queue?

Which types of processes are included in the run queue?

Why are those process types counted?

What algorithm does the kernel use to compute the average?

What loadavg value is considered high?

Run Queue (Runqueue)

Each CPU core maintains its own runqueue data structure. The runqueue is not only used for loadavg; it also plays a major role in CPU scheduling.

Two fields are relevant for loadavg:

nr_running – number of processes in state R (running or runnable).

nr_uninterruptible – number of processes in state D (uninterruptible, usually I/O).

State D processes do not execute CPU instructions but still occupy the CPU because they are performing critical I/O operations that cannot be safely interrupted.

The run queue is a per‑CPU kernel data structure that serves many purposes.

It contains both R‑state and D‑state processes.

The kernel source comment that explains the counting is:

<code>* Once every LOAD_FREQ:
 *
 *   nr_active = 0;
 *   for_each_possible_cpu(cpu)
 *     nr_active += cpu_of(cpu)->nr_running + cpu_of(cpu)->nr_uninterruptible;</code>

Why Include D Processes?

Early Linux versions only counted R processes, which caused misleadingly low loadavg on I/O‑bound systems that have many D processes. Adding D processes yields a more accurate picture of overall system load, not just CPU load.

How the Kernel Calculates loadavg

Linux always reports three numbers: the 1‑minute, 5‑minute, and 15‑minute load averages. The kernel does not simply average samples with equal weight; it uses an exponential weighted moving average (EWMA), giving more weight to recent samples.

In a naïve approach you would take n samples of the active process count over a minute, sum them, and divide by n. The kernel instead applies EWMA, where the newest sample has the highest weight and older samples have progressively smaller weights.

This method not only saves resources but also reflects the trend of the metric, similar to how recent weather data is more predictive of tomorrow’s temperature than older data.

Interpreting the loadaverage Metric

It is a common misconception that loadaverage divided by the number of CPU cores greater than or equal to 1 always indicates a performance problem. Because loadavg includes both R and D processes, the simple division can be misleading.

There is no universal threshold such as 0.7 × CPU‑cores that guarantees good performance. The significance of a loadavg value depends on the typical baseline for a given machine and the trend over time. For example, an 8‑core server normally running at loadavg 8 may be fine, but a sudden jump to 15 could signal trouble.

Therefore, loadavg should be evaluated together with other system metrics rather than in isolation.

Reference

For further reading, see the article “Linux Load Averages: Solving the Mystery” and resources on understanding average load and exponential weighted averages.

KernelLinuxsystem performanceload averagerun queue
Efficient Ops
Written by

Efficient Ops

This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.