]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
xen/arm: Add performance counters in guest atomic helpers
authorJulien Grall <julien.grall@arm.com>
Mon, 29 Apr 2019 14:05:29 +0000 (15:05 +0100)
committerJulien Grall <julien.grall@arm.com>
Fri, 14 Jun 2019 13:27:32 +0000 (14:27 +0100)
Add performance counters in guest atomic helpers to be able to detect
whether a guest is often paused during the operations.

This is part of XSA-295.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
xen/include/asm-arm/guest_atomics.h
xen/include/asm-arm/perfc_defn.h

index 61925d313db29718a3992fa3e973f596ccfc7c2f..698508bf87715935cbc36334375100bbe84bc8fc 100644 (file)
@@ -24,9 +24,13 @@ DECLARE_PER_CPU(unsigned int, guest_safe_atomic_max);
 #define guest_bitop(name)                                                   \
 static inline void guest_##name(struct domain *d, int nr, volatile void *p) \
 {                                                                           \
+    perfc_incr(atomics_guest);                                              \
+                                                                            \
     if ( name##_timeout(nr, p, this_cpu(guest_safe_atomic_max)) )           \
         return;                                                             \
                                                                             \
+    perfc_incr(atomics_guest_paused);                                       \
+                                                                            \
     domain_pause_nosync(d);                                                 \
     name(nr, p);                                                            \
     domain_unpause(d);                                                      \
@@ -38,11 +42,15 @@ static inline int guest_##name(struct domain *d, int nr, volatile void *p)  \
     bool succeed;                                                           \
     int oldbit;                                                             \
                                                                             \
+    perfc_incr(atomics_guest);                                              \
+                                                                            \
     succeed = name##_timeout(nr, p, &oldbit,                                \
                              this_cpu(guest_safe_atomic_max));              \
     if ( succeed )                                                          \
         return oldbit;                                                      \
                                                                             \
+    perfc_incr(atomics_guest_paused);                                       \
+                                                                            \
     domain_pause_nosync(d);                                                 \
     oldbit = name(nr, p);                                                   \
     domain_unpause(d);                                                      \
@@ -73,10 +81,14 @@ static inline unsigned long __guest_cmpxchg(struct domain *d,
 {
     unsigned long oldval = old;
 
+    perfc_incr(atomics_guest);
+
     if ( __cmpxchg_mb_timeout(ptr, &oldval, new, size,
                               this_cpu(guest_safe_atomic_max)) )
         return oldval;
 
+    perfc_incr(atomics_guest_paused);
+
     domain_pause_nosync(d);
     oldval = __cmpxchg_mb(ptr, old, new, size);
     domain_unpause(d);
index 8922e9525a444a5cecc66877b795794010c5231a..6a83185163239a8c47c2bd2dc9062743acc87614 100644 (file)
@@ -73,6 +73,9 @@ PERFCOUNTER(phys_timer_irqs,  "Physical timer interrupts")
 PERFCOUNTER(virt_timer_irqs,  "Virtual timer interrupts")
 PERFCOUNTER(maintenance_irqs, "Maintenance interrupts")
 
+PERFCOUNTER(atomics_guest,    "atomics: guest access")
+PERFCOUNTER(atomics_guest_paused,   "atomics: guest paused")
+
 /*#endif*/ /* __XEN_PERFC_DEFN_H__ */
 
 /*