From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [PATCH v4 1/5] getcpu_cache system call: cache CPU number of running thread Date: Tue, 1 Mar 2016 22:36:11 +0100 Message-ID: <20160301213611.GY6375@twins.programming.kicks-ass.net> References: <1456270120-7560-1-git-send-email-mathieu.desnoyers@efficios.com> <1401667361.10273.1456617236327.JavaMail.zimbra@efficios.com> <1082926946.10326.1456619994590.JavaMail.zimbra@efficios.com> <1538518747.10504.1456669948568.JavaMail.zimbra@efficios.com> <20160229103506.GJ6356@twins.programming.kicks-ass.net> <676569856.13488.1456863792603.JavaMail.zimbra@efficios.com> <20160301213202.GY6357@twins.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20160301213202.GY6357-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Mathieu Desnoyers Cc: "H. Peter Anvin" , Linus Torvalds , Ben Maurer , Thomas Gleixner , Ingo Molnar , Russell King , linux-api , Andrew Morton , Michael Kerrisk , Dave Watson , rostedt , Andy Lutomirski , Will Deacon , "Paul E. McKenney" , Chris Lameter , Andi Kleen , Josh Triplett , Paul Turner , Linux Kernel Mailing List , Catalin Marinas , Andrew Hunter List-Id: linux-api@vger.kernel.org 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.