Skip to contentSkip to conversation

vpmu intel: Add dumping vpmu infos in 'q' keyhandler

PATCH In review Dietmar Hahn 2 participants 4 messages Mar 14, 2013 – Mar 26, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vpmu intel: Add dumping vpmu infos in 'q' keyhandler

This patch extends the printout of the VPCU infos of the keyhandler 'q'. If vPMU is enabled is on the VCPU and active a line is printed like;
(XEN) vPMU running: fixed=0x2 general=0x1

This means from the fixed counters the counter 3 and the general counter 1 are enabled.
As example this picture happens on linux-3.4.6 with watchdog and 'perf top'. This patch supports only Intel as I don't have Amd machines. Thanks.

Dietmar.

xen/arch/x86/domain.c +3 -0
diff -r a6b81234b189 xen/arch/x86/domain.c
@@ -2093,6 +2093,9 @@ void arch_dump_domain_info(struct domain
 void arch_dump_vcpu_info(struct vcpu *v)
 {
     paging_dump_vcpu_info(v);
+
+    if ( is_hvm_vcpu(v) )
+        vpmu_dump(v);
 }
 
 void domain_cpuid(
xen/arch/x86/hvm/vmx/vpmu_core2.c +37 -1
diff -r a6b81234b189 xen/arch/x86/hvm/vmx/vpmu_core2.c
@@ -611,6 +611,41 @@ static void core2_vpmu_do_cpuid(unsigned
     }
 }
 
+static void core2_vpmu_dump(struct vcpu *v)
+{
+    struct vpmu_struct *vpmu = vcpu_vpmu(v);
+    int i, num, fixed, general;
+    struct core2_vpmu_context *core2_vpmu_cxt = NULL;
+
+    if ( !vpmu_is_set(vpmu, VPMU_CONTEXT_ALLOCATED) )
+         return;
+
+    if ( !vpmu_is_set(vpmu, VPMU_RUNNING) )
+    {
+        if ( vpmu_set(vpmu, VPMU_CONTEXT_LOADED) )
+            printk("    vPMU loaded\n");
+        else
+            printk("    vPMU allocated\n");
+        return;
+    }
+
+    core2_vpmu_cxt = vpmu->context;
+    num = core2_get_pmc_count();
+    general = 0;
+    for ( i = 0; i < num; i++ )
+    {
+        if ( core2_vpmu_cxt->pmu_enable->arch_pmc_enable[i] )
+            general |= 1 << i;
+    }
+    fixed = 0;
+    for ( i = 0; i < 3; i++ )
+    {
+        if ( core2_vpmu_cxt->pmu_enable->fixed_ctr_enable[i] )
+            fixed |= 1 << i;
+    }
+    printk("    vPMU running: fixed=0x%x general=0x%x\n", fixed, general);
+}
+
 static int core2_vpmu_do_interrupt(struct cpu_user_regs *regs)
 {
     struct vcpu *v = current;
@@ -724,7 +759,8 @@ struct arch_vpmu_ops core2_vpmu_ops = {
     .do_cpuid = core2_vpmu_do_cpuid,
     .arch_vpmu_destroy = core2_vpmu_destroy,
     .arch_vpmu_save = core2_vpmu_save,
-    .arch_vpmu_load = core2_vpmu_load
+    .arch_vpmu_load = core2_vpmu_load,
+    .arch_vpmu_dump = core2_vpmu_dump
 };
 
 int vmx_vpmu_initialise(struct vcpu *v, unsigned int vpmu_flags)
xen/arch/x86/hvm/vpmu.c +9 -0
diff -r a6b81234b189 xen/arch/x86/hvm/vpmu.c
@@ -157,3 +157,12 @@ void vpmu_destroy(struct vcpu *v)
         vpmu->arch_vpmu_ops->arch_vpmu_destroy(v);
 }
 
+/* Dump some vpmu informations on console. Used in keyhandler dump_domains(). */
+void vpmu_dump(struct vcpu *v)
+{
+    struct vpmu_struct *vpmu = vcpu_vpmu(v);
+
+    if ( vpmu->arch_vpmu_ops && vpmu->arch_vpmu_ops->arch_vpmu_dump )
+        vpmu->arch_vpmu_ops->arch_vpmu_dump(v);
+}
+
xen/include/asm-x86/hvm/vpmu.h +2 -0
diff -r a6b81234b189 xen/include/asm-x86/hvm/vpmu.h
@@ -54,6 +54,7 @@ struct arch_vpmu_ops {
     void (*arch_vpmu_destroy)(struct vcpu *v);
     void (*arch_vpmu_save)(struct vcpu *v);
     void (*arch_vpmu_load)(struct vcpu *v);
+    void (*arch_vpmu_dump)(struct vcpu *v);
 };
 
 int vmx_vpmu_initialise(struct vcpu *, unsigned int flags);
@@ -87,6 +88,7 @@ void vpmu_initialise(struct vcpu *v);
 void vpmu_destroy(struct vcpu *v);
 void vpmu_save(struct vcpu *v);
 void vpmu_load(struct vcpu *v);
+void vpmu_dump(struct vcpu *v);
 
 extern int acquire_pmu_ownership(int pmu_ownership);
 extern void release_pmu_ownership(int pmu_ownership);
Signature · 1 line
Company details: http://ts.fujitsu.com/imprint.html
#1 lore raw

Am Donnerstag 14 März 2013, 10:36:25 schrieb Dietmar Hahn:

Quoted 5 lines

This patch extends the printout of the VPCU infos of the keyhandler 'q'. If vPMU is enabled is on the VCPU and active a line is printed like;
(XEN) vPMU running: fixed=0x2 general=0x1

Quoted 7 lines

This means from the fixed counters the counter 3 and the general counter 1 are enabled.
As example this picture happens on linux-3.4.6 with watchdog and 'perf top'. This patch supports only Intel as I don't have Amd machines. Thanks.

Dietmar.

Ping?

Quoted 107 lines

diff -r a6b81234b189 xen/arch/x86/domain.c

xen/arch/x86/domain.c +3 -0
@@ -2093,6 +2093,9 @@ void arch_dump_domain_info(struct domain
 void arch_dump_vcpu_info(struct vcpu *v)
 {
     paging_dump_vcpu_info(v);
+
+    if ( is_hvm_vcpu(v) )
+        vpmu_dump(v);
 }
 
 void domain_cpuid(

diff -r a6b81234b189 xen/arch/x86/hvm/vmx/vpmu_core2.c

xen/arch/x86/hvm/vmx/vpmu_core2.c +37 -1
@@ -611,6 +611,41 @@ static void core2_vpmu_do_cpuid(unsigned
     }
 }
 
+static void core2_vpmu_dump(struct vcpu *v)
+{
+    struct vpmu_struct *vpmu = vcpu_vpmu(v);
+    int i, num, fixed, general;
+    struct core2_vpmu_context *core2_vpmu_cxt = NULL;
+
+    if ( !vpmu_is_set(vpmu, VPMU_CONTEXT_ALLOCATED) )
+         return;
+
+    if ( !vpmu_is_set(vpmu, VPMU_RUNNING) )
+    {
+        if ( vpmu_set(vpmu, VPMU_CONTEXT_LOADED) )
+            printk("    vPMU loaded\n");
+        else
+            printk("    vPMU allocated\n");
+        return;
+    }
+
+    core2_vpmu_cxt = vpmu->context;
+    num = core2_get_pmc_count();
+    general = 0;
+    for ( i = 0; i < num; i++ )
+    {
+        if ( core2_vpmu_cxt->pmu_enable->arch_pmc_enable[i] )
+            general |= 1 << i;
+    }
+    fixed = 0;
+    for ( i = 0; i < 3; i++ )
+    {
+        if ( core2_vpmu_cxt->pmu_enable->fixed_ctr_enable[i] )
+            fixed |= 1 << i;
+    }
+    printk("    vPMU running: fixed=0x%x general=0x%x\n", fixed, general);
+}
+
 static int core2_vpmu_do_interrupt(struct cpu_user_regs *regs)
 {
     struct vcpu *v = current;
@@ -724,7 +759,8 @@ struct arch_vpmu_ops core2_vpmu_ops = {
     .do_cpuid = core2_vpmu_do_cpuid,
     .arch_vpmu_destroy = core2_vpmu_destroy,
     .arch_vpmu_save = core2_vpmu_save,
-    .arch_vpmu_load = core2_vpmu_load
+    .arch_vpmu_load = core2_vpmu_load,
+    .arch_vpmu_dump = core2_vpmu_dump
 };
 
 int vmx_vpmu_initialise(struct vcpu *v, unsigned int vpmu_flags)

diff -r a6b81234b189 xen/arch/x86/hvm/vpmu.c

xen/arch/x86/hvm/vpmu.c +9 -0
@@ -157,3 +157,12 @@ void vpmu_destroy(struct vcpu *v)
         vpmu->arch_vpmu_ops->arch_vpmu_destroy(v);
 }
 
+/* Dump some vpmu informations on console. Used in keyhandler dump_domains(). */
+void vpmu_dump(struct vcpu *v)
+{
+    struct vpmu_struct *vpmu = vcpu_vpmu(v);
+
+    if ( vpmu->arch_vpmu_ops && vpmu->arch_vpmu_ops->arch_vpmu_dump )
+        vpmu->arch_vpmu_ops->arch_vpmu_dump(v);
+}
+

diff -r a6b81234b189 xen/include/asm-x86/hvm/vpmu.h

xen/include/asm-x86/hvm/vpmu.h +2 -0
@@ -54,6 +54,7 @@ struct arch_vpmu_ops {
     void (*arch_vpmu_destroy)(struct vcpu *v);
     void (*arch_vpmu_save)(struct vcpu *v);
     void (*arch_vpmu_load)(struct vcpu *v);
+    void (*arch_vpmu_dump)(struct vcpu *v);
 };
 
 int vmx_vpmu_initialise(struct vcpu *, unsigned int flags);
@@ -87,6 +88,7 @@ void vpmu_initialise(struct vcpu *v);
 void vpmu_destroy(struct vcpu *v);
 void vpmu_save(struct vcpu *v);
 void vpmu_load(struct vcpu *v);
+void vpmu_dump(struct vcpu *v);
 
 extern int acquire_pmu_ownership(int pmu_ownership);
 extern void release_pmu_ownership(int pmu_ownership);
Signature · 6 lines
Company details: http://ts.fujitsu.com/imprint.html

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw
Quoted 58 lines · Dietmar Hahn

Am Donnerstag 14 März 2013, 10:36:25 schrieb Dietmar Hahn:

Quoted 5 lines

This patch extends the printout of the VPCU infos of the keyhandler 'q'. If vPMU is enabled is on the VCPU and active a line is printed like;
(XEN) vPMU running: fixed=0x2 general=0x1

Quoted 7 lines

This means from the fixed counters the counter 3 and the general counter 1 are enabled.
As example this picture happens on linux-3.4.6 with watchdog and 'perf top'. This patch supports only Intel as I don't have Amd machines. Thanks.

Dietmar.

Ping?

Quoted 42 lines

diff -r a6b81234b189 xen/arch/x86/domain.c

xen/arch/x86/domain.c +3 -0
@@ -2093,6 +2093,9 @@ void arch_dump_domain_info(struct domain
 void arch_dump_vcpu_info(struct vcpu *v)
 {
     paging_dump_vcpu_info(v);
+
+    if ( is_hvm_vcpu(v) )
+        vpmu_dump(v);
 }
 
 void domain_cpuid(

diff -r a6b81234b189 xen/arch/x86/hvm/vmx/vpmu_core2.c

xen/arch/x86/hvm/vmx/vpmu_core2.c +20 -0
@@ -611,6 +611,41 @@ static void core2_vpmu_do_cpuid(unsigned
     }
 }
 
+static void core2_vpmu_dump(struct vcpu *v)
+{
+    struct vpmu_struct *vpmu = vcpu_vpmu(v);
+    int i, num, fixed, general;
+    struct core2_vpmu_context *core2_vpmu_cxt = NULL;
+
+    if ( !vpmu_is_set(vpmu, VPMU_CONTEXT_ALLOCATED) )
+         return;
+
+    if ( !vpmu_is_set(vpmu, VPMU_RUNNING) )
+    {
+        if ( vpmu_set(vpmu, VPMU_CONTEXT_LOADED) )
+            printk("    vPMU loaded\n");
+        else
+            printk("    vPMU allocated\n");
+        return;
+    }
+
+    core2_vpmu_cxt = vpmu->context;
+    num = core2_get_pmc_count();
Quoted 8 lines

xen/arch/x86/hvm/vmx/vpmu_core2.c static void core2_vpmu_do_cpuid(unsigned · line 641

Quoted 8 lines
xen/arch/x86/hvm/vmx/vpmu_core2.c +8 -0
+    general = 0;
+    for ( i = 0; i < num; i++ )
+    {
+        if ( core2_vpmu_cxt->pmu_enable->arch_pmc_enable[i] )
+            general |= 1 << i;
+    }
+    fixed = 0;
+    for ( i = 0; i < 3; i++ )

3? What if there are more? Ah, wait. The code can only do 3! Perhaps another extra patch that makes this a #define in case the CPU can do more in the future?

Quoted 5 lines

xen/arch/x86/hvm/vmx/vpmu_core2.c static void core2_vpmu_do_cpuid(unsigned · line 646

Quoted 5 lines
xen/arch/x86/hvm/vmx/vpmu_core2.c +5 -0
+    {
+        if ( core2_vpmu_cxt->pmu_enable->fixed_ctr_enable[i] )
+            fixed |= 1 << i;
+    }
+    printk("    vPMU running: fixed=0x%x general=0x%x\n", fixed, general);

Would it also make sense to print the contents of the MSR?

And also the global counter enable and the overflow one?

Quoted 60 lines
Quoted 52 lines
xen/arch/x86/hvm/vmx/vpmu_core2.c +4 -1
+}
+
 static int core2_vpmu_do_interrupt(struct cpu_user_regs *regs)
 {
     struct vcpu *v = current;
@@ -724,7 +759,8 @@ struct arch_vpmu_ops core2_vpmu_ops = {
     .do_cpuid = core2_vpmu_do_cpuid,
     .arch_vpmu_destroy = core2_vpmu_destroy,
     .arch_vpmu_save = core2_vpmu_save,
-    .arch_vpmu_load = core2_vpmu_load
+    .arch_vpmu_load = core2_vpmu_load,
+    .arch_vpmu_dump = core2_vpmu_dump
 };
 
 int vmx_vpmu_initialise(struct vcpu *v, unsigned int vpmu_flags)

diff -r a6b81234b189 xen/arch/x86/hvm/vpmu.c

xen/arch/x86/hvm/vpmu.c +9 -0
@@ -157,3 +157,12 @@ void vpmu_destroy(struct vcpu *v)
         vpmu->arch_vpmu_ops->arch_vpmu_destroy(v);
 }
 
+/* Dump some vpmu informations on console. Used in keyhandler dump_domains(). */
+void vpmu_dump(struct vcpu *v)
+{
+    struct vpmu_struct *vpmu = vcpu_vpmu(v);
+
+    if ( vpmu->arch_vpmu_ops && vpmu->arch_vpmu_ops->arch_vpmu_dump )
+        vpmu->arch_vpmu_ops->arch_vpmu_dump(v);
+}
+

diff -r a6b81234b189 xen/include/asm-x86/hvm/vpmu.h

xen/include/asm-x86/hvm/vpmu.h +2 -0
@@ -54,6 +54,7 @@ struct arch_vpmu_ops {
     void (*arch_vpmu_destroy)(struct vcpu *v);
     void (*arch_vpmu_save)(struct vcpu *v);
     void (*arch_vpmu_load)(struct vcpu *v);
+    void (*arch_vpmu_dump)(struct vcpu *v);
 };
 
 int vmx_vpmu_initialise(struct vcpu *, unsigned int flags);
@@ -87,6 +88,7 @@ void vpmu_initialise(struct vcpu *v);
 void vpmu_destroy(struct vcpu *v);
 void vpmu_save(struct vcpu *v);
 void vpmu_load(struct vcpu *v);
+void vpmu_dump(struct vcpu *v);
 
 extern int acquire_pmu_ownership(int pmu_ownership);
 extern void release_pmu_ownership(int pmu_ownership);
Signature · 6 lines
Company details: http://ts.fujitsu.com/imprint.html

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#3 lore raw

Am Montag 25 März 2013, 10:47:17 schrieb Konrad Rzeszutek Wilk:

Quoted 63 lines · Dietmar Hahn
Quoted 62 lines

Am Donnerstag 14 März 2013, 10:36:25 schrieb Dietmar Hahn:

Quoted 5 lines

This patch extends the printout of the VPCU infos of the keyhandler 'q'. If vPMU is enabled is on the VCPU and active a line is printed like;
(XEN) vPMU running: fixed=0x2 general=0x1

Quoted 7 lines

This means from the fixed counters the counter 3 and the general counter 1 are enabled.
As example this picture happens on linux-3.4.6 with watchdog and 'perf top'. This patch supports only Intel as I don't have Amd machines. Thanks.

Dietmar.

Ping?

Quoted 46 lines

diff -r a6b81234b189 xen/arch/x86/domain.c

xen/arch/x86/domain.c +3 -0
@@ -2093,6 +2093,9 @@ void arch_dump_domain_info(struct domain
 void arch_dump_vcpu_info(struct vcpu *v)
 {
     paging_dump_vcpu_info(v);
+
+    if ( is_hvm_vcpu(v) )
+        vpmu_dump(v);
 }
 
 void domain_cpuid(

diff -r a6b81234b189 xen/arch/x86/hvm/vmx/vpmu_core2.c

xen/arch/x86/hvm/vmx/vpmu_core2.c +24 -0
@@ -611,6 +611,41 @@ static void core2_vpmu_do_cpuid(unsigned
     }
 }
 
+static void core2_vpmu_dump(struct vcpu *v)
+{
+    struct vpmu_struct *vpmu = vcpu_vpmu(v);
+    int i, num, fixed, general;
+    struct core2_vpmu_context *core2_vpmu_cxt = NULL;
+
+    if ( !vpmu_is_set(vpmu, VPMU_CONTEXT_ALLOCATED) )
+         return;
+
+    if ( !vpmu_is_set(vpmu, VPMU_RUNNING) )
+    {
+        if ( vpmu_set(vpmu, VPMU_CONTEXT_LOADED) )
+            printk("    vPMU loaded\n");
+        else
+            printk("    vPMU allocated\n");
+        return;
+    }
+
+    core2_vpmu_cxt = vpmu->context;
+    num = core2_get_pmc_count();
+    general = 0;
+    for ( i = 0; i < num; i++ )
+    {
+        if ( core2_vpmu_cxt->pmu_enable->arch_pmc_enable[i] )
Quoted 8 lines
Quoted 4 lines

xen/arch/x86/hvm/vmx/vpmu_core2.c static void core2_vpmu_do_cpuid(unsigned · line 641

Quoted 4 lines
xen/arch/x86/hvm/vmx/vpmu_core2.c +4 -0
+            general |= 1 << i;
+    }
+    fixed = 0;
+    for ( i = 0; i < 3; i++ )

3? What if there are more? Ah, wait. The code can only do 3! Perhaps another extra patch that makes this a #define in case the CPU can do more in the future?

Yes, I had this in mind for a next step but still wait for ACK, NACK or comments of this patch.

Quoted 10 lines
Quoted 6 lines

xen/arch/x86/hvm/vmx/vpmu_core2.c static void core2_vpmu_do_cpuid(unsigned · line 646

Quoted 6 lines
xen/arch/x86/hvm/vmx/vpmu_core2.c +5 -0
+    {
+        if ( core2_vpmu_cxt->pmu_enable->fixed_ctr_enable[i] )
+            fixed |= 1 << i;
+    }
+    printk("    vPMU running: fixed=0x%x general=0x%x\n", fixed, general);

Would it also make sense to print the contents of the MSR?

And also the global counter enable and the overflow one?

Yes, can do this.

Dietmar.

Quoted 50 lines
Quoted 50 lines
Quoted 50 lines
xen/arch/x86/hvm/vmx/vpmu_core2.c +4 -1
+}
+
 static int core2_vpmu_do_interrupt(struct cpu_user_regs *regs)
 {
     struct vcpu *v = current;
@@ -724,7 +759,8 @@ struct arch_vpmu_ops core2_vpmu_ops = {
     .do_cpuid = core2_vpmu_do_cpuid,
     .arch_vpmu_destroy = core2_vpmu_destroy,
     .arch_vpmu_save = core2_vpmu_save,
-    .arch_vpmu_load = core2_vpmu_load
+    .arch_vpmu_load = core2_vpmu_load,
+    .arch_vpmu_dump = core2_vpmu_dump
 };
 
 int vmx_vpmu_initialise(struct vcpu *v, unsigned int vpmu_flags)

diff -r a6b81234b189 xen/arch/x86/hvm/vpmu.c

xen/arch/x86/hvm/vpmu.c +9 -0
@@ -157,3 +157,12 @@ void vpmu_destroy(struct vcpu *v)
         vpmu->arch_vpmu_ops->arch_vpmu_destroy(v);
 }
 
+/* Dump some vpmu informations on console. Used in keyhandler dump_domains(). */
+void vpmu_dump(struct vcpu *v)
+{
+    struct vpmu_struct *vpmu = vcpu_vpmu(v);
+
+    if ( vpmu->arch_vpmu_ops && vpmu->arch_vpmu_ops->arch_vpmu_dump )
+        vpmu->arch_vpmu_ops->arch_vpmu_dump(v);
+}
+

diff -r a6b81234b189 xen/include/asm-x86/hvm/vpmu.h

xen/include/asm-x86/hvm/vpmu.h +2 -0
@@ -54,6 +54,7 @@ struct arch_vpmu_ops {
     void (*arch_vpmu_destroy)(struct vcpu *v);
     void (*arch_vpmu_save)(struct vcpu *v);
     void (*arch_vpmu_load)(struct vcpu *v);
+    void (*arch_vpmu_dump)(struct vcpu *v);
 };
 
 int vmx_vpmu_initialise(struct vcpu *, unsigned int flags);
@@ -87,6 +88,7 @@ void vpmu_initialise(struct vcpu *v);
 void vpmu_destroy(struct vcpu *v);
 void vpmu_save(struct vcpu *v);
 void vpmu_load(struct vcpu *v);
+void vpmu_dump(struct vcpu *v);
 
 extern int acquire_pmu_ownership(int pmu_ownership);
 extern void release_pmu_ownership(int pmu_ownership);