Scope-Based Resource Management Infrastructure Merged For Linux 6.5

Written by Michael Larabel in Linux Kernel on 4 July 2023 at 07:08 PM EDT. 39 Comments
LINUX KERNEL
Here comes a very exciting addition to the Linux 6.5 kernel: the initial infrastructure has landed for scope-based resource management.

Peter Zijlstra of Intel has been working on this scope-based resource management code and the initial infrastructure is ready for Linux 6.5. Developers now will be able to leverage this functionality and make use of it in various areas over the coming releases.

The scope-based resource management for the kernel is based around the new __cleanup() macro for the Linux kernel that wraps around the GCC and LLVM Clang "cleanup" attribute. The compiler "cleanup" attribute allows for defining a function to be called when a variable goes out-of-scope and the compiler will ensure that memory is properly freed to avoid memory leaks. This support has been worked on by Zijlstra as part of his kernel lock and pointer guards code.

This pull request merged today on the US Independence Day adds the scope-based resource management infrastructure. But it's left for future merge windows (or trying to still squeeze this week into Linux 6.5 albeit unlikely) for actually converting existing code to make use of this __cleanup() infrastructure.
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