From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935008AbcHJSws (ORCPT ); Wed, 10 Aug 2016 14:52:48 -0400 Received: from mail.efficios.com ([78.47.125.74]:58531 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752591AbcHJSwo (ORCPT ); Wed, 10 Aug 2016 14:52:44 -0400 Date: Wed, 10 Aug 2016 13:26:04 +0000 (UTC) From: Mathieu Desnoyers To: Peter Zijlstra Cc: Andrew Morton , Russell King , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , linux-kernel , linux-api , Paul Turner , Andrew Hunter , Andy Lutomirski , Andi Kleen , Dave Watson , Chris Lameter , Ben Maurer , rostedt , "Paul E. McKenney" , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Boqun Feng Message-ID: <1431024781.7024.1470835564859.JavaMail.zimbra@efficios.com> In-Reply-To: <20160810075044.GJ6879@twins.programming.kicks-ass.net> References: <1469135662-31512-1-git-send-email-mathieu.desnoyers@efficios.com> <1469135662-31512-2-git-send-email-mathieu.desnoyers@efficios.com> <20160803131940.GM6862@twins.programming.kicks-ass.net> <656745027.6624.1470773200334.JavaMail.zimbra@efficios.com> <20160809213314.GK30192@twins.programming.kicks-ass.net> <427989454.6732.1470782507345.JavaMail.zimbra@efficios.com> <20160810075044.GJ6879@twins.programming.kicks-ass.net> Subject: Re: [RFC PATCH v7 1/7] Restartable sequences system call MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [78.47.125.74] X-Mailer: Zimbra 8.7.0_GA_1659 (ZimbraWebClient - FF45 (Linux)/8.7.0_GA_1659) Thread-Topic: Restartable sequences system call Thread-Index: ssr+ej7tm3WuYQTkhQ53bV/ycoxmbw== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Aug 10, 2016, at 3:50 AM, Peter Zijlstra peterz@infradead.org wrote: > On Tue, Aug 09, 2016 at 10:41:47PM +0000, Mathieu Desnoyers wrote: >> #ifdef __LP64__ >> >> static bool rseq_update_cpu_id_event_counter(struct task_struct *t) >> { >> union rseq_cpu_event u; >> >> u.e.cpu_id = raw_smp_processor_id(); >> u.e.event_counter = ++t->rseq_event_counter; >> if (__put_user(u.v, &t->rseq->u.v)) >> return false; >> trace_rseq_inc(t->rseq_event_counter); >> return true; >> } >> >> #else /* #ifdef __LP64__ */ >> >> static bool rseq_update_cpu_id_event_counter(struct task_struct *t) >> { >> if (__put_user(raw_smp_processor_id(), &t->rseq->u.e.cpu_id)) >> return false; >> if (__put_user(++t->rseq_event_counter, &t->rseq->u.e.event_counter)) >> return false; >> trace_rseq_inc(t->rseq_event_counter); >> return true; >> } >> >> #endif /* #else #ifdef __LP64__ */ > > I don't think you need to guard it (and CONFIG_64BIT is the 'right' > kernel symbol for that), 32bit should have u64 __put_user() only > implemented as 2 u32 stores. OK, I can then simplify the implementation to: [...] * On 64-bit architectures, both cpu_id and event_counter can be updated * with a single 64-bit store. On 32-bit architectures, __put_user() is * expected to perform two 32-bit single-copy stores to guarantee * single-copy atomicity semantics for other threads. */ static bool rseq_update_cpu_id_event_counter(struct task_struct *t) { union rseq_cpu_event u; u.e.cpu_id = raw_smp_processor_id(); u.e.event_counter = ++t->rseq_event_counter; if (__put_user(u.v, &t->rseq->u.v)) return false; trace_rseq_inc(t->rseq_event_counter); return true; } Thanks! Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com