Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use __kuser_cmpxchg64 for 64-bit atomics on pre-v6 ARM Linux/Android #82

Merged
merged 1 commit into from
Mar 25, 2023

Conversation

taiki-e
Copy link
Owner

@taiki-e taiki-e commented Mar 5, 2023

Currently, we are using fallback implementation for 64-bit atomics on pre-v6 ARM Linux/Android such as armv5te-unknown-linux-gnueabi and arm-linux-androideabi.

However, Linux kernel 3.1+ provides kernel user helpers for 64-bit atomics. This could be more efficient than a lock-based fallback implementation, because it calls native atomic instructions, depending on the actual CPU version.

This PR uses __kuser_cmpxchg64 on Linux kernel 3.1+, otherwise use fallback implementation as before.

Since Rust 1.64, the Linux kernel requirement for Rust when using std1 is 3.2+, so it should be possible to omit the dynamic kernel version check if the std feature is enabled on Rust 1.64+, but that has not yet been implemented.

Footnotes

  1. https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html#affected-targets says "Targets which only use libcore and not libstd are unaffected."

@taiki-e taiki-e added the O-arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state label Mar 5, 2023
@taiki-e taiki-e force-pushed the arm-linux branch 10 times, most recently from a7a39ac to b91c04c Compare March 12, 2023 12:00
@taiki-e taiki-e marked this pull request as ready for review March 12, 2023 12:04
@taiki-e taiki-e force-pushed the arm-linux branch 8 times, most recently from aecb2af to 97993ae Compare March 25, 2023 16:05
@taiki-e
Copy link
Owner Author

taiki-e commented Mar 25, 2023

Ok, benchmarked on Graviton2 (Neoverse-N1)'s aarch32 mode. https://cirrus-ci.com/task/6137907514179584
It was about two times faster in most cases than the fallback implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant