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

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

Reply via email to