How to trace or debug slab leaks

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux

Issue

  • How do I trace allocation of slabs?
  • Slab memory usage is quite high. How do I determine who is generating the slab allocations?

Resolution

Quite a few options exist to trace slab allocations.

Systemtap

Systemtap (also known as stap) provides a method for writing scripts to perform debugging and tracing activity in the kernel, compile the script into a custom kernel module, and load the module to enable the troubleshooting functionality provided by the custom script.

Perf

Perf is a userspace tool which interacts with the ftrace subsystem of the kernel to perform tracing within kernelspace execution.

eBPF/BCC

Extended Berkeley Packet Filter (eBPF) enables tracing and debugging within a sandboxed, in-kernel virtual machine. Tracing and debugging is written out similar to Clang programs and compiled via the BPF Compiler Collection (BCC).

Tooling within the kernel

The linux kernel offers the slub_debug kernel parameter (as well as sysfs files) to enable debugging options for slab.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments