Linus Torvalds Lands A 2.6% Performance Improvement With Minor Linux Kernel Patch
([Linux Kernel] 6 Hours Ago
Will It Scale? 2.6% Faster)
- Reference: 0001502897
- News link: https://www.phoronix.com/news/Linus-2.6p-Faster-Scale-Patch
- Source link:
Linus Torvalds merged a patch on Wednesday that he authored that with reworking a few lines of code is able to score a 2.6% improvement within Intel's well-exercise "will it scale" per-thread-ops benchmark test case.
The patch written by Linux creator Linus Torvalds in turn is based on an earlier patch proposed by kernel developer Josh Poimboeuf. The intent is on avoiding the use of barrier_nospec() within the 64-bit copy_from_user() function.
Linus Torvalds explains in the 21-line kernel [1]patch :
"The barrier_nospec() in 64-bit copy_from_user() is slow. Instead use pointer masking to force the user pointer to all 1's for an invalid address.
The kernel test robot reports a 2.6% improvement in the per_thread_ops benchmark."
With copy_from_user() being used to copy a block of data from user-space to kernel-space, it will be interesting to see if this minor optimization ends up having an impact in any of the other synthetic or real-world workloads. In any event, every little optimization to the kernel adds up... Especially when this optimization is a result of avoiding the overhead of barrier_nospec -- preventing speculative execution past the barrier as part of the Spectre mitigations that have been oh so costly over the years.
This patch is merged to Linux Git and will be part of next Sunday's Linux 6.12-rc6 kernel release ahead of the [2]Linux 6.12 stable release being out in the back half of November.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0fc810ae3ae110f9e2fcccce80fc8c8d62f97907
[2] https://www.phoronix.com/search/Linux+6.12
The patch written by Linux creator Linus Torvalds in turn is based on an earlier patch proposed by kernel developer Josh Poimboeuf. The intent is on avoiding the use of barrier_nospec() within the 64-bit copy_from_user() function.
Linus Torvalds explains in the 21-line kernel [1]patch :
"The barrier_nospec() in 64-bit copy_from_user() is slow. Instead use pointer masking to force the user pointer to all 1's for an invalid address.
The kernel test robot reports a 2.6% improvement in the per_thread_ops benchmark."
With copy_from_user() being used to copy a block of data from user-space to kernel-space, it will be interesting to see if this minor optimization ends up having an impact in any of the other synthetic or real-world workloads. In any event, every little optimization to the kernel adds up... Especially when this optimization is a result of avoiding the overhead of barrier_nospec -- preventing speculative execution past the barrier as part of the Spectre mitigations that have been oh so costly over the years.
This patch is merged to Linux Git and will be part of next Sunday's Linux 6.12-rc6 kernel release ahead of the [2]Linux 6.12 stable release being out in the back half of November.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0fc810ae3ae110f9e2fcccce80fc8c8d62f97907
[2] https://www.phoronix.com/search/Linux+6.12
Danny3