Re: [PATCH v4 1/5] getcpu_cache system call: cache CPU number of running thread

From: Peter Zijlstra
Date: Tue Mar 01 2016 - 16:36:41 EST


On Tue, Mar 01, 2016 at 10:32:02PM +0100, Peter Zijlstra wrote:

> > /*
> > * Thread-local ABI rseq_seqnum field.
> > * Updated by the kernel, and read by user-space with
> > * single-copy atomicity semantics. Aligned on 32-bit.
> > * Values:
> > * >= 0: current seqnum for this thread (feature is active).
> > * -1 (initial value): means the rseq feature is inactive.
> > * -2: rseq feature is not available.
> > */
> > int32_t rseq_seqnum;
>
> So I really hate that, that makes we have to check for these special
> values whenever we increment the seq count and cannot have it wrap
> naturally.

Also, since it will wrap, uint32_t is more natural, since the whole
signed overflow thing is somewhat undefined in C.