Skip to contentSkip to conversation

Adaptative busy spinning with rseq

DISCUSSION Mathieu Desnoyers 1 participant 1 message Jan 16, 2019

lore
Share & tools
lore
#0 lore raw

Hi!

A follow up on the Edinburgh discussion I had with Daniel: I did a prototype implementation of adaptative busy spinning with rseq. It only uses current upstream rseq features. It's not optimized at this stage (and I don't have time to work more on it at the moment), and it's only x86-64, but I'm throwing the code out there for feedback:

https://github.com/compudj/rseq-test/blob/adapt-lock/test-rseq-adaptative-lock.c

The trick here is to rely on the Zero Flag being invariant for a sub-section of the rseq critical sections, and use it to figure out if it has been aborted after cmpxchg has succeeded. Testing the Zero Flag on abort basically removes the rseq requirement that the very last instruction of a rseq critical section needs to be the "commit" instruction, allowing us to cover an entire loop within a rseq critical section.

Feedback is welcome!

Thanks,

Mathieu

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com