Skip to contentSkip to conversation

configure: add workaround for SystemTap PR13296

PATCH Superseded Stefan Hajnoczi 2 participants 3 messages Mar 21, 2014 – Mar 24, 2014

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 configure: add workaround for SystemTap PR13296

SystemTap sdt.h sometimes results in compiled probes without sufficient information to extract arguments. See code comment for details on this workaround.

This patch fixes the apic_reset_irq_delivered() trace event on Fedora 20 with gcc-4.8.2-7.fc20 and systemtap-sdt-devel-2.4-2.fc20 on x86_64.

---
 configure | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
configure +16 -0
index aae617e..6c86431 100755
@@ -3635,6 +3635,22 @@ if test "$trace_backend" = "dtrace"; then
   trace_backend_stap="no"
   if has 'stap' ; then
     trace_backend_stap="yes"
+
+    # Sometimes sdt.h probes produce insufficient information to access probe
+    # arguments.  The compiler can be forced to place probe arguments in
+    # registers to avoid the issue.  This workaround has a performance cost so
+    # it should be dropped if SystemTap is able to resolve the underlying
+    # issue.
+    #
+    # On host architectures that are starved for registers, it may not be
+    # possible to force arguments into registers and this causes a compiler
+    # error.  Only apply this workaround on x86_64 where the problem has been
+    # observed.
+    #
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=13296
+    if test "$ARCH" = "x86_64"; then
+      QEMU_CFLAGS="-DSTAP_SDT_ARG_CONSTRAINT=r $QEMU_CFLAGS"
+    fi
   fi
 fi
 
Signature · 1 line
1.8.5.3
#1 lore raw

Hi -

Quoted 6 lines · Stefan Hajnoczi

SystemTap sdt.h sometimes results in compiled probes without sufficient information to extract arguments. See code comment for details on this workaround.

This patch fixes the apic_reset_irq_delivered() trace event on Fedora 20 with gcc-4.8.2-7.fc20 and systemtap-sdt-devel-2.4-2.fc20 on x86_64.

An alternate solution would focus on this particular trace site. (It's peculiar because the surrounding code doesn't read the value being passed to the tracers at all, so the value is not already available in a register.)

The benefit of this solution is that the hundreds of other trace sites are not affected at all. 230 of them (on my qemu-system-X86 builds) use register-indirect operand expressions currently, and your patch would force all of those to be turned into actual loads -- i.e., slow down qemu.

Please consider whether that performance is worth it, over a patch as dreadful :-) as the following.

hw/intc/apic_common.c +4 -1
index c623fcc6d813..e7bbac1be48b 100644
@@ -117,7 +117,10 @@ void apic_report_irq_delivered(int delivered)
 
 void apic_reset_irq_delivered(void)
 {
-    trace_apic_reset_irq_delivered(apic_irq_delivered);
+    /* Copy this into a local variable to encourage gcc to emit a plain
+       register for a sys/sdt.h marker. */
+    volatile int a_i_d = apic_irq_delivered;
+    trace_apic_reset_irq_delivered(a_i_d);
 
     apic_irq_delivered = 0;
 }

- FChE

#2 lore raw
Quoted 32 lines · Frank Ch. Eigler

Hi -

Quoted 6 lines · Stefan Hajnoczi

SystemTap sdt.h sometimes results in compiled probes without sufficient information to extract arguments. See code comment for details on this workaround.

This patch fixes the apic_reset_irq_delivered() trace event on Fedora 20 with gcc-4.8.2-7.fc20 and systemtap-sdt-devel-2.4-2.fc20 on x86_64.

An alternate solution would focus on this particular trace site. (It's peculiar because the surrounding code doesn't read the value being passed to the tracers at all, so the value is not already available in a register.)

The benefit of this solution is that the hundreds of other trace sites are not affected at all. 230 of them (on my qemu-system-X86 builds) use register-indirect operand expressions currently, and your patch would force all of those to be turned into actual loads -- i.e., slow down qemu.

Please consider whether that performance is worth it, over a patch as dreadful :-) as the following.

hw/intc/apic_common.c +0 -0
index c623fcc6d813..e7bbac1be48b 100644
@@ -117,7 +117,10 @@ void apic_report_irq_delivered(int delivered)
 

hw/intc/apic_common.c void apic_report_irq_delivered(int delivered) · line 126

Quoted 10 lines
hw/intc/apic_common.c +4 -1
 void apic_reset_irq_delivered(void)
 {
-    trace_apic_reset_irq_delivered(apic_irq_delivered);
+    /* Copy this into a local variable to encourage gcc to emit a plain
+       register for a sys/sdt.h marker. */
+    volatile int a_i_d = apic_irq_delivered;
+    trace_apic_reset_irq_delivered(a_i_d);
 
     apic_irq_delivered = 0;
 }

This is not too bad either. Can I add your Signed-off-by:?

Stefan