From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 09 Feb 2019 08:57:48 -0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1gsOSJ-0000Nm-8g for speck@linutronix.de; Sat, 09 Feb 2019 09:57:47 +0100 Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gsOSH-0000CQ-3V for speck@linutronix.de; Sat, 09 Feb 2019 08:57:45 +0000 Date: Sat, 9 Feb 2019 09:57:42 +0100 From: Peter Zijlstra Subject: [MODERATED] Re: [RFC][PATCH] performance walnuts Message-ID: <20190209085742.GQ32511@hirez.programming.kicks-ass.net> References: <3dd5d6e2bc9ac53f826c251c68ce84fcc79a6872.1549582769.git.ak@linux.intel.com> <20190208090147.GK32477@hirez.programming.kicks-ass.net> <20190208093950.GD32534@hirez.programming.kicks-ass.net> <20190208105318.GE32534@hirez.programming.kicks-ass.net> MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Fri, Feb 08, 2019 at 04:28:41PM -0800, speck for Linus Torvalds wrote: > On Fri, Feb 8, 2019 at 2:53 AM speck for Peter Zijlstra > wrote: > > > > +static void intel_set_tfa(struct cpu_hw_events *cpuc, bool on) > > +{ > > + u64 val = MSR_TFA_RTM_FORCE_ABORT * on; > > Have you actually verified that this does the right thing on all > versions of gcc? > > In particular, I certainly hope it doesn't cause an actual multiply instruction. > > It might be better to just write it as > > u64 val = on ? MSR_TFA_RTM_FORCE_ABORT : 0; > > because that's what we'd hope the code generation is anyway. Instead > of just assuming gcc DTRT. I did not verify in this instance; but I did look at code generation for b987ffc18fb3 ("x86/qspinlock: Fix compile error") where we do a similar mult-by-bool to avoid if() and GCC got it right there. That said; I don't suppose there's anything wrong with using the ternary operator here, but in general I try to avoid it.