mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	X86 ML <x86@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Jan Kara <jack@suse.cz>, Borislav Petkov <bp@alien8.de>,
	Denys Vlasenko <dvlasenk@redhat.com>
Subject: Re: [PATCH] x86: Fix detection of GCC -mpreferred-stack-boundary support
Date: Mon, 6 Jul 2015 19:40:11 +0200	[thread overview]
Message-ID: <20150706174011.GB30566@gmail.com> (raw)
In-Reply-To: <CALCETrWjga6ZrLtashynocaVbjK3HX5e6=3UCPq3=9yhn_2ZQQ@mail.gmail.com>


* Andy Lutomirski <luto@amacapital.net> wrote:

> > My reasoning: on modern uarchs there's no penalty for 32-bit misalignment of 
> > 64-bit variables, only if they cross 64-byte cache lines, which should be rare 
> > with a chance of 1:16. This small penalty (of at most +1 cycle in some 
> > circumstances IIRC) should be more than counterbalanced by the compression of 
> > the stack by 5% on average.
> 
> I'll counter with: what's the benefit?  There are no operations that will 
> naturally change RSP by anything that isn't a multiple of 8 (there's no pushl in 
> 64-bit mode, or at least not on AMD chips -- the Intel manual is a bit vague on 
> this point), so we'll end up with RSP being a multiple of 8 regardless.  Even if 
> we somehow shaved 4 bytes off in asm, that still wouldn't buy us anything, as a 
> dangling 4 bytes at the bottom of the stack isn't useful for anything.

Yeah, so it might be utilized in frame-pointer less builds (which we might be able 
to utilize in the future if sane Dwarf code comes around), which does not use 
push/pop to manage the stack but often has patterns like:

ffffffff8102aa90 <SyS_getpriority>:
ffffffff8102aa90:       48 83 ec 18             sub    $0x18,%rsp

and uses MOVs to manage the stack. Those kinds of stack frames could be 4-byte 
granular as well.

But yeah ... it's pretty marginal.

Thanks,

	Ingo

  reply	other threads:[~2015-07-06 17:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-05 20:08 Andy Lutomirski
2015-07-06 13:44 ` Ingo Molnar
2015-07-06 16:59   ` Andy Lutomirski
2015-07-06 17:40     ` Ingo Molnar [this message]
2015-07-06 17:59       ` Andy Lutomirski
2015-07-07  4:01         ` Raymond Jennings
2015-07-06 17:10   ` Linus Torvalds
2015-07-06 17:32     ` Ingo Molnar

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=20150706174011.GB30566@gmail.com \
    --to=mingo@kernel.org \
    --cc=bp@alien8.de \
    --cc=dvlasenk@redhat.com \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=torvalds@linux-foundation.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

Powered by JetHome