Performance & Scaling Bug Report

Load average 40 on 4 cores with idle CPU: tasks stuck in D state on a hung NFS mount

A 4-core worker showed load average 40 while CPUs sat idle. Every extra unit of load was a process in uninterruptible sleep waiting on an NFS server that had stopped answering. How we proved it, cleared it and changed our alerts.

Le Minh Khoa Le Minh Khoa @leminhkhoa · November 20, 2026 · 8 min read · 158 Views
595-high-load-average-low-cpu-io-wait-d-state

At 14:20 our capacity alert fired for a report-rendering worker: load average above 10 for 15 minutes on a 4-vCPU VM. By the time we logged in the 1-minute load was 41. Yet top showed the CPUs 96% idle, the web UI was fine, and the only user-visible symptom was that report jobs had stopped completing.

top - 14:31:07 up 23 days,  3:12,  1 user,  load average: 41.18, 38.02, 24.55
Tasks: 263 total,   1 running, 224 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.9 us,  1.1 sy,  0.0 ni, 96.4 id,  0.4 wa,  0.0 hi,  0.2 si,  0.0 st

A shell command as simple as ls /mnt/reports hung and ignored Ctrl+C.

Reproducing it

We could not reproduce the trigger on demand at first, but the condition was easy to see: every new report job that touched /mnt/reports joined the pile and never left. Load rose by roughly one for each job the queue dispatched.

What we ruled out

  • CPU saturation. Idle was above 95% and the run queue (r column in vmstat) was 0 or 1.

  • Local disk I/O. iostat -x 1 showed %util under 2% on the root and data volumes, with tiny queue sizes.

  • Memory pressure. MemAvailable was 60% of RAM, no swap activity, PSI memory near zero.

  • A fork bomb or runaway pool. Process count was normal; the jobs had simply stopped finishing.

Root cause

On Linux, load average counts tasks that are runnable and tasks in uninterruptible sleep (state D). We had about 40 processes in D state, all blocked inside the NFS client waiting for replies from the file server that held /mnt/reports. The server's NFS service had hung after its own storage backend failed over. The mount used the default hard option, so the client retried forever and every process touching the mount waited, uninterruptibly, for a server that was not answering. No CPU was used; the load number was purely a count of waiters.

What is happening under the hood

The kernel computes load average from the number of tasks in TASK_RUNNING plus those in TASK_UNINTERRUPTIBLE, damped over 1, 5 and 15 minutes. Most Unix systems count only runnable tasks; Linux has included uninterruptible ones for decades so that load reflects demand on disks as well as CPUs. The practical consequence: on Linux, a high load with idle CPUs is almost always a crowd of D tasks.

A task enters D when it waits for something the kernel does not want interrupted midway, typically a block device or network filesystem request. Signals are not delivered until the wait ends, which is why kill -9 did nothing. NFS hard mounts use killable waits in modern kernels, so a fatal signal can end some of them, but tasks often re-enter the wait or are stuck in paths that are not killable.

With hard (the default), the NFS client retries a request until the server answers. The nfs(5) man page recommends hard for data integrity: a soft mount gives up after retrans retries and returns an I/O error to the application, which can silently corrupt data if the program does not handle it.

The kernel also has a hung-task detector. When a task stays in D longer than kernel.hung_task_timeout_secs (120 seconds by default on most distributions), it logs a warning with the stack trace.

Environment

Component

Version / value

OS

Rocky Linux 9.4, kernel 5.14

NFS client

nfs-utils 2.5, NFSv4.1

Mount options

rw,hard,proto=tcp,timeo=600,retrans=2,vers=4.1 (defaults)

Workload

Python report renderer, 8 worker processes, jobs from a Redis queue

VM

4 vCPU, 8 GB RAM

Minimal reproduction

On a test client with a scratch NFS export, blocking the server's traffic recreates the pile-up:

# On the NFS server (test only): silently drop client traffic
sudo iptables -I INPUT -s 198.51.100.24 -p tcp --dport 2049 -j DROP

# On the client: start a few readers, then watch load climb
for i in $(seq 1 10); do (cat /mnt/scratch/file.bin > /dev/null &); done
watch -n5 cat /proc/loadavg

Load climbs by about ten while CPUs stay idle. Removing the DROP rule releases the tasks.

Who is affected

Any Linux host with network filesystems (NFS, CIFS/SMB, FUSE-based mounts such as object storage gateways), or with local storage that stops responding (a failed RAID controller, a multipath device with no live path, a cloud block volume being detached). The symptom is the same: high load, idle CPU, commands touching one path hang.

The fix

Step 1: confirm the crowd and where it waits.

# Count tasks by state
ps -eo stat= | cut -c1 | sort | uniq -c

# D-state tasks with the kernel function they sleep in
ps -eo pid,stat,wchan:32,args | awk 'NR==1 || $2 ~ /^D/'
    PID STAT WCHAN                            COMMAND
  18842 D    rpc_wait_bit_killable            python3 render.py --job 88123
  18901 D    rpc_wait_bit_killable            python3 render.py --job 88124
  19012 D    nfs_wait_bit_killable            ls /mnt/reports

rpc_wait_bit_killable and nfs_* wait channels point straight at the NFS client. vmstat 1 agreed: column b (blocked tasks) sat around 40 while r was near zero.

Step 2: read the kernel's own diagnosis.

journalctl -k --since "-1h" | grep -E 'nfs: server|blocked for more than'
kernel: nfs: server files01.example.internal not responding, still trying
kernel: INFO: task python3:18842 blocked for more than 122 seconds.

For one task, sudo cat /proc/18842/stack showed the RPC call chain inside the NFS client, which removed any remaining doubt.

Step 3: fix the server, not the client. The storage team restarted the NFS service on the file server once its backend was healthy. The client logged nfs: server files01.example.internal OK, the waiting tasks completed within seconds, and load decayed over the next 15 minutes as the damped average caught up.

Step 4: stop the queue from feeding the pile. During the outage the job dispatcher kept handing out work to processes that would block immediately. We added a health check to the worker that tests the mount with a bounded wait before taking a job:

timeout 5 stat -t /mnt/reports/.healthcheck > /dev/null || exit 1

If the check fails, the worker stops pulling from the queue and reports unhealthy instead of adding another D task.

If the server cannot be recovered and you must free the mount, a lazy, forced unmount (umount -f -l /mnt/reports) detaches it from the namespace; processes still holding files may stay stuck until reboot. Treat it as a last resort.

Alternatives and trade-offs

  • Switch to soft mounts. Reads fail with EIO after timeo and retrans instead of hanging. Acceptable for read-only caches; risky for writes, where an application that ignores the error leaves partial files. We kept hard.

  • Use softerr (kernel 5.6+). Like soft but returns ETIMEDOUT, which applications can distinguish from a disk error. Same data-safety caveat.

  • Move reports to object storage. Removes the shared filesystem from the hot path entirely; this is the long-term plan, since HTTP clients time out and retry cleanly.

How to test the fix

On the test client we repeated the iptables drop and confirmed that the worker health check failed within five seconds, that the worker stopped taking jobs, and that load rose only by the number of jobs already in flight.

Confirming in production

After recovery the numbers returned to normal:

cat /proc/loadavg              # falls back toward 1-2 over 15 minutes
ps -eo stat= | grep -c '^D'    # 0
vmstat 1 5                     # b column back to 0

Report job throughput in the queue dashboard returned to its usual rate within a minute of the server recovering.

Regression guard

Our old load alert compared load to a fixed number, which told us something was wrong but sent us to look at CPU. We split it into two node_exporter-based alerts:

- alert: HostCpuSaturated
  expr: avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) < 0.10
  for: 15m
- alert: HostTasksBlocked
  expr: node_procs_blocked > 10
  for: 5m
  annotations:
    summary: "{{ $labels.instance }} has tasks in uninterruptible sleep; check storage and network mounts"

node_procs_blocked comes from procs_blocked in /proc/stat and directly counts tasks waiting on I/O. We also forward kernel logs matching not responding, still trying and blocked for more than to the alert channel.

Security implications

None in the bug itself. Two notes on the fix: the mount health check runs as the worker's own user and only stats a marker file, so it needs no extra privileges; and do not "fix" this class of problem by exporting the share with broader permissions or switching to an unauthenticated protocol to avoid timeouts. A hung file server is an availability problem, so treat it with timeouts and isolation, not with relaxed access control.

Prevention checklist

  • Read high load with idle CPU as "count the D tasks", not "add cores".

  • Alert on node_procs_blocked and kernel hung-task messages, not only on load.

  • Health-check network mounts with a bounded timeout before workers take jobs.

  • Keep hard for writable NFS unless the application handles I/O errors correctly.

  • Keep shared filesystems off the request path where an object store or API would do.

References

Add a label

#linux #vmstat #load-average #nfs #d-state
Written by
Le Minh Khoa @leminhkhoa

I work on databases and data pipelines: MySQL and PostgreSQL in production, Kafka streams, change data capture and the analytical stores downstream. I started as a backend developer on a gaming platform, where a single race condition could hand out items that did not exist, and that taught me to respect concurrency early. Most of my posts start with an alert: a disk filling overnight, a server at full CPU, missing rows after a failover. I show how we traced it to the root cause, the fix, and the monitoring or test we added so it does not happen twice.

Advertisement

Comments

0

No comments yet. Be the first to comment!

Sign In to post a comment.