From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
"H. Peter Anvin" <hpa@zytor.com>, Jason Baron <jbaron@redhat.com>,
"H. Peter Anvin" <hpa@linux.intel.com>
Subject: [PATCH 1/7] x86/jump-label: Use best default nops for inital jump label calls
Date: Thu, 08 Mar 2012 17:17:31 -0500 [thread overview]
Message-ID: <20120308222201.165735678@goodmis.org> (raw)
In-Reply-To: 20120308221730.807074710@goodmis.org
[-- Attachment #1: Type: text/plain, Size: 1611 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
As specified by H. Peter Anvin, the best nops for x86 without knowing
the running computer is:
32bit:
0x3e, 0x8d, 0x74, 0x26, 0x00 also known as GENERIC_NOP5_ATOMIC
64bit:
0x0f, 0x1f, 0x44, 0x00, 0x00 also known as P6_NOP5_ATOMIC
Currently the default nop that is used by jump label is:
0xe9 0x00 0x00 0x00 0x00
Which is really a 5byte jump to the next position.
It's better to use a real nop than a jmp.
Cc: H. Peter Anvin <hpa@linux.intel.com>
Cc: Jason Baron <jbaron@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
arch/x86/include/asm/jump_label.h | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h
index 3a16c14..64507f3 100644
--- a/arch/x86/include/asm/jump_label.h
+++ b/arch/x86/include/asm/jump_label.h
@@ -3,18 +3,23 @@
#ifdef __KERNEL__
+#include <linux/stringify.h>
#include <linux/types.h>
#include <asm/nops.h>
#include <asm/asm.h>
#define JUMP_LABEL_NOP_SIZE 5
-#define STATIC_KEY_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t"
+#ifdef CONFIG_X86_64
+# define STATIC_KEY_INIT_NOP P6_NOP5_ATOMIC
+#else
+# define STATIC_KEY_INIT_NOP GENERIC_NOP5_ATOMIC
+#endif
static __always_inline bool arch_static_branch(struct static_key *key)
{
asm goto("1:"
- STATIC_KEY_INITIAL_NOP
+ ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t"
".pushsection __jump_table, \"aw\" \n\t"
_ASM_ALIGN "\n\t"
_ASM_PTR "1b, %l[l_yes], %c0 \n\t"
--
1.7.8.3
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-03-08 22:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-08 22:17 [PATCH 0/7] [GIT PULL] jump-labels: Implement 2 and 5 byte jumps Steven Rostedt
2012-03-08 22:17 ` Steven Rostedt [this message]
2012-03-08 22:17 ` [PATCH 2/7] x86/jump-label: Do not bother updating nops if they are correct Steven Rostedt
2012-03-08 22:17 ` [PATCH 3/7] x86/jump-label: Add safety checks to jump label conversions Steven Rostedt
2012-03-08 22:17 ` [PATCH 4/7] jump labels: Add infrastructure to update jump labels at compile time Steven Rostedt
2012-03-08 22:17 ` [PATCH 5/7] x86/jump labels: Use etiher 5 byte or 2 byte jumps Steven Rostedt
2012-03-12 16:17 ` Jason Baron
2012-03-12 16:29 ` Steven Rostedt
2012-03-12 17:27 ` Steven Rostedt
2012-03-12 18:03 ` Jason Baron
2012-03-08 22:17 ` [PATCH 6/7] x86/jump lables: Show where and what was wrong on errors Steven Rostedt
2012-03-08 22:17 ` [PATCH 7/7] x86/jump labels: Handle initialization of enabled nops 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=20120308222201.165735678@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=hpa@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jbaron@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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