Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161024AbcLPSfG (ORCPT ); Fri, 16 Dec 2016 13:35:06 -0500 Received: from mail-ua0-f169.google.com ([209.85.217.169]:33963 "EHLO mail-ua0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933661AbcLPSe4 (ORCPT ); Fri, 16 Dec 2016 13:34:56 -0500 MIME-Version: 1.0 In-Reply-To: References: <20161215162648.061449202@linutronix.de> <20161215164240.904945084@linutronix.de> From: Andy Lutomirski Date: Fri, 16 Dec 2016 10:34:32 -0800 Message-ID: Subject: Re: [patch 3/3] x86/process: Optimize TIF_NOTSC switch To: Thomas Gleixner Cc: LKML , X86 ML , Peter Zijlstra , Kyle Huey , Andy Lutomirski Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 765 Lines: 21 On Fri, Dec 16, 2016 at 12:50 AM, Thomas Gleixner wrote: > On Thu, 15 Dec 2016, Andy Lutomirski wrote: >> On Thu, Dec 15, 2016 at 8:44 AM, Thomas Gleixner wrote: >> > +static inline void cr4_toggle_bits(unsigned long mask) >> > +{ >> > + unsigned long cr4; >> > + >> > + cr4 = this_cpu_read(cpu_tlbstate.cr4); >> > + cr4 ^= mask; >> > + this_cpu_write(cpu_tlbstate.cr4, cr4); >> > + __write_cr4(cr4); >> > +} >> >> This scares me for the same reason as BTF, although this should at >> least be less fragile. But how about: > > If that is fragile then all cr4 manipulation code is fragile because it > relies on cpu_tlbstate.cr4. The TIF flag and that per cpu thing are kept in > sync. True.