From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751356AbdBLTiC (ORCPT ); Sun, 12 Feb 2017 14:38:02 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:36721 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750999AbdBLTiB (ORCPT ); Sun, 12 Feb 2017 14:38:01 -0500 Date: Sun, 12 Feb 2017 20:37:57 +0100 (CET) From: Thomas Gleixner To: Dave Hansen cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, kirill.shutemov@linux.intel.com Subject: Re: [RFC][PATCH 4/7] x86, mpx: context-switch new MPX address size MSR In-Reply-To: <20170201232413.15540F7E@viggo.jf.intel.com> Message-ID: References: <20170201232408.FA486473@viggo.jf.intel.com> <20170201232413.15540F7E@viggo.jf.intel.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 Feb 2017, Dave Hansen wrote: > +/* > + * The MPX tables change sizes based on the size of the virtual > + * (aka. linear) address space. There is an MSR to tell the CPU > + * whether we want the legacy-style ones or the larger ones when > + * we are running with an eXtended virtual address space. > + */ > +static inline void switch_mpx_bd(struct mm_struct *prev, struct mm_struct *next) > +{ > + /* > + * Note: there is one and only one bit in use in the MSR > + * at this time, so we do not have to be concerned with > + * preserving any of the other bits. Just write 0 or 1. > + */ > + u32 IA32_MPX_LAX_ENABLE_MASK = 0x00000001; > + > + /* > + * Avoid the MSR on CPUs without MPX, obviously: > + */ > + if (!cpu_feature_enabled(X86_FEATURE_MPX)) > + return; > + /* > + * FIXME: do we want a check here for the 5-level paging > + * CR4 bit or CPUID bit, or is the mawa check below OK? > + * It's not obvious what would be the fastest or if it > + * matters. > + */ Well, you could use a static key which is enabled when 5 level paging and MPX is enabled. > + /* > + * Avoid the relatively costly MSR if we are not changing > + * MAWA state. All processes not using MPX will have a > + * mpx_mawa_shift()=0, so we do not need to check > + * separately for whether MPX management is enabled. > + */ > + if (likely(mpx_bd_size_shift(prev) == mpx_bd_size_shift(next))) > + return; So this switches back unconditionally if the previous task was using the large tables even if the next task is not using MPX at all. It's probably a non issue. Thanks, tglx