Amir Reza Ghods
A Study of Linux Perf and Slab Allocation Sub-Systems
Today, modern processors are equipped with a special unit named Performance Monitoring Unit (PMU) that enables software developers to gain access to micro-architectural level information such as CPU cycles count, executed instructions count, etc. The PMU provides a set of programmable registers called hardware performance counters that can be programmed to count the specific hardware events. In the Linux operating system, many low-level interfaces are designed to provide access to the hardware counters facilities. Perf event is one of these interfaces that was merged as a sub-system to the kernel mainline, and became a widely used interface for hardware counters.
In the first part of our research, we investigate the perf event Linux sub-system in the kernel-level by exploring the kernel source code to identify the potential sources of overhead and counting error. We also study the Perf tool as one of the end-user interfaces that was built on top of the perf event sub-system to provide an easy-to-use measurement and profiling tool in the Linux operating system. Moreover, we conduct some experiments on a variety of processors to analyze the overhead, determinism, and accuracy of the Perf tool and the underlying perf event sub-system in counting hardware events. Despite our results show 47% error in counting the number of taken branches as well as 5.92% relative overhead on the Intel Pentium 4 processors, we do not observe a significant overhead or inaccuracy on the modern x86 and ARM processors.
The second part of the research is dedicated to a memory management sub-system of Linux kernel, called slab allocator, that plays a crucial role in the overall performance of the system. We study three different implementations of the slab allocator that are currently available in the Linux kernel mainline and enumerate the advantages and disadvantages of each implementation. We also investigate the binning effect of the slab allocator on the Linux system calls execution time variation. Moreover, we introduce a new metric called “Slab Metric” that is assigned to each system call to represent the interaction level with the slab allocator. The results show a correlation coefficient of 0.78 between the dynamic slab metric and the execution time variation of the Linux system calls.