From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ingo Molnar Subject: Re: [PATCH v5 14/32] x86/mm/64: Enable vmapped stacks Date: Thu, 14 Jul 2016 10:34:11 +0200 Message-ID: <20160714083411.GA15437@gmail.com> References: <8d36dd9b2430b61db64333af7b911d0bca7d5d2f.1468270393.git.luto@kernel.org> <20160713075314.GA32700@gmail.com> Reply-To: kernel-hardening@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Return-path: List-Post: List-Help: List-Unsubscribe: List-Subscribe: Sender: Ingo Molnar Content-Disposition: inline In-Reply-To: To: Andy Lutomirski Cc: Andy Lutomirski , X86 ML , "linux-kernel@vger.kernel.org" , linux-arch , Borislav Petkov , Nadav Amit , Kees Cook , Brian Gerst , "kernel-hardening@lists.openwall.com" , Linus Torvalds , Josh Poimboeuf , Jann Horn , Heiko Carstens List-Id: linux-arch.vger.kernel.org * Andy Lutomirski wrote: > On Wed, Jul 13, 2016 at 12:53 AM, Ingo Molnar wrote: > > > > * Andy Lutomirski wrote: > > > >> This allows x86_64 kernels to enable vmapped stacks. There are a > >> couple of interesting bits. > > > >> --- a/arch/x86/Kconfig > >> +++ b/arch/x86/Kconfig > >> @@ -92,6 +92,7 @@ config X86 > >> select HAVE_ARCH_TRACEHOOK > >> select HAVE_ARCH_TRANSPARENT_HUGEPAGE > >> select HAVE_EBPF_JIT if X86_64 > >> + select HAVE_ARCH_VMAP_STACK if X86_64 > > > > So what is the performance impact? > > Seems to be a very slight speedup (0.5 µs or so) on my silly benchmark > (pthread_create, pthread_join in a loop). [...] Music to my ears - although TBH there's probably two opposing forces: advantages from the cache versus (possibly very minor, if measurable at all) disadvantages from the 4K granularity. > [...] It should be a small slowdown on workloads that create many threads all > at once, thus defeating the stack cache. It should be a *large* speedup on any > workload that would trigger compaction on clone() to satisfy the high-order > allocation. > > > > > Because I think we should consider enabling this feature by default on x86 - but > > the way it's selected here it will be default-off. > > > > On the plus side: the debuggability and reliability improvements are real and > > making it harder for exploits to use kernel stack overflows is a nice bonus as > > well. There's two performance effects: > > Agreed. At the very least, I want to wait until after net-next gets > pulled to flip the default to y. I'm also a bit concerned about more > random driver issues that I haven't found yet. I suppose we could > flip the default to y for a few -rc releases and see what, if > anything, shakes loose. So I'd prefer the following approach: to apply it to a v4.8-rc1 base in ~2 weeks and keep it default-y for much of the next development cycle. If no serious problems are found in those ~2 months then send it to Linus in that fashion. We can still turn it off by default (or re-spin the whole approach) if it turns out to be too risky. Exposing it as default-n for even a small amount of time will massively reduce the testing we'll get, as most people will just use the N setting (often without noticing). Plus this also gives net-next and other preparatory patches applied directly to maintainer trees time to trickle upstream. Thanks, Ingo From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f53.google.com ([74.125.82.53]:36472 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751251AbcGNIeR (ORCPT ); Thu, 14 Jul 2016 04:34:17 -0400 Date: Thu, 14 Jul 2016 10:34:11 +0200 From: Ingo Molnar Subject: Re: [PATCH v5 14/32] x86/mm/64: Enable vmapped stacks Message-ID: <20160714083411.GA15437@gmail.com> References: <8d36dd9b2430b61db64333af7b911d0bca7d5d2f.1468270393.git.luto@kernel.org> <20160713075314.GA32700@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-arch-owner@vger.kernel.org List-ID: To: Andy Lutomirski Cc: Andy Lutomirski , X86 ML , "linux-kernel@vger.kernel.org" , linux-arch , Borislav Petkov , Nadav Amit , Kees Cook , Brian Gerst , "kernel-hardening@lists.openwall.com" , Linus Torvalds , Josh Poimboeuf , Jann Horn , Heiko Carstens Message-ID: <20160714083411.ZNY8WDrE13VPsuPHhM7h6Ggb3zDliWS4ZkaoIdU-AlM@z> * Andy Lutomirski wrote: > On Wed, Jul 13, 2016 at 12:53 AM, Ingo Molnar wrote: > > > > * Andy Lutomirski wrote: > > > >> This allows x86_64 kernels to enable vmapped stacks. There are a > >> couple of interesting bits. > > > >> --- a/arch/x86/Kconfig > >> +++ b/arch/x86/Kconfig > >> @@ -92,6 +92,7 @@ config X86 > >> select HAVE_ARCH_TRACEHOOK > >> select HAVE_ARCH_TRANSPARENT_HUGEPAGE > >> select HAVE_EBPF_JIT if X86_64 > >> + select HAVE_ARCH_VMAP_STACK if X86_64 > > > > So what is the performance impact? > > Seems to be a very slight speedup (0.5 µs or so) on my silly benchmark > (pthread_create, pthread_join in a loop). [...] Music to my ears - although TBH there's probably two opposing forces: advantages from the cache versus (possibly very minor, if measurable at all) disadvantages from the 4K granularity. > [...] It should be a small slowdown on workloads that create many threads all > at once, thus defeating the stack cache. It should be a *large* speedup on any > workload that would trigger compaction on clone() to satisfy the high-order > allocation. > > > > > Because I think we should consider enabling this feature by default on x86 - but > > the way it's selected here it will be default-off. > > > > On the plus side: the debuggability and reliability improvements are real and > > making it harder for exploits to use kernel stack overflows is a nice bonus as > > well. There's two performance effects: > > Agreed. At the very least, I want to wait until after net-next gets > pulled to flip the default to y. I'm also a bit concerned about more > random driver issues that I haven't found yet. I suppose we could > flip the default to y for a few -rc releases and see what, if > anything, shakes loose. So I'd prefer the following approach: to apply it to a v4.8-rc1 base in ~2 weeks and keep it default-y for much of the next development cycle. If no serious problems are found in those ~2 months then send it to Linus in that fashion. We can still turn it off by default (or re-spin the whole approach) if it turns out to be too risky. Exposing it as default-n for even a small amount of time will massively reduce the testing we'll get, as most people will just use the N setting (often without noticing). Plus this also gives net-next and other preparatory patches applied directly to maintainer trees time to trickle upstream. Thanks, Ingo