More improvements to kernel modules with Linux 6.13

6 Views
3 Min Read

The Linux Kernel 6.13 modules pull request that included several low-level enhancements was sent out on Tuesday. However, it was pointed out that the memory management pull had introduced the largest kernel module highlight, which was not in the pull request itself. A Microsoft engineer made this modification regarding the caching of kernel modules onto large pages.

Microsoft engineer Mike Rapoport had his module caching patches merged through Andrew Morton’s MM pull, according to Luis Chamberlain, who submitted the module improvements on Tuesday.

“The whole caching of module code into huge pages by Mike Rapoport is going in through Andrew Morton’s tree due to some other code dependencies. That’s really the biggest highlight for Linux kernel modules in this release. With it we share huge pages for modules, starting off with x86.”

The MM pull was released last week and included lightweight guard pages, some great performance improvements, and more. The fixes from Microsoft’s Mike Rapoport for using large ROX pages for module text allocations were also included in that pull.

linux 6.13 kernel

The x86_64 patch set starts allocating executable memory using big read-only-execute (ROX) pages. Regarding those patches, Rapoport clarified:

“In order to support ROX allocations for module text, it is necessary to handle modifications to the code, such as relocations and alternatives patching, without write access to that memory.

One option is to use text patching, but this would make module loading extremely slow and will expose executable code that is not finally formed.

A better way is to have memory allocated with ROX permissions contain invalid instructions and keep a writable, but not executable copy of the module text. The relocations and alternative patches would be done on the writable copy using the addresses of the ROX memory. Once the module is completely ready, the updated text will be copied to ROX memory using text patching in one go and the writable copy will be freed.”

The patch to add support for caching of large ROX pages is where things get more enticing for reducing TLB instruction pressure and improving performance:

“Using large pages to map text areas reduces iTLB pressure and improves performance.”

This support is originally only supported/enabled for x86_64 Linux kernel builds and is gated by the new “ARCH_HAS_EXECMEM_ROX” option. This execmem ROX functionality may be expanded to other CPU architectures in subsequent kernel cycles.

These fixes are now upstream in Linux 6.13 after undergoing seven rounds of evaluation and discussion among kernel developers. See this pull for more information on the other Linux 6.13 module changes. Early in 2025, the Linux 6.13 kernel—which will be included in spring distribution releases—looks to be another extremely feature-rich version.

Share This Article
Leave a Comment