public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Denys Vlasenko <vda.linux@googlemail.com>,
	Andy Lutomirski <luto@amacapital.net>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Alexei Starovoitov <ast@plumgrid.com>,
	Will Drewry <wad@chromium.org>, Kees Cook <keescook@chromium.org>,
	X86 ML <x86@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/4] x86: get rid of KERNEL_STACK_OFFSET
Date: Wed, 25 Feb 2015 14:53:21 +0100	[thread overview]
Message-ID: <20150225135321.GA767@gmail.com> (raw)
In-Reply-To: <54EDCD31.3000203@redhat.com>


* Denys Vlasenko <dvlasenk@redhat.com> 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

  reply	other threads:[~2015-02-25 13:53 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-24 18:51 [PATCH 1/4] x86: entry.S: tidy up several suboptimal insns Denys Vlasenko
2015-02-24 18:51 ` [PATCH 2/4] x86: get rid of KERNEL_STACK_OFFSET Denys Vlasenko
2015-02-24 19:30   ` Steven Rostedt
2015-02-24 20:02     ` Denys Vlasenko
2015-02-24 22:37   ` Andy Lutomirski
2015-02-25  9:45     ` Ingo Molnar
2015-02-25 16:14       ` Andy Lutomirski
2015-02-26 11:42         ` Ingo Molnar
2015-02-26 15:21           ` Andy Lutomirski
2015-02-26 15:29             ` Andy Lutomirski
2015-02-25  8:53   ` Ingo Molnar
2015-02-25 12:48     ` Denys Vlasenko
2015-02-25 13:25       ` Denys Vlasenko
2015-02-25 13:53         ` Ingo Molnar [this message]
2015-02-24 18:51 ` [PATCH 3/4] x86: save r11 into pt_regs->eflags on SYSCALL64 fastpath Denys Vlasenko
2015-02-24 22:44   ` Andy Lutomirski
2015-02-24 18:51 ` [PATCH 4/4] x86: save user %rsp in pt_regs->sp Denys Vlasenko
2015-02-24 22:55   ` Andy Lutomirski
2015-02-24 19:58 ` [PATCH 1/4] x86: entry.S: tidy up several suboptimal insns Borislav Petkov
2015-02-24 20:13   ` Denys Vlasenko
2015-02-24 20:36     ` Borislav Petkov
2015-02-24 22:51       ` H. Peter Anvin
2015-02-24 22:25 ` Andy Lutomirski
2015-02-24 22:52   ` H. Peter Anvin
2015-02-24 22:56     ` Andy Lutomirski
2015-02-24 23:01       ` H. Peter Anvin
2015-02-24 23:03         ` Andy Lutomirski
2015-02-24 23:26           ` Denys Vlasenko
2015-02-25  9:20     ` Ingo Molnar
2015-02-25  9:27       ` H. Peter Anvin
2015-02-25  9:39         ` Ingo Molnar
2015-02-25 14:43       ` Steven Rostedt
2015-02-25 15:40         ` Denys Vlasenko
2015-02-25 16:01           ` Steven Rostedt
2015-02-25 16:06             ` Borislav Petkov
2015-02-26 11:47             ` Ingo Molnar
2015-02-26 12:47               ` Steven Rostedt
2015-02-26 12:50               ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150225135321.GA767@gmail.com \
    --to=mingo@kernel.org \
    --cc=ast@plumgrid.com \
    --cc=bp@alien8.de \
    --cc=dvlasenk@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=oleg@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.org \
    --cc=vda.linux@googlemail.com \
    --cc=wad@chromium.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox