Linux Advanced 2 05 — Kernel Modules and Resource Limits

Linux course index · Linux Advanced 2 category · Lesson 5 of 7

AI disclosure — AI-generated content, posted as is. AI can make mistakes. This extension adds new material and links related posts from this site. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.

Learning goal

Read kernel module information and identify the current process’s resource-control group without changing the kernel.

Concepts and setup

The site’s kernel and device-driver posts point to low-level Linux internals. This operational lab gives you a read-only way to inspect them. Modules are loadable kernel code. Built-in drivers may not appear in lsmod, and loading a module is not required just to learn its metadata. Control groups organize processes into resource-accounting and control hierarchies. Namespaces provide isolated views. These are different mechanisms and both can be involved in running containers.

Inspect the kernel and a module record

uname -r
lsmod | head -n 6
# If loop is present as a module or discoverable as built-in:
modinfo -F filename loop
journalctl -k -b -n 5 --no-pager

Possible output

6.x.x-example
Module                  Size  Used by
loop                   45056  0
...
/lib/modules/6.x.x-example/kernel/drivers/block/loop.ko.zst
... kernel: ...

Your actual kernel and modules differ. The loop driver can be built in or absent, and logs can require authorized access. Do not load or remove modules merely to make the output match.

Find the current cgroup and inspect a limit where supported

cat "/proc/$$/cgroup"
stat -fc '%T' /sys/fs/cgroup
group=$(awk -F: '$1=="0" && $2=="" {print $3}' "/proc/$$/cgroup")
if test -n "$group" && test -r "/sys/fs/cgroup$group/memory.max"; then
  cat "/sys/fs/cgroup$group/memory.max"
fi

Possible output

0::/user.slice/user-1000.slice/session-2.scope
cgroup2fs
max

This example uses the unified cgroup v2 hierarchy. Containers can change the cgroup view and filesystem layout. The word max means no numeric limit at this level, not necessarily no limit at any ancestor.

Questions only

Quick-check questions

  1. Does absence from lsmod prove that Linux has no such driver?
  2. What is the difference between a cgroup and a namespace?

Assessment questions

  1. Which read-only command identifies the running kernel release?
  2. In cgroup v2, why can a process hit a memory limit even if its memory.max says max?
  3. How would you collect kernel evidence without reloading a driver?

Questions and answers

Quick-check answers

  1. Does absence from lsmod prove that Linux has no such driver?
    Answer — No. It can be built into the kernel or otherwise not listed as a loaded module.
  2. What is the difference between a cgroup and a namespace?
    Answer — A cgroup groups processes for accounting and resource controls. A namespace isolates a view of a system resource.

Assessment answer key

  1. Which read-only command identifies the running kernel release?
    Answer — uname -r.
  2. In cgroup v2, why can a process hit a memory limit even if its memory.max says max?
    Answer — A parent cgroup may enforce a narrower quota.
  3. How would you collect kernel evidence without reloading a driver?
    Answer — Use boot kernel logs, lsmod and modinfo where available, and record the actual running kernel and timestamps.

Related source articles on this site

Technical references

Continue the course

Previous lesson 04 — Performance Triage with vmstat and PSI. Next lesson 06 — Encrypted Backups and Restore Drills.

Linux course index · Linux Advanced 2 category · Lesson 5 of 7

Leave a Reply