From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757515AbcDGUWi (ORCPT ); Thu, 7 Apr 2016 16:22:38 -0400 Received: from one.firstfloor.org ([193.170.194.197]:54274 "EHLO one.firstfloor.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753175AbcDGUWg (ORCPT ); Thu, 7 Apr 2016 16:22:36 -0400 Date: Thu, 7 Apr 2016 13:22:32 -0700 From: Andi Kleen To: Mathieu Desnoyers Cc: Linus Torvalds , Peter Zijlstra , Florian Weimer , "H. Peter Anvin" , Andrew Morton , Russell King , Thomas Gleixner , Ingo Molnar , Linux Kernel Mailing List , linux-api , Paul Turner , Andrew Hunter , Andy Lutomirski , Andi Kleen , Dave Watson , Chris Lameter , Ben Maurer , rostedt , "Paul E. McKenney" , Josh Triplett , Catalin Marinas , Will Deacon , Michael Kerrisk , Boqun Feng Subject: Re: [RFC PATCH v6 1/5] Thread-local ABI system call: cache CPU number of running thread Message-ID: <20160407202232.GF9407@two.firstfloor.org> References: <1459789313-4917-1-git-send-email-mathieu.desnoyers@efficios.com> <20160405164722.GB3430@twins.programming.kicks-ass.net> <570621E5.7060306@redhat.com> <20160407103158.GP3430@twins.programming.kicks-ass.net> <570638D9.7010108@redhat.com> <20160407111938.GR3430@twins.programming.kicks-ass.net> <1025228632.49344.1460054592801.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1025228632.49344.1460054592801.JavaMail.zimbra@efficios.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > One basic use of cpu id cache is to speed up the sched_getcpu(3) > implementation in glibc. This is why I'm proposing it as a stand-alone I don't think rseq is needed for faster getcpu. User space has to be able handle stale return values anyways, as it has no way to lock itself to a cpu while it is using the return value. So it can be only a hint. The original version of getcpu just had a jiffies based cache. The CPU value was valid up to a jiffie (the next time jiffie changes), and then it gets looked up again. Processes are unlikely to switch CPUs more often than a jiffie, so it's good enough as a hint. This doesn't need any new kernel interfaces at all because jiffies is already exported to the vdso. It just needs a new entry point into the vdso that handles the jiffie check. -Andi