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 ; 20 Feb 2019 16:21:34 -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 1gwUcn-0008TH-0e for speck@linutronix.de; Wed, 20 Feb 2019 17:21:33 +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 1gwUcl-0001hZ-BJ for speck@linutronix.de; Wed, 20 Feb 2019 16:21:31 +0000 Date: Wed, 20 Feb 2019 17:21:28 +0100 From: Peter Zijlstra Subject: [MODERATED] Re: [patch V2 09/10] MDS basics+ 9 Message-ID: <20190220162128.GW32477@hirez.programming.kicks-ass.net> References: <20190220150753.665964899@linutronix.de> <20190220151400.787843957@linutronix.de> MIME-Version: 1.0 In-Reply-To: <20190220151400.787843957@linutronix.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Wed, Feb 20, 2019 at 04:08:02PM +0100, speck for Thomas Gleixner wrote: > static inline void mds_user_clear_cpu_buffers(void) > { > + if (static_branch_likely(&mds_user_clear_cond)) { Are we sure we want _likely() ? That puts the body in-line. > + if (__this_cpu_read(mds_cond_clear)) { > + __this_cpu_write(mds_cond_clear, 0); > + mds_clear_cpu_buffers(); > + } return; _might_ generate better code; by making it explitit we'll never have both branches enabled at the same time. > + } > if (static_branch_likely(&mds_user_clear_always)) > mds_clear_cpu_buffers(); > } And in general; yuck! Should I once again look at tri-state jump_labels or static_switch? Last time I tried I got stuck on the C part, writing different targets is trivial. Ideally we'd end up with something like: 1: jmp 3f test $1, %gs:mds_cond_clear jz 3f mov $0, %gs:mds_cond_clear 2: verw ds 3: And change the jmp at 1 between: JMP 3f, JMP 2f and NOP for mds={off,full,cond} resp.