Fall back to alternative membarrier command on aarch64 to support older kernels.#4987
Fall back to alternative membarrier command on aarch64 to support older kernels.#4987cfallin wants to merge 1 commit into
Conversation
| rustix::process::MembarrierCommand::RegisterPrivateExpeditedSyncCore, | ||
| ) | ||
| // Fallback for older kernels that don't support the above command. | ||
| .or_else(|_| rustix::process::membarrier(rustix::process::MembarrierCommand::Global)) |
There was a problem hiding this comment.
RegisterPrivateExpeditedSyncCore registers intent to use PrivateExpeditedSyncCore later on in the publish method. Global should be used in publish and doesn't have an associated register command.
| rustix::process::MembarrierCommand::RegisterPrivateExpeditedSyncCore, | ||
| ) | ||
| // Fallback for older kernels that don't support the above command. | ||
| .or_else(|_| rustix::process::membarrier(rustix::process::MembarrierCommand::Global)) |
There was a problem hiding this comment.
This change should be applied to line 171 instead, and I think that here you can just use unwrap_or_default().
Since the EXPEDITED commands have additional overhead (according to the documentation), the process must opt in explicitly to use them via the corresponding REGISTER command (e.g. MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE); the call here is precisely that registration.
BTW in hindsight when I implemented this initially, adding this call here was probably not the best idea because the registration should happen only once for the whole lifetime of the process (instead of whenever a CodeMemory object is created, though subsequent registrations are harmless); perhaps the moment of the Engine creation is a better time? Of course, that assumes that no one is going to use a CodeMemory object without creating an Engine first.
There was a problem hiding this comment.
Ninja'd by @bjorn3 😃.
P.S. There is another option that I have come up with in #4997 - just run MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE. If it fails with an EPERM error, execute MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE and retry. If it fails with EINVAL instead, fall back to MEMBARRIER_CMD_GLOBAL/MEMBARRIER_CMD_SHARED. In all other cases fail.
|
Subsumed by @afonso360 's work in #4997 before I could get back to this -- thanks :-) |
This is an attempt to fix #4972 by adding a fallback syscall that older kernels should support. The fallback is invoked only if the more specific membarrier fails.