public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot for H.J. Lu" <hjl.tools@gmail.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
	tglx@linutronix.de, hjl.tools@gmail.com
Subject: [tip:x86/build] x86-64, gcc: Use -mpreferred-stack-boundary= 3 if supported
Date: Sat, 23 Jun 2012 20:13:07 -0700	[thread overview]
Message-ID: <tip-d9b0cde91c60da0ed5f92cdc3ac878142e6b5f27@git.kernel.org> (raw)
In-Reply-To: <CAMe9rOqPfy3JcZRLaUeCjBe9BVY-P6e0uaSbMi5hvS-6WwQueg@mail.gmail.com>

Commit-ID:  d9b0cde91c60da0ed5f92cdc3ac878142e6b5f27
Gitweb:     http://git.kernel.org/tip/d9b0cde91c60da0ed5f92cdc3ac878142e6b5f27
Author:     H.J. Lu <hjl.tools@gmail.com>
AuthorDate: Tue, 29 May 2012 14:31:23 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Sat, 23 Jun 2012 19:25:22 -0700

x86-64, gcc: Use -mpreferred-stack-boundary=3 if supported

On x86-64, the standard ABI requires alignment to 16 bytes.  However,
this is not actually necessary in the kernel (we don't do SSE except
in very controlled ways); and furthermore, the standard kernel entry
on x86-64 actually leaves the stack on an odd 8-byte boundary, which
means that gcc will generate extra instructions to keep the stack
*mis*aligned!

gcc 4.8 adds an -mpreferred-stack-boundary=3 option to override this
and lets us save some stack space and a handful of instructions.

Note that this causes us to pass -mno-sse twice; this is redundant,
but necessary since the cc-option test will fail unless -mno-sse is
passed on the same command line.

[ hpa: rewrote the patch description ]

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Link: http://lkml.kernel.org/r/CAMe9rOqPfy3JcZRLaUeCjBe9BVY-P6e0uaSbMi5hvS-6WwQueg@mail.gmail.com
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
 arch/x86/Makefile |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 1f25214..b0c5276 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -49,6 +49,9 @@ else
         KBUILD_AFLAGS += -m64
         KBUILD_CFLAGS += -m64
 
+	# Use -mpreferred-stack-boundary=3 if supported.
+	KBUILD_CFLAGS += $(call cc-option,-mno-sse -mpreferred-stack-boundary=3)
+
         # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
         cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
         cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)

      parent reply	other threads:[~2012-06-24  3:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-23 16:06 PATCH] Use -mpreferred-stack-boundary=3 on x86-64 if supported H.J. Lu
2012-06-23 16:13 ` Andi Kleen
2012-06-23 16:17   ` H. Peter Anvin
2012-06-23 16:49     ` H.J. Lu
2012-06-23 22:57       ` Randy Dunlap
2012-06-23 19:27     ` Andi Kleen
2012-06-23 19:45       ` H. Peter Anvin
2012-06-24  3:13 ` tip-bot for H.J. Lu [this message]

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=tip-d9b0cde91c60da0ed5f92cdc3ac878142e6b5f27@git.kernel.org \
    --to=hjl.tools@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /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