Linus Torvalds Improves Futex Code To Improve User-Space Accesses
In between managing all of the pull requests being submitted during this two week long merge window for the Linux 6.13 kernel, Linus Torvalds has merged some of his own code this cycle.
Coming just a month after Torvalds himself worked out a minor performance optimization patch in Linux 6.12, for Linux 6.13 he's onto another minor optimization. This time around Torvalds is working on improving user-space accesses from within the Futex code.
Going off this Linux kernel mailing list thread, Torvalds came up with a new improvement to the kernel. The Linux creator explained in yesterday's commit:
Linus Torvalds got that Futex code cleaned up with a few dozen lines of code. Josh Poimboeuf who worked on the original optimization patch commented he didn't have a chance yet to re-create the original benchmark but the new code "looks obviously correct."
This is just a minor improvement overall but Linux 6.13 as a whole is shaping up to be very exciting from new features to continuing with more performance optimizations.
Coming just a month after Torvalds himself worked out a minor performance optimization patch in Linux 6.12, for Linux 6.13 he's onto another minor optimization. This time around Torvalds is working on improving user-space accesses from within the Futex code.
Going off this Linux kernel mailing list thread, Torvalds came up with a new improvement to the kernel. The Linux creator explained in yesterday's commit:
"Josh Poimboeuf reports that he got a "will-it-scale.per_process_ops 1.9% improvement" report for his patch that changed __get_user() to use pointer masking instead of the explicit speculation barrier. However, that patch doesn't actually work in the general case, because some (very bad) architecture-specific code actually depends on __get_user() also working on kernel addresses.
A profile showed that the offending __get_user() was the futex code, which really should be fixed up to not use that horrid legacy case. Rewrite futex_get_value_locked() to use the modern user acccess helpers, and inline it so that the compiler not only avoids the function call for a few instructions, but can do CSE on the address masking.
It also turns out the x86 futex functions have unnecessary barriers in other places, so let's fix those up too."
Linus Torvalds got that Futex code cleaned up with a few dozen lines of code. Josh Poimboeuf who worked on the original optimization patch commented he didn't have a chance yet to re-create the original benchmark but the new code "looks obviously correct."
This is just a minor improvement overall but Linux 6.13 as a whole is shaping up to be very exciting from new features to continuing with more performance optimizations.
3 Comments