Linux's vmalloc Seeing "Large Performance Benefits" With 5.2 Kernel Changes

Written by Michael Larabel in Linux Kernel on 19 May 2019 at 03:57 PM EDT. 15 Comments
LINUX KERNEL
On top of all the changes queued for Linux 5.2 is an interesting last-minute performance improvement for the vmalloc code.

The Linux kernel's vmalloc code has the potential of performing much faster on Linux 5.2, particularly with embedded devices. Vmalloc is used for allocating contiguous memory in the virtual address space and saw a nice optimization merged today on the expected final day of the Linux 5.2 merge window.

As part of a pull merged minutes ago from Andrew Morton are "large changes to vmalloc, yielding large performance benefits."

The principal change to the vmalloc code is keeping track of free blocks for allocation.
Currently an allocation of the new VA area is done over busy list iteration until a suitable hole is found between two busy areas. Therefore each new allocation causes the list being grown. Due to long list and different permissive parameters an allocation can take a long time on embedded devices(milliseconds).

This patch organizes the vmalloc memory layout into free areas of the VMALLOC_START-VMALLOC_END range. It uses a red-black tree that keeps blocks sorted by their offsets in pair with linked list keeping the free space in order of increasing addresses.

With this patch from Uladzislau Rezki, calling vmalloc() can take up to 67% less time compared to the behavior on Linux 5.1 and prior, at least with tests done by the developer under QEMU.

Linux 5.2 is shaping up to be a very exciting kernel release. Linux 5.2-rc1 will be released as soon as tonight while the stable kernel should debut in July.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week