Linus Torvalds Lands A 2.6% Performance Improvement With Minor Linux Kernel Patch
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 patch:
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 Linux 6.12 stable release being out in the back half of November.
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 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 Linux 6.12 stable release being out in the back half of November.
21 Comments