[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] 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@xxxxxxxx>

--- 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: x86-label-subsections.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.