Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1165532

Re: [PATCH 4/5] x86/asm/entry/32: Replace RESTORE_RSI_RDI[_RDX] with open-coded 32-bit reads

Path csiph.com!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod
From Ingo Molnar <mingo@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH 4/5] x86/asm/entry/32: Replace RESTORE_RSI_RDI[_RDX] with open-coded 32-bit reads
Date Mon, 15 Jun 2015 22:30:02 +0200
Message-ID <pBJb4-5IV-3@gated-at.bofh.it> (permalink)
References <pzwUG-6VC-17@gated-at.bofh.it> <pzwUG-6VC-15@gated-at.bofh.it> <pBbM5-72v-1@gated-at.bofh.it> <pBi1c-8lo-21@gated-at.bofh.it>
X-Original-To Denys Vlasenko <dvlasenk@redhat.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=0TFCHIMAFcxsETLKa30DXvzGpN9a3DkpcjoUsAe9Wk0=; b=j0jcPQM0i8g0Vof36+5Y6rW49c5VVMl9RcOIUMVOOXd+4jd+onSbLAd103o10cANXB JkK3GJn/OaJBVefhyleF9VQq8UXIzcHT6eOllXydUYGZDNnyDYxkzZl9gGNYofw/FJjK tPXJ5vUyyNM81dpm5V/1hMrNYGshS5zmhhgg2JBLam1IWv0m6kcaFguifHEycpniGOa5 dcuD2rU6x5whqLOznGNxler/4bE55RaTl2lEXXMlVXXi/7NM6wvKPPvzBKXSHl5K83VN cwN6No+l6mO4tMIqFELCkJuYLRlTgqrMPasGgNGfdYYeQFAF4BxL2n3jPjzgVo5sKF5S Hzjg==
X-Received by 10.194.193.42 with SMTP id hl10mr44454231wjc.144.1434399612515; Mon, 15 Jun 2015 13:20:12 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.5.23 (2014-03-12)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 61
Organization linux.* mail to news gateway
X-Original-Cc Linus Torvalds <torvalds@linux-foundation.org>, Steven Rostedt <rostedt@goodmis.org>, Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>, Andy Lutomirski <luto@amacapital.net>, 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@kernel.org, linux-kernel@vger.kernel.org
X-Original-Date Mon, 15 Jun 2015 22:20:08 +0200
X-Original-Message-ID <20150615202008.GA12450@gmail.com>
X-Original-References <1433876051-26604-1-git-send-email-dvlasenk@redhat.com> <1433876051-26604-4-git-send-email-dvlasenk@redhat.com> <20150614084059.GA24562@gmail.com> <557D9BEE.8010902@redhat.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref aioe.org linux.kernel:1165532

Show key headers only | View raw


* Denys Vlasenko <dvlasenk@redhat.com> wrote:

> On 06/14/2015 10:40 AM, Ingo Molnar wrote:
> > 
> > * Denys Vlasenko <dvlasenk@redhat.com> wrote:
> > 
> >> 	+8b 74 24 68            mov    0x68(%rsp),%esi
> >> 	+8b 7c 24 70            mov    0x70(%rsp),%edi
> >> 	+8b 54 24 60            mov    0x60(%rsp),%edx
> > 
> > Btw., could you (in another patch) order the restoration properly, by pt_regs 
> > memory order, where possible?
> 
> Will do.
> 
> > So this:
> > 
> >> +	movl	RSI(%rsp), %esi
> >> +	movl	RDI(%rsp), %edi
> >> +	movl	RDX(%rsp), %edx
> >>  	movl	RIP(%rsp), %ecx
> >>  	movl	EFLAGS(%rsp), %r11d
> > 
> > would become:
> > 
> > 	movl	RDX(%rsp), %edx
> > 	movl	RSI(%rsp), %esi
> > 	movl	RDI(%rsp), %edi
> > 	movl	RIP(%rsp), %ecx
> >  	movl	EFLAGS(%rsp), %r11d
> > 
> > ... or so.
> 
> Actually, ecx and r11 need to be loaded first. They are not so much "restored" 
> as "prepared for SYSRET insn". Every cycle lost in loading these delays SYSRET. 
> [...]

So in the typical case they will still be cached, and so their max latency should 
be around 3 cycles.

In fact because they are memory loads, they don't really have dependencies, so 
they should be available to SYSRET almost immediately, i.e. within a cycle - and 
there's no reason to believe why these loads wouldn't pipeline properly and 
parallelize with the many other things SYSRET has to do to organize a return to 
user-space, before it can actually use the target RIP and RFLAGS.

So I strongly doubt that the placement of the RCX and R11 load before the SYSRET 
matters to performance.

In any case this should be testable by looking at syscall performance and 
reordering the instructions.

Thanks,

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 4/5] x86/asm/entry/32: Replace RESTORE_RSI_RDI[_RDX] with  open-coded 32-bit reads Ingo Molnar <mingo@kernel.org> - 2015-06-15 22:30 +0200
  Re: [PATCH 4/5] x86/asm/entry/32: Replace RESTORE_RSI_RDI[_RDX] with  open-coded 32-bit reads Denys Vlasenko <dvlasenk@redhat.com> - 2015-06-16 02:30 +0200

csiph-web