* [PATCH] x86: generate labels at the beginning of unlikely sub-sections
@ 2015-12-11 13:42 Jan Beulich
2015-12-11 16:55 ` Andrew Cooper
2015-12-11 18:52 ` [PATCH v2] xen/x86: Use tag in C UNLIKELY blocks, rather than a literal ".tag" Andrew Cooper
0 siblings, 2 replies; 3+ messages in thread
From: Jan Beulich @ 2015-12-11 13:42 UTC (permalink / raw)
To: xen-devel; +Cc: Andrew Cooper, Keir Fraser
[-- Attachment #1: Type: text/plain, Size: 3683 bytes --]
This is to limit symbol table growth, which would be quite a bit worse
if we went with the "label every unlikely sub-section contribution"
approach proposed previously.
Older gas doesn't support quoted symbols, yet the result looks quite
bit better that way. Hence two variants get introduced, one using
proper path names (including slashes and dashes) and one using path
names after converting them to valid symbol names (slashes and dashes
replaced).
As a secondary adjustment also change the section name used with Clang.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/Rules.mk
+++ b/xen/arch/x86/Rules.mk
@@ -20,6 +20,7 @@ xenoprof := y
CFLAGS += -I$(BASEDIR)/include
CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-generic
CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-default
+CFLAGS += '-D__OBJECT_LABEL__=$(subst /,$$,$(subst -,_,$(subst $(BASEDIR)/,,$(CURDIR))/$@))'
# Prevent floating-point variables from creeping into Xen.
CFLAGS += -msoft-float
@@ -29,6 +30,9 @@ $(call cc-option-add,CFLAGS,CC,-Wnested-
$(call as-insn-check,CFLAGS,CC,"vmcall",-DHAVE_GAS_VMX)
$(call as-insn-check,CFLAGS,CC,"invept (%rax)$$(comma)%rax",-DHAVE_GAS_EPT)
$(call as-insn-check,CFLAGS,CC,"rdfsbase %rax",-DHAVE_GAS_FSGSBASE)
+$(call as-insn-check,CFLAGS,CC,".equ \"x\"$$(comma)1", \
+ -U__OBJECT_LABEL__ -DHAVE_GAS_QUOTED_SYM \
+ '-D__OBJECT_LABEL__=$(subst $(BASEDIR)/,,$(CURDIR))/$$@')
x86 := y
x86_32 := n
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -93,10 +93,24 @@ void ret_from_intr(void);
#ifdef __ASSEMBLY__
+#ifdef HAVE_GAS_QUOTED_SYM
+#define SUBSECTION_LBL(tag) \
+ .ifndef .L.tag; \
+ .equ .L.tag, 1; \
+ .equ __stringify(__OBJECT_LABEL__.tag), .; \
+ .endif
+#else
+#define SUBSECTION_LBL(tag) \
+ .ifndef __OBJECT_LABEL__.tag; \
+ __OBJECT_LABEL__.tag:; \
+ .endif
+#endif
+
#define UNLIKELY_START(cond, tag) \
.Ldispatch.tag: \
j##cond .Lunlikely.tag; \
.subsection 1; \
+ SUBSECTION_LBL(unlikely); \
.Lunlikely.tag:
#define UNLIKELY_DISPATCH_LABEL(tag) \
@@ -141,9 +155,22 @@ void ret_from_intr(void);
#else
+#ifdef HAVE_GAS_QUOTED_SYM
+#define SUBSECTION_LBL(tag) \
+ ".ifndef .L." #tag "\n\t" \
+ ".equ .L." #tag ", 1\n\t" \
+ ".equ \"" __stringify(__OBJECT_LABEL__) "." #tag "\", .\n\t" \
+ ".endif"
+#else
+#define SUBSECTION_LBL(tag) \
+ ".ifndef " __stringify(__OBJECT_LABEL__) "." #tag "\n\t" \
+ __stringify(__OBJECT_LABEL__) "." #tag ":\n\t" \
+ ".endif"
+#endif
+
#ifdef __clang__ /* clang's builtin assember can't do .subsection */
-#define UNLIKELY_START_SECTION ".pushsection .fixup,\"ax\""
+#define UNLIKELY_START_SECTION ".pushsection .text.unlikely,\"ax\""
#define UNLIKELY_END_SECTION ".popsection"
#else
@@ -155,7 +182,8 @@ void ret_from_intr(void);
#define UNLIKELY_START(cond, tag) \
"j" #cond " .Lunlikely%=.tag;\n\t" \
- UNLIKELY_START_SECTION "\n" \
+ UNLIKELY_START_SECTION "\n\t" \
+ SUBSECTION_LBL(unlikely) "\n" \
".Lunlikely%=.tag:"
#define UNLIKELY_END(tag) \
[-- Attachment #2: x86-label-subsections.patch --]
[-- Type: text/plain, Size: 3743 bytes --]
x86: generate labels at the beginning of unlikely sub-sections
This is to limit symbol table growth, which would be quite a bit worse
if we went with the "label every unlikely sub-section contribution"
approach proposed previously.
Older gas doesn't support quoted symbols, yet the result looks quite
bit better that way. Hence two variants get introduced, one using
proper path names (including slashes and dashes) and one using path
names after converting them to valid symbol names (slashes and dashes
replaced).
As a secondary adjustment also change the section name used with Clang.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/Rules.mk
+++ b/xen/arch/x86/Rules.mk
@@ -20,6 +20,7 @@ xenoprof := y
CFLAGS += -I$(BASEDIR)/include
CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-generic
CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-default
+CFLAGS += '-D__OBJECT_LABEL__=$(subst /,$$,$(subst -,_,$(subst $(BASEDIR)/,,$(CURDIR))/$@))'
# Prevent floating-point variables from creeping into Xen.
CFLAGS += -msoft-float
@@ -29,6 +30,9 @@ $(call cc-option-add,CFLAGS,CC,-Wnested-
$(call as-insn-check,CFLAGS,CC,"vmcall",-DHAVE_GAS_VMX)
$(call as-insn-check,CFLAGS,CC,"invept (%rax)$$(comma)%rax",-DHAVE_GAS_EPT)
$(call as-insn-check,CFLAGS,CC,"rdfsbase %rax",-DHAVE_GAS_FSGSBASE)
+$(call as-insn-check,CFLAGS,CC,".equ \"x\"$$(comma)1", \
+ -U__OBJECT_LABEL__ -DHAVE_GAS_QUOTED_SYM \
+ '-D__OBJECT_LABEL__=$(subst $(BASEDIR)/,,$(CURDIR))/$$@')
x86 := y
x86_32 := n
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -93,10 +93,24 @@ void ret_from_intr(void);
#ifdef __ASSEMBLY__
+#ifdef HAVE_GAS_QUOTED_SYM
+#define SUBSECTION_LBL(tag) \
+ .ifndef .L.tag; \
+ .equ .L.tag, 1; \
+ .equ __stringify(__OBJECT_LABEL__.tag), .; \
+ .endif
+#else
+#define SUBSECTION_LBL(tag) \
+ .ifndef __OBJECT_LABEL__.tag; \
+ __OBJECT_LABEL__.tag:; \
+ .endif
+#endif
+
#define UNLIKELY_START(cond, tag) \
.Ldispatch.tag: \
j##cond .Lunlikely.tag; \
.subsection 1; \
+ SUBSECTION_LBL(unlikely); \
.Lunlikely.tag:
#define UNLIKELY_DISPATCH_LABEL(tag) \
@@ -141,9 +155,22 @@ void ret_from_intr(void);
#else
+#ifdef HAVE_GAS_QUOTED_SYM
+#define SUBSECTION_LBL(tag) \
+ ".ifndef .L." #tag "\n\t" \
+ ".equ .L." #tag ", 1\n\t" \
+ ".equ \"" __stringify(__OBJECT_LABEL__) "." #tag "\", .\n\t" \
+ ".endif"
+#else
+#define SUBSECTION_LBL(tag) \
+ ".ifndef " __stringify(__OBJECT_LABEL__) "." #tag "\n\t" \
+ __stringify(__OBJECT_LABEL__) "." #tag ":\n\t" \
+ ".endif"
+#endif
+
#ifdef __clang__ /* clang's builtin assember can't do .subsection */
-#define UNLIKELY_START_SECTION ".pushsection .fixup,\"ax\""
+#define UNLIKELY_START_SECTION ".pushsection .text.unlikely,\"ax\""
#define UNLIKELY_END_SECTION ".popsection"
#else
@@ -155,7 +182,8 @@ void ret_from_intr(void);
#define UNLIKELY_START(cond, tag) \
"j" #cond " .Lunlikely%=.tag;\n\t" \
- UNLIKELY_START_SECTION "\n" \
+ UNLIKELY_START_SECTION "\n\t" \
+ SUBSECTION_LBL(unlikely) "\n" \
".Lunlikely%=.tag:"
#define UNLIKELY_END(tag) \
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] x86: generate labels at the beginning of unlikely sub-sections
2015-12-11 13:42 [PATCH] x86: generate labels at the beginning of unlikely sub-sections Jan Beulich
@ 2015-12-11 16:55 ` Andrew Cooper
2015-12-11 18:52 ` [PATCH v2] xen/x86: Use tag in C UNLIKELY blocks, rather than a literal ".tag" Andrew Cooper
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2015-12-11 16:55 UTC (permalink / raw)
To: Jan Beulich, xen-devel; +Cc: Keir Fraser
On 11/12/15 13:42, Jan Beulich wrote:
> This is to limit symbol table growth, which would be quite a bit worse
> if we went with the "label every unlikely sub-section contribution"
> approach proposed previously.
>
> Older gas doesn't support quoted symbols, yet the result looks quite
> bit better that way. Hence two variants get introduced, one using
> proper path names (including slashes and dashes) and one using path
> names after converting them to valid symbol names (slashes and dashes
> replaced).
>
> As a secondary adjustment also change the section name used with Clang.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
(XEN) '1' pressed -> Extreme debugging in progress...
(XEN) Xen WARN at /local/xen.git/xen/include/asm/hvm/vmx/vmx.h:329
(XEN) ----[ Xen-4.7-unstable x86_64 debug=y Not tainted ]----
(XEN) CPU: 0
(XEN) RIP: e008:[<ffff82d08019c2f2>]
traps.c#arch/x86/traps.o.unlikely+0/0x8
<snip>
(XEN) Xen call trace:
(XEN) [<ffff82d08019c2f2>] traps.c#arch/x86/traps.o.unlikely+0/0x8
(XEN) [<ffff82d080114bd3>] handle_keypress+0xa4/0xd9
(XEN) [<ffff82d08014282c>] console.c#__serial_rx+0x16/0x51
(XEN) [<ffff82d080142fb7>] console.c#serial_rx+0x8a/0x8f
(XEN) [<ffff82d08014529f>] serial_rx_interrupt+0x90/0xac
(XEN) [<ffff82d080143cef>] ns16550.c#ns16550_interrupt+0x57/0x71
(XEN) [<ffff82d08016fffe>] do_IRQ+0x582/0x629
(XEN) [<ffff82d08023dea2>] common_interrupt+0x62/0x70
(XEN)
Looks good.
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] xen/x86: Use tag in C UNLIKELY blocks, rather than a literal ".tag"
2015-12-11 13:42 [PATCH] x86: generate labels at the beginning of unlikely sub-sections Jan Beulich
2015-12-11 16:55 ` Andrew Cooper
@ 2015-12-11 18:52 ` Andrew Cooper
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2015-12-11 18:52 UTC (permalink / raw)
To: Xen-devel; +Cc: Andrew Cooper, Jan Beulich
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
v2 - Rebase on top of "x86: generate labels at the beginning of unlikely sub-sections"
---
xen/include/asm-x86/asm_defns.h | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/xen/include/asm-x86/asm_defns.h b/xen/include/asm-x86/asm_defns.h
index 7cf4408..b5f79d8 100644
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -180,16 +180,16 @@ void ret_from_intr(void);
#endif
-#define UNLIKELY_START(cond, tag) \
- "j" #cond " .Lunlikely%=.tag;\n\t" \
- UNLIKELY_START_SECTION "\n\t" \
- SUBSECTION_LBL(unlikely) "\n" \
- ".Lunlikely%=.tag:"
+#define UNLIKELY_START(cond, tag) \
+ "j" #cond " .Lunlikely." #tag ".%=;\n\t" \
+ UNLIKELY_START_SECTION "\n\t" \
+ SUBSECTION_LBL(unlikely) "\n" \
+ ".Lunlikely." #tag ".%=:"
#define UNLIKELY_END(tag) \
- "jmp .Llikely%=.tag;\n\t" \
+ "jmp .Llikely." #tag ".%=;\n\t" \
UNLIKELY_END_SECTION "\n" \
- ".Llikely%=.tag:"
+ ".Llikely." #tag ".%=:"
#endif
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-11 18:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-11 13:42 [PATCH] x86: generate labels at the beginning of unlikely sub-sections Jan Beulich
2015-12-11 16:55 ` Andrew Cooper
2015-12-11 18:52 ` [PATCH v2] xen/x86: Use tag in C UNLIKELY blocks, rather than a literal ".tag" Andrew Cooper
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.