Skip to contentSkip to conversation

xen: arm: enable perf counters

PATCH Superseded Ian Campbell 2 participants 5 messages Jan 14, 2015

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 xen: arm: enable perf counters

As well as the existing common perf counters add a bunch of ARM specifics, including the various trap types, vuart/vgic/vtimer accesses and different types of interrupt.

Adjust the common code so that the columns line up again, not sure when/where this went wrong.

This is mostly the set of stuff I happened to be interested in, it can be made more (or less) fine grained as the need arises.

---
I don't think I posted v2, but such a long time has passed I'm jumping to v3 to avoid confusion.

v3: Rebased onto current staging
Handled changes to PSCI (function numbers are no longer just small ints)
Handled VGIC refactoring (v2 vs v3)
Count WFI separate from WFE now we trap both.

v2: s/trap_cp15_32/trap_cp15_64/ when that was what I meant
s/vtimer_phys_ignored/vtimer_phys_masked/ which better describes it Removed a spurious whitespace change in traps.c.
Move comment on the scope of the change and future changes to the main
body of the commit log. Expanded the comment.
Line up the descriptions of blocks of perfc_defn.

---
 xen/arch/arm/gic.c               |    3 ++
 xen/arch/arm/irq.c               |    8 ++++-
 xen/arch/arm/time.c              |    4 +++
 xen/arch/arm/traps.c             |   36 ++++++++++++++++++-
 xen/arch/arm/vgic-v2.c           |    4 +++
 xen/arch/arm/vgic-v3.c           |   13 +++++++
 xen/arch/arm/vgic.c              |    9 +++++
 xen/arch/arm/vtimer.c            |   22 ++++++++++++
 xen/arch/arm/vuart.c             |    5 +++
 xen/common/perfc.c               |    4 +--
 xen/include/asm-arm/config.h     |    2 ++
 xen/include/asm-arm/perfc.h      |   12 +++++++
 xen/include/asm-arm/perfc_defn.h |   74 ++++++++++++++++++++++++++++++++++++++
 13 files changed, 192 insertions(+), 4 deletions(-)
 create mode 100644 xen/include/asm-arm/perfc.h
 create mode 100644 xen/include/asm-arm/perfc_defn.h
xen/arch/arm/gic.c +3 -0
index e7a1af5..390c8b0 100644
@@ -536,6 +536,8 @@ static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)
     /* Lower the priority */
     struct irq_desc *desc = irq_to_desc(sgi);
 
+    perfc_incr(ipis);
+
     /* Lower the priority */
     gic_hw_ops->eoi_irq(desc);
 
@@ -604,6 +606,7 @@ static void maintenance_interrupt(int irq, void *dev_id, struct cpu_user_regs *r
      * GICH_HCR_UIE is cleared before reading GICC_IAR. As a consequence
      * this handler is not called.
      */
+    perfc_incr(maintenance_irqs);
 }
 
 void gic_dump_info(struct vcpu *v)
xen/arch/arm/irq.c +7 -1
index 25ecf1d..604fc81 100644
@@ -179,7 +179,12 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq)
 {
     struct irq_desc *desc = irq_to_desc(irq);
 
-    /* TODO: perfc_incr(irqs); */
+    perfc_incr(irqs);
+
+    if (irq < 32) /* SGIs do not come down this path */
+        perfc_incr(ppis);
+    else
+        perfc_incr(spis);
 
     /* TODO: this_cpu(irq_count)++; */
 
@@ -199,6 +204,7 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq)
     {
         struct domain *d = irq_get_domain(desc);
 
+        perfc_incr(guest_irqs);
         desc->handler->end(desc);
 
         set_bit(_IRQ_INPROGRESS, &desc->status);
xen/arch/arm/time.c +4 -0
index 0add494..455f217 100644
@@ -151,6 +151,7 @@ static void timer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
     if ( irq == (timer_irq[TIMER_HYP_PPI]) &&
          READ_SYSREG32(CNTHP_CTL_EL2) & CNTx_CTL_PENDING )
     {
+        perfc_incr(hyp_timer_irqs);
         /* Signal the generic timer code to do its work */
         raise_softirq(TIMER_SOFTIRQ);
         /* Disable the timer to avoid more interrupts */
@@ -160,6 +161,7 @@ static void timer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
     if ( irq == (timer_irq[TIMER_PHYS_NONSECURE_PPI]) &&
          READ_SYSREG32(CNTP_CTL_EL0) & CNTx_CTL_PENDING )
     {
+        perfc_incr(phys_timer_irqs);
         /* Signal the generic timer code to do its work */
         raise_softirq(TIMER_SOFTIRQ);
         /* Disable the timer to avoid more interrupts */
@@ -182,6 +184,8 @@ static void vtimer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
     if ( unlikely(is_idle_vcpu(current)) )
         return;
 
+    perfc_incr(virt_timer_irqs);
+
     current->arch.virt_timer.ctl = READ_SYSREG32(CNTV_CTL_EL0);
     WRITE_SYSREG32(current->arch.virt_timer.ctl | CNTx_CTL_MASK, CNTV_CTL_EL0);
     vgic_vcpu_inject_irq(current, current->arch.virt_timer.irq);
xen/arch/arm/traps.c +35 -1
index 4c93250..68208d6 100644
@@ -30,6 +30,7 @@
 #include <xen/hypercall.h>
 #include <xen/softirq.h>
 #include <xen/domain_page.h>
+#include <xen/perfc.h>
 #include <public/sched.h>
 #include <public/xen.h>
 #include <asm/debugger.h>
@@ -1240,6 +1241,7 @@ static void do_trap_psci(struct cpu_user_regs *regs)
     case PSCI_cpu_off:
         {
             uint32_t pstate = PSCI_ARG32(regs,1);
+            perfc_incr(psci_cpu_off);
             PSCI_RESULT_REG(regs) = do_psci_cpu_off(pstate);
         }
         break;
@@ -1247,33 +1249,41 @@ static void do_trap_psci(struct cpu_user_regs *regs)
         {
             uint32_t vcpuid = PSCI_ARG32(regs,1);
             register_t epoint = PSCI_ARG(regs,2);
+            perfc_incr(psci_cpu_on);
             PSCI_RESULT_REG(regs) = do_psci_cpu_on(vcpuid, epoint);
         }
         break;
     case PSCI_0_2_FN_PSCI_VERSION:
+        perfc_incr(psci_version);
         PSCI_RESULT_REG(regs) = do_psci_0_2_version();
         break;
     case PSCI_0_2_FN_CPU_OFF:
+        perfc_incr(psci_cpu_off);
         PSCI_RESULT_REG(regs) = do_psci_0_2_cpu_off();
         break;
     case PSCI_0_2_FN_MIGRATE_INFO_TYPE:
+        perfc_incr(psci_migrate_info_type);
         PSCI_RESULT_REG(regs) = do_psci_0_2_migrate_info_type();
         break;
     case PSCI_0_2_FN_MIGRATE_INFO_UP_CPU:
     case PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU:
+        perfc_incr(psci_migrate_info_up_cpu);
         if ( psci_mode_check(current->domain, fid) )
             PSCI_RESULT_REG(regs) = do_psci_0_2_migrate_info_up_cpu();
         break;
     case PSCI_0_2_FN_SYSTEM_OFF:
+        perfc_incr(psci_system_off);
         do_psci_0_2_system_off();
         PSCI_RESULT_REG(regs) = PSCI_INTERNAL_FAILURE;
         break;
     case PSCI_0_2_FN_SYSTEM_RESET:
+        perfc_incr(psci_system_reset);
         do_psci_0_2_system_reset();
         PSCI_RESULT_REG(regs) = PSCI_INTERNAL_FAILURE;
         break;
     case PSCI_0_2_FN_CPU_ON:
     case PSCI_0_2_FN64_CPU_ON:
+        perfc_incr(psci_cpu_on);
         if ( psci_mode_check(current->domain, fid) )
         {
             register_t vcpuid = PSCI_ARG(regs,1);
@@ -1285,6 +1295,7 @@ static void do_trap_psci(struct cpu_user_regs *regs)
         break;
     case PSCI_0_2_FN_CPU_SUSPEND:
     case PSCI_0_2_FN64_CPU_SUSPEND:
+        perfc_incr(psci_cpu_suspend);
         if ( psci_mode_check(current->domain, fid) )
         {
             uint32_t pstate = PSCI_ARG32(regs,1);
@@ -1296,6 +1307,7 @@ static void do_trap_psci(struct cpu_user_regs *regs)
         break;
     case PSCI_0_2_FN_AFFINITY_INFO:
     case PSCI_0_2_FN64_AFFINITY_INFO:
+        perfc_incr(psci_cpu_affinity_info);
         if ( psci_mode_check(current->domain, fid) )
         {
             register_t taff = PSCI_ARG(regs,1);
@@ -1306,6 +1318,7 @@ static void do_trap_psci(struct cpu_user_regs *regs)
         break;
     case PSCI_0_2_FN_MIGRATE:
     case PSCI_0_2_FN64_MIGRATE:
+        perfc_incr(psci_cpu_migrate);
         if ( psci_mode_check(current->domain, fid) )
         {
             uint32_t tcpu = PSCI_ARG32(regs,1);
@@ -1344,15 +1357,19 @@ static void do_trap_hypercall(struct cpu_user_regs *regs, register_t *nr,
     register_t orig_pc = regs->pc;
 #endif
 
+    BUILD_BUG_ON(NR_hypercalls < ARRAY_SIZE(arm_hypercall_table) );
+
     if ( iss != XEN_HYPERCALL_TAG )
         domain_crash_synchronous();
 
     if ( *nr >= ARRAY_SIZE(arm_hypercall_table) )
     {
+        perfc_incr(invalid_hypercalls);
         HYPERCALL_RESULT_REG(regs) = -ENOSYS;
         return;
     }
 
+    perfc_incra(hypercalls, *nr);
     call = arm_hypercall_table[*nr].fn;
     if ( call == NULL )
     {
@@ -1492,8 +1509,10 @@ static int check_conditional_instr(struct cpu_user_regs *regs, union hsr hsr)
     cpsr_cond = cpsr >> 28;
 
     if ( !((cc_map[cond] >> cpsr_cond) & 1) )
+    {
+        perfc_incr(trap_uncond);
         return 0;
-
+    }
     return 1;
 }
 
@@ -2034,9 +2053,11 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs)
         }
         if ( hsr.wfi_wfe.ti ) {
             /* Yield the VCPU for WFE */
+            perfc_incr(trap_wfe);
             vcpu_yield();
         } else {
             /* Block the VCPU for WFI */
+            perfc_incr(trap_wfi);
             vcpu_block_unless_event_pending(current);
         }
         advance_pc(regs, hsr);
@@ -2044,32 +2065,39 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs)
     case HSR_EC_CP15_32:
         if ( !is_32bit_domain(current->domain) )
             goto bad_trap;
+        perfc_incr(trap_cp15_32);
         do_cp15_32(regs, hsr);
         break;
     case HSR_EC_CP15_64:
         if ( !is_32bit_domain(current->domain) )
             goto bad_trap;
+        perfc_incr(trap_cp15_64);
         do_cp15_64(regs, hsr);
         break;
     case HSR_EC_CP14_32:
         if ( !is_32bit_domain(current->domain) )
             goto bad_trap;
+        perfc_incr(trap_cp14_32);
         do_cp14_32(regs, hsr);
         break;
     case HSR_EC_CP14_DBG:
         if ( !is_32bit_domain(current->domain) )
             goto bad_trap;
+        perfc_incr(trap_cp14_dbg);
         do_cp14_dbg(regs, hsr);
         break;
     case HSR_EC_CP:
         if ( !is_32bit_domain(current->domain) )
             goto bad_trap;
+        perfc_incr(trap_cp);
         do_cp(regs, hsr);
         break;
     case HSR_EC_SMC32:
+        perfc_incr(trap_smc32);
         inject_undef32_exception(regs);
         break;
     case HSR_EC_HVC32:
+        perfc_incr(trap_hvc32);
 #ifndef NDEBUG
         if ( (hsr.iss & 0xff00) == 0xff00 )
             return do_debug_trap(regs, hsr.iss & 0x00ff);
@@ -2080,6 +2108,7 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs)
         break;
 #ifdef CONFIG_ARM_64
     case HSR_EC_HVC64:
+        perfc_incr(trap_hvc64);
 #ifndef NDEBUG
         if ( (hsr.iss & 0xff00) == 0xff00 )
             return do_debug_trap(regs, hsr.iss & 0x00ff);
@@ -2089,19 +2118,23 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs)
         do_trap_hypercall(regs, &regs->x16, hsr.iss);
         break;
     case HSR_EC_SMC64:
+        perfc_incr(trap_smc64);
         inject_undef64_exception(regs, hsr.len);
         break;
     case HSR_EC_SYSREG:
         if ( is_32bit_domain(current->domain) )
             goto bad_trap;
+        perfc_incr(trap_sysreg);
         do_sysreg(regs, hsr);
         break;
 #endif
 
     case HSR_EC_INSTR_ABORT_LOWER_EL:
+        perfc_incr(trap_iabt);
         do_trap_instr_abort_guest(regs, hsr);
         break;
     case HSR_EC_DATA_ABORT_LOWER_EL:
+        perfc_incr(trap_dabt);
         do_trap_data_abort_guest(regs, hsr);
         break;
 
@@ -2113,6 +2146,7 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs)
 
     default:
  bad_trap:
+        perfc_incr(trap_bad);
         printk("Hypervisor Trap. HSR=0x%x EC=0x%x IL=%x Syndrome=0x%"PRIx32"\n",
                hsr.bits, hsr.ec, hsr.len, hsr.iss);
         do_unexpected_trap("Hypervisor", regs);
xen/arch/arm/vgic-v2.c +4 -0
index 1369f78..4dc2267 100644
@@ -41,6 +41,8 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info)
     int gicd_reg = (int)(info->gpa - v->domain->arch.vgic.dbase);
     unsigned long flags;
 
+    perfc_incr(vgicd_reads);
+
     switch ( gicd_reg )
     {
     case GICD_CTLR:
@@ -271,6 +273,8 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info)
     uint32_t tr;
     unsigned long flags;
 
+    perfc_incr(vgicd_writes);
+
     switch ( gicd_reg )
     {
     case GICD_CTLR:
xen/arch/arm/vgic-v3.c +13 -0
index ff99e50..c738ca9 100644
@@ -605,6 +605,8 @@ static int vgic_v3_rdistr_mmio_read(struct vcpu *v, mmio_info_t *info)
 {
     uint32_t offset;
 
+    perfc_incr(vgicr_reads);
+
     if ( v->domain->arch.vgic.rdist_stride != 0 )
         offset = info->gpa & (v->domain->arch.vgic.rdist_stride - 1);
     else
@@ -627,6 +629,8 @@ static int vgic_v3_rdistr_mmio_write(struct vcpu *v, mmio_info_t *info)
 {
     uint32_t offset;
 
+    perfc_incr(vgicr_writes);
+
     if ( v->domain->arch.vgic.rdist_stride != 0 )
         offset = info->gpa & (v->domain->arch.vgic.rdist_stride - 1);
     else
@@ -656,6 +660,8 @@ static int vgic_v3_distr_mmio_read(struct vcpu *v, mmio_info_t *info)
     unsigned int vcpu_id;
     int gicd_reg = (int)(info->gpa - v->domain->arch.vgic.dbase);
 
+    perfc_incr(vgicd_reads);
+
     switch ( gicd_reg )
     {
     case GICD_CTLR:
@@ -801,6 +807,8 @@ static int vgic_v3_distr_mmio_write(struct vcpu *v, mmio_info_t *info)
     struct vcpu *old_vcpu, *new_vcpu;
     int gicd_reg = (int)(info->gpa - v->domain->arch.vgic.dbase);
 
+    perfc_incr(vgicd_writes);
+
     switch ( gicd_reg )
     {
     case GICD_CTLR:
@@ -980,6 +988,11 @@ static int vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr)
 
     ASSERT (hsr.ec == HSR_EC_SYSREG);
 
+    if ( sysreg.read )
+        perfc_incr(vgic_sysreg_reads);
+    else
+        perfc_incr(vgic_sysreg_writes);
+
     switch ( hsr.bits & HSR_SYSREG_REGS_MASK )
     {
     case HSR_SYSREG_ICC_SGI1R_EL1:
xen/arch/arm/vgic.c +9 -0
index b8bd38b..8938a69 100644
@@ -24,6 +24,7 @@
 #include <xen/softirq.h>
 #include <xen/irq.h>
 #include <xen/sched.h>
+#include <xen/perfc.h>
 
 #include <asm/current.h>
 
@@ -185,6 +186,8 @@ void vgic_migrate_irq(struct vcpu *old, struct vcpu *new, unsigned int irq)
     if ( test_bit(GIC_IRQ_GUEST_MIGRATING, &p->status) )
         return;
 
+    perfc_incr(vgic_irq_migrates);
+
     spin_lock_irqsave(&old->arch.vgic.lock, flags);
 
     if ( list_empty(&p->inflight) )
@@ -301,12 +304,14 @@ int vgic_to_sgi(struct vcpu *v, register_t sgir, enum gic_sgi_mode irqmode, int
     switch ( irqmode )
     {
     case SGI_TARGET_LIST:
+        perfc_incr(vgic_sgi_list);
         break;
     case SGI_TARGET_OTHERS:
         /*
          * We expect vcpu_mask to be 0 for SGI_TARGET_OTHERS and
          * SGI_TARGET_SELF mode. So Force vcpu_mask to 0
          */
+        perfc_incr(vgic_sgi_others);
         vcpu_mask = 0;
         for ( i = 0; i < d->max_vcpus; i++ )
         {
@@ -320,6 +325,7 @@ int vgic_to_sgi(struct vcpu *v, register_t sgir, enum gic_sgi_mode irqmode, int
          * We expect vcpu_mask to be 0 for SGI_TARGET_OTHERS and
          * SGI_TARGET_SELF mode. So Force vcpu_mask to 0
          */
+        perfc_incr(vgic_sgi_self);
         vcpu_mask = 0;
         set_bit(current->vcpu_id, &vcpu_mask);
         break;
@@ -418,7 +424,10 @@ out:
     running = v->is_running;
     vcpu_unblock(v);
     if ( running && v != current )
+    {
+        perfc_incr(vgic_cross_cpu_intr_inject);
         smp_send_event_check_mask(cpumask_of(v->processor));
+    }
 }
 
 void vgic_vcpu_inject_spi(struct domain *d, unsigned int irq)
xen/arch/arm/vtimer.c +22 -0
index 2e95ceb..848e2c6 100644
@@ -21,6 +21,7 @@
 #include <xen/lib.h>
 #include <xen/timer.h>
 #include <xen/sched.h>
+#include <xen/perfc.h>
 #include <asm/irq.h>
 #include <asm/time.h>
 #include <asm/gic.h>
@@ -35,7 +36,12 @@ static void phys_timer_expired(void *data)
     struct vtimer *t = data;
     t->ctl |= CNTx_CTL_PENDING;
     if ( !(t->ctl & CNTx_CTL_MASK) )
+    {
+        perfc_incr(vtimer_phys_inject);
         vgic_vcpu_inject_irq(t->v, t->irq);
+    }
+    else
+        perfc_incr(vtimer_phys_masked);
 }
 
 static void virt_timer_expired(void *data)
@@ -43,6 +49,7 @@ static void virt_timer_expired(void *data)
     struct vtimer *t = data;
     t->ctl |= CNTx_CTL_MASK;
     vgic_vcpu_inject_irq(t->v, t->irq);
+    perfc_incr(vtimer_virt_inject);
 }
 
 int domain_vtimer_init(struct domain *d)
@@ -196,6 +203,11 @@ static int vtimer_emulate_cp32(struct cpu_user_regs *regs, union hsr hsr)
     struct hsr_cp32 cp32 = hsr.cp32;
     uint32_t *r = (uint32_t *)select_user_reg(regs, cp32.reg);
 
+    if ( cp32.read )
+        perfc_incr(vtimer_cp32_reads);
+    else
+        perfc_incr(vtimer_cp32_writes);
+
     switch ( hsr.bits & HSR_CP32_REGS_MASK )
     {
     case HSR_CPREG32(CNTP_CTL):
@@ -218,6 +230,11 @@ static int vtimer_emulate_cp64(struct cpu_user_regs *regs, union hsr hsr)
     uint32_t *r2 = (uint32_t *)select_user_reg(regs, cp64.reg2);
     uint64_t x;
 
+    if ( cp64.read )
+        perfc_incr(vtimer_cp64_reads);
+    else
+        perfc_incr(vtimer_cp64_writes);
+
     switch ( hsr.bits & HSR_CP64_REGS_MASK )
     {
     case HSR_CPREG64(CNTPCT):
@@ -243,6 +260,11 @@ static int vtimer_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr)
     register_t *x = select_user_reg(regs, sysreg.reg);
     uint32_t r = (uint32_t)*x;
 
+    if ( sysreg.read )
+        perfc_incr(vtimer_sysreg_reads);
+    else
+        perfc_incr(vtimer_sysreg_writes);
+
     switch ( hsr.bits & HSR_SYSREG_REGS_MASK )
     {
     case HSR_SYSREG_CNTP_CTL_EL0:
xen/arch/arm/vuart.c +5 -0
index e327c15..d9f4249 100644
@@ -39,6 +39,7 @@
 #include <xen/ctype.h>
 #include <xen/serial.h>
 #include <asm/mmio.h>
+#include <xen/perfc.h>
 
 #include "vuart.h"
 
@@ -112,6 +113,8 @@ static int vuart_mmio_read(struct vcpu *v, mmio_info_t *info)
     register_t *r = select_user_reg(regs, dabt.reg);
     paddr_t offset = info->gpa - d->arch.vuart.info->base_addr;
 
+    perfc_incr(vuart_reads);
+
     /* By default zeroed the register */
     *r = 0;
 
@@ -130,6 +133,8 @@ static int vuart_mmio_write(struct vcpu *v, mmio_info_t *info)
     register_t *r = select_user_reg(regs, dabt.reg);
     paddr_t offset = info->gpa - d->arch.vuart.info->base_addr;
 
+    perfc_incr(vuart_writes);
+
     if ( offset == d->arch.vuart.info->data_off )
         /* ignore any status bits */
         vuart_print_char(v, *r & 0xFF);
xen/common/perfc.c +2 -2
index 96a4245..9f078e1 100644
@@ -57,7 +57,7 @@ void perfc_printall(unsigned char key)
                 for_each_online_cpu ( cpu )
                 {
                     if ( k > 0 && (k % 4) == 0 )
-                        printk("\n%46s", "");
+                        printk("\n%53s", "");
                     printk("  CPU%02u[%10"PRIperfc"u]", cpu, per_cpu(perfcounters, cpu)[j]);
                     ++k;
                 }
@@ -103,7 +103,7 @@ void perfc_printall(unsigned char key)
                     if ( perfc_info[i].type == TYPE_S_ARRAY ) 
                         sum = (perfc_t) sum;
                     if ( k > 0 && (k % 4) == 0 )
-                        printk("\n%46s", "");
+                        printk("\n%53s", "");
                     printk("  CPU%02u[%10Lu]", cpu, sum);
                     ++k;
                 }
xen/include/asm-arm/config.h +2 -0
index 9e165db..1b5a842 100644
@@ -187,6 +187,8 @@
 #define PAGE_MASK           (~(PAGE_SIZE-1))
 #define PAGE_FLAG_MASK      (~0)
 
+#define NR_hypercalls 64
+
 #define STACK_ORDER 3
 #define STACK_SIZE  (PAGE_SIZE << STACK_ORDER)
 
xen/include/asm-arm/perfc.h new file +12 -0
new file mode 100644
index 0000000..a1a591e
@@ -0,0 +1,12 @@
+#ifndef __ASM_PERFC_H__
+#define __ASM_PERFC_H__
+
+static inline void arch_perfc_reset(void)
+{
+}
+
+static inline void arch_perfc_gather(void)
+{
+}
+
+#endif
xen/include/asm-arm/perfc_defn.h new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#1 lore raw

Hi Ian,

xen/arch/arm/irq.c void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq) · line 184

Quoted 12 lines · Ian Campbell
xen/arch/arm/irq.c +3 -1
index 25ecf1d..604fc81 100644
@@ -179,7 +179,12 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq)
 {
     struct irq_desc *desc = irq_to_desc(irq);
 
-    /* TODO: perfc_incr(irqs); */
+    perfc_incr(irqs);
+
+    if (irq < 32) /* SGIs do not come down this path */

if ( irq < 32 )

Maybe an ASSERT(irq >= 16) to check the validity of the comment.

[..]

Quoted 21 lines
xen/arch/arm/traps.c +2 -0
index 4c93250..68208d6 100644
@@ -30,6 +30,7 @@
 #include <xen/hypercall.h>
 #include <xen/softirq.h>
 #include <xen/domain_page.h>
+#include <xen/perfc.h>
 #include <public/sched.h>
 #include <public/xen.h>
 #include <asm/debugger.h>
@@ -1240,6 +1241,7 @@ static void do_trap_psci(struct cpu_user_regs *regs)
     case PSCI_cpu_off:
         {
             uint32_t pstate = PSCI_ARG32(regs,1);
+            perfc_incr(psci_cpu_off);
             PSCI_RESULT_REG(regs) = do_psci_cpu_off(pstate);
         }
         break;

xen/arch/arm/traps.c static void do_trap_psci(struct cpu_user_regs *regs) · line 1252

Quoted 4 lines
xen/arch/arm/traps.c +1 -0
@@ -1247,33 +1249,41 @@ static void do_trap_psci(struct cpu_user_regs *regs)
         {
             uint32_t vcpuid = PSCI_ARG32(regs,1);
             register_t epoint = PSCI_ARG(regs,2);
+            perfc_incr(psci_cpu_on);

I find confusing to use psci_cpu_on because it may refer to the host psci.

Maybe renaming to vpsci_ would be better?

[..]

xen/arch/arm/traps.c asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs) · line 2149

Quoted 5 lines
xen/arch/arm/traps.c +1 -0
@@ -2113,6 +2146,7 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs)
 
     default:
  bad_trap:
+        perfc_incr(trap_bad);

I don't think this perf counters is useful. When the CPU is receiving a bad trap Xen will panic in do_unexpected_trap.

[..]

Quoted 8 lines
xen/include/asm-arm/perfc.h new file +2 -0
new file mode 100644
index 0000000..a1a591e
@@ -0,0 +1,12 @@
+#ifndef __ASM_PERFC_H__
+#define __ASM_PERFC_H__

xen/include/asm-arm/perfc.h line 12

Quoted 10 lines
xen/include/asm-arm/perfc.h new file +10 -0
+
+static inline void arch_perfc_reset(void)
+{
+}
+
+static inline void arch_perfc_gather(void)
+{
+}
+
+#endif

Missing the Emacs local variables.

xen/include/asm-arm/perfc_defn.h line 1

Quoted 7 lines
xen/include/asm-arm/perfc_defn.h new file +1 -0
new file mode 100644
index 0000000..df86879
@@ -0,0 +1,74 @@
+/* This file is legiimately included multiple times. */

Legacy for xen/include/perfc_defn.h?

xen/include/asm-arm/perfc_defn.h line 2

Quoted 1 line
xen/include/asm-arm/perfc_defn.h new file +1 -0
+/*#ifndef __XEN_PERFC_DEFN_H__*/

All headers in asm-arm use __ARCH_ARM_* or __ARM_*

This would avoid the strange reason to not use guard in xen/perfc_defn.h.

[..]

xen/include/asm-arm/perfc_defn.h line 74

Quoted 1 line
xen/include/asm-arm/perfc_defn.h new file +1 -0
+/*#endif*/ /* __XEN_PERFC_DEFN_H__ */

Missing local variables for emacs.

Regards,

Signature · 1 line
Julien Grall
#2 lore raw
Quoted 11 lines · Julien Grall

Hi Ian,

Quoted 8 lines · Ian Campbell
xen/arch/arm/irq.c +0 -0
index 25ecf1d..604fc81 100644
@@ -179,7 +179,12 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq)
 {
     struct irq_desc *desc = irq_to_desc(irq);
 
Quoted 8 lines

xen/arch/arm/irq.c void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq) · line 184

Quoted 4 lines
xen/arch/arm/irq.c +3 -1
-    /* TODO: perfc_incr(irqs); */
+    perfc_incr(irqs);
+
+    if (irq < 32) /* SGIs do not come down this path */

if ( irq < 32 )

Maybe an ASSERT(irq >= 16) to check the validity of the comment.

OK.

Quoted 5 lines

xen/arch/arm/irq.c void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq) · line 185

Quoted 1 line
xen/arch/arm/irq.c +1 -0
+            perfc_incr(psci_cpu_on);

I find confusing to use psci_cpu_on because it may refer to the host psci.

Maybe renaming to vpsci_ would be better?

Yes, good idea.

Quoted 11 lines

[..]

xen/arch/arm/irq.c asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs) · line 2149

Quoted 5 lines
xen/arch/arm/irq.c +1 -0
@@ -2113,6 +2146,7 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs)
 
     default:
  bad_trap:
+        perfc_incr(trap_bad);

I don't think this perf counters is useful. When the CPU is receiving a bad trap Xen will panic in do_unexpected_trap.

Good point, I'll drop.

Quoted 3 lines

xen/arch/arm/irq.c asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs) · line 2150

Quoted 1 line
xen/arch/arm/irq.c +1 -0
+#endif

Missing the Emacs local variables.

Will add.

Quoted 10 lines

xen/include/asm-arm/perfc_defn.h line 1

Quoted 8 lines
xen/include/asm-arm/perfc_defn.h new file +1 -0
new file mode 100644
index 0000000..df86879
@@ -0,0 +1,74 @@
+/* This file is legiimately included multiple times. */

Legacy for xen/include/perfc_defn.h?

No, since this file is included by that. perfc_defn.* contain lists which are included multiple times using different definitions of PERFCOUNTER etc to produce different bits of the require infrastructure (definitions vs declarations). asm-x86/perfc_defn.h is identical in this respect.

Quoted 5 lines

xen/include/asm-arm/perfc_defn.h line 2

Quoted 1 line
xen/include/asm-arm/perfc_defn.h new file +1 -0
+/*#ifndef __XEN_PERFC_DEFN_H__*/

All headers in asm-arm use __ARCH_ARM_* or __ARM_*

This would avoid the strange reason to not use guard in xen/perfc_defn.h.

No it wouldn't.

Quoted 6 lines

[..]

Quoted 1 line

+/*#endif*/ /* __XEN_PERFC_DEFN_H__ */

Missing local variables for emacs.

Will add.

Ian.

#3 lore raw
Quoted 10 lines · Ian Campbell
Quoted 9 lines

xen/include/asm-arm/perfc_defn.h line 1

Quoted 7 lines
xen/include/asm-arm/perfc_defn.h new file +1 -0
new file mode 100644
index 0000000..df86879
@@ -0,0 +1,74 @@
+/* This file is legiimately included multiple times. */

Legacy for xen/include/perfc_defn.h?

Quoted 5 lines

No, since this file is included by that. perfc_defn.* contain lists which are included multiple times using different definitions of PERFCOUNTER etc to produce different bits of the require infrastructure (definitions vs declarations). asm-x86/perfc_defn.h is identical in this respect.

Oh ok. Thanks for the information.

BTW, I think you wanted to mean legitimately.

Regards,

Signature · 1 line
Julien Grall
#4 lore raw
Quoted 10 lines · Julien Grall
Quoted 8 lines · Ian Campbell
Quoted 8 lines

xen/include/asm-arm/perfc_defn.h line 1

Quoted 7 lines
xen/include/asm-arm/perfc_defn.h new file +1 -0
new file mode 100644
index 0000000..df86879
@@ -0,0 +1,74 @@
+/* This file is legiimately included multiple times. */

BTW, I think you wanted to mean legitimately.

That's what the patch had, one of us must have corrupted it by mistake.

Ian,