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

[Xen-devel] [PATCH 5/6] xen/x86: Avoid using local labels for UNLIKELY() regions



Using local labels causes the stack trace to use the last non-local
label emitted by the compiler in the translation unit, which is almost
always unrelated.

e.g. A (contrived debug) example switches from:

  (XEN) ----[ Xen-4.7-unstable  x86_64  debug=y  Not tainted ]----
  (XEN) CPU:    0
  (XEN) RIP:    e008:[<ffff82d0801961e2>] asm_domain_crash_synchronous+0x44/0x4c
  ...
  (XEN) Xen call trace:
  (XEN)    [<ffff82d0801961e2>] asm_domain_crash_synchronous+0x44/0x4c
  (XEN)    [<ffff82d080114bdf>] handle_keypress+0xa4/0xd9

to:

  (XEN) ----[ Xen-4.7-unstable  x86_64  debug=y  Not tainted ]----
  (XEN) CPU:    0
  (XEN) RIP:    e008:[<ffff82d0801961e2>] unlikely.vmptrld.921+0/0x8
  ...
  (XEN) Xen call trace:
  (XEN)    [<ffff82d0801961e2>] unlikely.vmptrld.921+0/0x8
  (XEN)    [<ffff82d080114bdf>] handle_keypress+0xa4/0xd9

which is far more relevant when identifying %eip.

Additionally, correct the inclusion of the tag parameter in the C UNLIKELY
blocks, to use the passed tag, rather than a literal ".tag".

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>

It is not obvious from the documentation whether an expansion of %= is unique
to the current translation unit, or entire linked binary; I suspect the
former.  There are no duplicate symbols introduced by this change in my
current compile, but I realise that this is hardly a guarantee.
---
 xen/include/asm-x86/asm_defns.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/xen/include/asm-x86/asm_defns.h b/xen/include/asm-x86/asm_defns.h
index 95ea21d..1028375 100644
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -95,9 +95,9 @@ void ret_from_intr(void);
 
 #define UNLIKELY_START(cond, tag) \
         .Ldispatch.tag:           \
-        j##cond .Lunlikely.tag;   \
+        j##cond unlikely.tag;     \
         .subsection 1;            \
-        .Lunlikely.tag:
+        unlikely.tag:
 
 #define UNLIKELY_DISPATCH_LABEL(tag) \
         .Ldispatch.tag
@@ -153,15 +153,15 @@ void ret_from_intr(void);
 
 #endif
 
-#define UNLIKELY_START(cond, tag)          \
-        "j" #cond " .Lunlikely%=.tag;\n\t" \
-        UNLIKELY_START_SECTION "\n"        \
-        ".Lunlikely%=.tag:"
+#define UNLIKELY_START(cond, tag)              \
+        "j" #cond " unlikely." #tag ".%=;\n\t" \
+        UNLIKELY_START_SECTION "\n"            \
+        "unlikely." #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


_______________________________________________
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®.