Re: [RFC PATCH v9 for 4.15 01/14] Restartable sequences system call
From: Ben Maurer
Date: Wed Oct 18 2017 - 12:43:12 EST
> The layout of struct rseq_cs is as follows:
> start_ip
> Instruction pointer address of the first instruction of the
> sequence of consecutive assembly instructions.
> post_commit_ip
> Instruction pointer address after the last instruction of
>Â the sequence of consecutive assembly instructions.
>Â abort_ip
> Instruction pointer address where to move the execution
>Â flow in case of abort of the sequence of consecutive assemâ
>Â bly instructions.
Really minor performance performance thought here.
1) In the kernel at context switch time you'd need code like:
if (ip >= start_ip && ip <= post_commit_ip)
This branch would be hard to predict because most instruction pointers would be either before or after. If post_commit_ip were relative to start_ip you could do this:
if (ip - start_ip <= post_commit_offset)
which is a single branch that would be more predictable.
2) In a shared library a rseq_cs structure would have to be relocated at runtime because at compilation time the final address of the library wouldn't be known. I'm not sure if this is important enough to address, but it could be solved by making the pointers relative to the address of rseq_cs. But this would make for an uglier API.