AlgoViz

Reading procfs, sysfs and cgroupfs

medium 7 min

Some filesystem paths expose live kernel state.

Video lesson · Chapter 1 of 8

Why two memory dashboards disagree

0:00 / 5:54

Theory

Read or listen first. About 1 min.

What it is

Some filesystem paths expose live kernel state. Reading them produces a view at that instant, so successive reads need not describe one atomic snapshot. Procfs exposes processes and kernel counters. Sysfs organizes devices and attributes, while cgroupfs describes resource groups, their controllers and their limits.

Why it exists

A dashboard reads machine-wide available memory from a container. It shows headroom immediately before that container receives an OOM kill. Record the process’s cgroup, its memory.current, memory.max and event deltas, and keep the node view as context. A metric needs a scope, a unit and a timestamp before two dashboards can be compared.

If local events are flat, check effective ancestor limits, process termination status and kernel events for the same timestamp.

Why two memory dashboards disagree

Process view → Kernel counters (inspect process). Process view → Cgroup controller (inspect group)
Process view → Kernel counters (inspect process). Process view → Cgroup controller (inspect group)

Inside this chapter

procfs (/proc) internals: maps, fd, environ, limits
Procfs exposes process-specific mappings, descriptors and limits. Select the correct PID and namespace. Diagnostic collection should minimize fields because some process data may contain sensitive values.
sysfs (/sys) internals: hardware device mapping
Sysfs presents devices and their relationships and attributes. A block device name alone may hide a virtual layer, so trace its device mapping before attributing physical latency.
Understanding Load Average calculations
Linux load averages smooth runnable tasks and certain uninterruptible waits across several windows. They are counts rather than CPU percentages and are best interpreted with queue and pressure metrics.
tmpfs and ramfs
Tmpfs uses memory-backed storage that can be limited and may use swap. Ramfs lacks equivalent size management, so an unchecked writer can consume host memory.
debugfs and tracefs
Tracefs exposes tracing controls and observations. Debugfs offers kernel-specific diagnostics with weaker interface stability. Prefer bounded, authorized observations on the affected subsystem.
cgroupfs (/sys/fs/cgroup)
Cgroupfs exposes membership, controller settings, events and accounting. Read the effective hierarchy, since an ancestor limit may bind more tightly than a child’s nominal setting.

How it works

Step through the idea, or press Play.

Step 1 of 4

Open a kernel interface. A reader opens a procfs or sysfs path in its current view.

Understand it

Worked incident

Why two memory dashboards disagree

ObservationMemory charged to workload (MiB)Interpretation
Baseline180The process and its peers fit within their group limit.
Incident440The cgroup approaches its limit while the node still has free memory.
After intervention205Reduce the charged working set or size the group deliberately. Verify event deltas across the next load window.
Illustrative measurements from the same workload at three checkpoints.

Choose the next investigation

If local events are flat, check effective ancestor limits, process termination status and kernel events for the same timestamp.

Summary

The whole topic in one minute.

Enforcement follows the group hierarchy. A node-level total describes a different budget.

If local events are flat, check effective ancestor limits, process termination status and kernel events for the same timestamp.

Sources