Microsoft Makes An Interesting Improvement To Kernel Modules With Linux 6.13
Sent out on Tuesday was the modules pull request for Linux 6.13 that have some low-level improvements but it noted that the biggest kernel modules highlight wasn't in that pull request itself but had been added by way of the memory management pull. This was a change by a Microsoft engineer around caching of kernel modules into huge pages.
Luis Chamberlain sent in the modules changes on Tuesday and noted there that Microsoft engineer Mike Rapoport had seen his module caching patches merged via Andrew Morton's MM pull.
Last week the MM pull went in with some nice performance optimizations, lightweight guard pages, and more. That pull had the patches as well from Microsoft's Mike Rapoport for using large ROX pages for module text allocations.
The set of patches on x86_64 begins using large read only execute (ROX) pages for allocations of executable memory. Rapoport explained on those patches:
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:
This support is gated by the new "ARCH_HAS_EXECMEM_ROX" option and initially is only supported/enabled for x86_64 Linux kernel builds. In future kernel cycles this execmem ROX support could be extended to other CPU architectures.
These patches had gone through seven rounds of review and discussion among kernel developers and now with Linux 6.13 are upstream. More details on the other module changes for Linux 6.13 via this pull. The Linux 6.13 kernel is shaping up to be another very exciting feature-packed release and will be out in early 2025 for appearing in spring distribution releases.
Luis Chamberlain sent in the modules changes on Tuesday and noted there that Microsoft engineer Mike Rapoport had seen his module caching patches merged via Andrew Morton's MM pull.
"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."
Last week the MM pull went in with some nice performance optimizations, lightweight guard pages, and more. That pull had the patches as well from Microsoft's Mike Rapoport for using large ROX pages for module text allocations.
The set of patches on x86_64 begins using large read only execute (ROX) pages for allocations of executable memory. Rapoport explained on those patches:
"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 gated by the new "ARCH_HAS_EXECMEM_ROX" option and initially is only supported/enabled for x86_64 Linux kernel builds. In future kernel cycles this execmem ROX support could be extended to other CPU architectures.
These patches had gone through seven rounds of review and discussion among kernel developers and now with Linux 6.13 are upstream. More details on the other module changes for Linux 6.13 via this pull. The Linux 6.13 kernel is shaping up to be another very exciting feature-packed release and will be out in early 2025 for appearing in spring distribution releases.
45 Comments