From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from albireo.enyo.de (albireo.enyo.de [37.24.231.21]) by sourceware.org (Postfix) with ESMTPS id 508C1387085E for ; Mon, 27 Apr 2020 09:13:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 508C1387085E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=deneb.enyo.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=fw@deneb.enyo.de Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1jSzpV-00046J-PD; Mon, 27 Apr 2020 09:13:33 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.92) (envelope-from ) id 1jSzpV-0007Nh-NC; Mon, 27 Apr 2020 11:13:33 +0200 From: Florian Weimer To: Mathieu Desnoyers via Libc-alpha Cc: Carlos O'Donell , Mathieu Desnoyers , linux-api@vger.kernel.org, Boqun Feng , Will Deacon , linux-kernel@vger.kernel.org, Peter Zijlstra , Ben Maurer , Thomas Gleixner , "Paul E. McKenney" , Paul Turner , Joseph Myers Subject: Re: [PATCH glibc 6/9] glibc: sched_getcpu(): use rseq cpu_id TLS on Linux (v7) References: <20200326155633.18236-1-mathieu.desnoyers@efficios.com> <20200326155633.18236-7-mathieu.desnoyers@efficios.com> Date: Mon, 27 Apr 2020 11:13:33 +0200 In-Reply-To: <20200326155633.18236-7-mathieu.desnoyers@efficios.com> (Mathieu Desnoyers via Libc-alpha's message of "Thu, 26 Mar 2020 11:56:30 -0400") Message-ID: <87a72xz3ya.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-21.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2020 09:13:36 -0000 * Mathieu Desnoyers via Libc-alpha: > diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c > index c019cfb3cf..2269c4f2bd 100644 > --- a/sysdeps/unix/sysv/linux/sched_getcpu.c > +++ b/sysdeps/unix/sysv/linux/sched_getcpu.c > @@ -18,10 +18,15 @@ > #include > #include > #include > +#include > #include > > -int > -sched_getcpu (void) > +#ifdef HAVE_GETCPU_VSYSCALL > +# define HAVE_VSYSCALL > +#endif > + > +static int > +vsyscall_sched_getcpu (void) > { > unsigned int cpu; > int r = -1; > @@ -32,3 +37,21 @@ sched_getcpu (void) > #endif > return r == -1 ? r : cpu; > } > + > +#include > + > +#ifdef RSEQ_SIG > +int > +sched_getcpu (void) > +{ > + int cpu_id = atomic_load_relaxed (&__rseq_abi.cpu_id); > + > + return cpu_id >= 0 ? cpu_id : vsyscall_sched_getcpu (); > +} > +#else > +int > +sched_getcpu (void) > +{ > + return vsyscall_sched_getcpu (); > +} > +#endif This patch needs to be rebased on current master, but the direction looks right to me.