From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753268AbbBYNxa (ORCPT ); Wed, 25 Feb 2015 08:53:30 -0500 Received: from mail-wg0-f49.google.com ([74.125.82.49]:44042 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753035AbbBYNx0 (ORCPT ); Wed, 25 Feb 2015 08:53:26 -0500 Date: Wed, 25 Feb 2015 14:53:21 +0100 From: Ingo Molnar To: Denys Vlasenko Cc: Denys Vlasenko , Andy Lutomirski , Linus Torvalds , Steven Rostedt , Borislav Petkov , "H. Peter Anvin" , Oleg Nesterov , Frederic Weisbecker , Alexei Starovoitov , Will Drewry , Kees Cook , X86 ML , Linux Kernel Mailing List Subject: Re: [PATCH 2/4] x86: get rid of KERNEL_STACK_OFFSET Message-ID: <20150225135321.GA767@gmail.com> References: <1424803895-4420-1-git-send-email-dvlasenk@redhat.com> <1424803895-4420-2-git-send-email-dvlasenk@redhat.com> <20150225085351.GA16165@gmail.com> <54EDCD31.3000203@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54EDCD31.3000203@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Denys Vlasenko wrote: > > The decision on how exactly we should fix > > KERNEL_STACK_OFFSET (set it to SIZEOF_PTREGS or to > > zero) depends on whether we switch to using PUSHes, or > > not. What do you think? Yes. > A data point. I implemented push-based creation of > pt_regs and benchmarked it. The patch is on top of all my > latest patches sent to ML. > > On SandyBridge CPU, it does not get slower: seems to be 1 > cycle faster per syscall. > > We lose a number of large insns there: > > text data bss dec hex filename > - 9863 0 0 9863 2687 entry_64.o > + 9671 0 0 9671 25c7 entry_64.o That's a nice reduction in I$ footprint ... > + /* Construct struct pt_regs on stack */ > + pushq $__USER_DS /* pt_regs->ss */ > + pushq PER_CPU_VAR(old_rsp) /* pt_regs->sp */ > + pushq %r11 /* pt_regs->flags */ Btw., this could also construct all the dwarf annotations in a natural, maintainable fashion - pushq_cfi and friends? > + pushq $__USER_CS /* pt_regs->cs */ > + pushq %rcx /* pt_regs->ip */ > + pushq %rax /* pt_regs->orig_ax */ > + pushq %rdi /* pt_regs->di */ > + pushq %rsi /* pt_regs->si */ > + pushq %rdx /* pt_regs->dx */ > + pushq %rcx /* pt_regs->cx */ > + pushq $-ENOSYS /* pt_regs->ax */ > + pushq %r8 /* pt_regs->r8 */ > + pushq %r9 /* pt_regs->r9 */ > + pushq %r10 /* pt_regs->r10 */ > + sub $(7*8),%rsp /* pt_regs->r11,bp,bx,r12-15 */ So the 'SUB' there is a bit sad, but push sequences are generally easier to read, so I like it altogether. Then we could indeed get rid of KERNEL_STACK_OFFSET. Thanks, Ingo