All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
Cc: Eddie Dong <eddie.dong@intel.com>,
	suravee.suthikulpanit@amd.com,
	Jun Nakajima <jun.nakajima@intel.com>,
	xen-devel@lists.xen.org
Subject: Re: [PATCH 3/3] vpmu intel: Dump vpmu infos in 'q' keyhandler
Date: Wed, 27 Mar 2013 11:16:31 -0400	[thread overview]
Message-ID: <20130327151631.GA5759@phenom.dumpdata.com> (raw)
In-Reply-To: <4177745.rHO2l0H14z@amur>

On Wed, Mar 27, 2013 at 03:13:22PM +0100, Dietmar Hahn wrote:
> This patch works only on top of 2/3.
> 
> This patch extends the printout of the VPCU infos of the keyhandler 'q'.
> If vPMU is enabled is on the VCPU and active lines are printed like
> (when running HVM openSuSE-12.3 with 'perf top');
> 
> (XEN)     vPMU running
> (XEN)       general_0: 0x000000ffffff3ae1 ctrl: 0x000000000053003c
> (XEN)       fixed_1:   0x000000ff90799188 ctrl: 0xb
> 
> This means general counter 0 and fixed counter 1 are running with showing
> their contents and the contents of their configuration msr.
> Thanks.
> Dietmar.
> 
> Signed-off-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>

Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> 
> 
> Index: xen-unstable.hg/xen/arch/x86/domain.c
> ===================================================================
> --- xen-unstable.hg.orig/xen/arch/x86/domain.c
> +++ xen-unstable.hg/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(
> Index: xen-unstable.hg/xen/arch/x86/hvm/vmx/vpmu_core2.c
> ===================================================================
> --- xen-unstable.hg.orig/xen/arch/x86/hvm/vmx/vpmu_core2.c
> +++ xen-unstable.hg/xen/arch/x86/hvm/vmx/vpmu_core2.c
> @@ -124,6 +124,14 @@ static const u32 core2_fix_counters_msr[
>      MSR_CORE_PERF_FIXED_CTR2
>  };
>  
> +/*
> + * MSR_CORE_PERF_FIXED_CTR_CTRL contains the configuration of all fixed
> + * counters. 4 bits for every counter.
> + */
> +#define FIXED_CTRL_CTRL_CONF_WIDTH 4
> +/* The index into the core2_ctrls_msr[] of this MSR used in core2_vpmu_dump() */
> +#define MSR_CORE_PERF_FIXED_CTR_CTRL_IDX 0
> +
>  /* Core 2 Non-architectual Performance Control MSRs. */
>  static const u32 core2_ctrls_msr[] = {
>      MSR_CORE_PERF_FIXED_CTR_CTRL,
> @@ -638,6 +646,52 @@ static void core2_vpmu_do_cpuid(unsigned
>      }
>  }
>  
> +/* Dump vpmu info on console, called in the context of keyhandler 'q'. */
> +static void core2_vpmu_dump(struct vcpu *v)
> +{
> +    struct vpmu_struct *vpmu = vcpu_vpmu(v);
> +    int i, num;
> +    struct core2_vpmu_context *core2_vpmu_cxt = NULL;
> +    u64 val, mask;
> +
> +    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;
> +    }
> +
> +    printk("    vPMU running\n");
> +    core2_vpmu_cxt = vpmu->context;
> +    num = core2_get_pmc_count();
> +    /* Print the contents of the counter and its configuration msr. */
> +    for ( i = 0; i < num; i++ )
> +    {
> +        struct arch_msr_pair* msr_pair = core2_vpmu_cxt->arch_msr_pair;
> +        if ( core2_vpmu_cxt->pmu_enable->arch_pmc_enable[i] )
> +            printk("      general_%d: 0x%016lx ctrl: 0x%016lx\n",
> +                             i, msr_pair[i].counter, msr_pair[i].control);
> +    }
> +    /*
> +     * The configuration of the fixed counter is 4 bits each in the
> +     * MSR_CORE_PERF_FIXED_CTR_CTRL.
> +     */
> +    val = core2_vpmu_cxt->ctrls[MSR_CORE_PERF_FIXED_CTR_CTRL_IDX];
> +    mask = (1 << FIXED_CTRL_CTRL_CONF_WIDTH) - 1;
> +    for ( i = 0; i < core2_fix_counters.num; i++ )
> +    {
> +        if ( core2_vpmu_cxt->pmu_enable->fixed_ctr_enable[i] )
> +            printk("      fixed_%d:   0x%016lx ctrl: 0x%lx\n",
> +                             i, core2_vpmu_cxt->fix_counters[i], val & mask);
> +	val >>= FIXED_CTRL_CTRL_CONF_WIDTH;
> +    }
> +}
> +
>  static int core2_vpmu_do_interrupt(struct cpu_user_regs *regs)
>  {
>      struct vcpu *v = current;
> @@ -751,7 +805,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
>  };
>  
>  static void core2_no_vpmu_do_cpuid(unsigned int input,
> Index: xen-unstable.hg/xen/arch/x86/hvm/vpmu.c
> ===================================================================
> --- xen-unstable.hg.orig/xen/arch/x86/hvm/vpmu.c
> +++ xen-unstable.hg/xen/arch/x86/hvm/vpmu.c
> @@ -154,3 +154,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);
> +}
> +
> Index: xen-unstable.hg/xen/include/asm-x86/hvm/vpmu.h
> ===================================================================
> --- xen-unstable.hg.orig/xen/include/asm-x86/hvm/vpmu.h
> +++ xen-unstable.hg/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);
> 
> 
> -- 
> Company details: http://ts.fujitsu.com/imprint.html

> Index: xen-unstable.hg/xen/arch/x86/domain.c
> ===================================================================
> --- xen-unstable.hg.orig/xen/arch/x86/domain.c
> +++ xen-unstable.hg/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(
> Index: xen-unstable.hg/xen/arch/x86/hvm/vmx/vpmu_core2.c
> ===================================================================
> --- xen-unstable.hg.orig/xen/arch/x86/hvm/vmx/vpmu_core2.c
> +++ xen-unstable.hg/xen/arch/x86/hvm/vmx/vpmu_core2.c
> @@ -124,6 +124,14 @@ static const u32 core2_fix_counters_msr[
>      MSR_CORE_PERF_FIXED_CTR2
>  };
>  
> +/*
> + * MSR_CORE_PERF_FIXED_CTR_CTRL contains the configuration of all fixed
> + * counters. 4 bits for every counter.
> + */
> +#define FIXED_CTRL_CTRL_CONF_WIDTH 4
> +/* The index into the core2_ctrls_msr[] of this MSR used in core2_vpmu_dump() */
> +#define MSR_CORE_PERF_FIXED_CTR_CTRL_IDX 0
> +
>  /* Core 2 Non-architectual Performance Control MSRs. */
>  static const u32 core2_ctrls_msr[] = {
>      MSR_CORE_PERF_FIXED_CTR_CTRL,
> @@ -638,6 +646,52 @@ static void core2_vpmu_do_cpuid(unsigned
>      }
>  }
>  
> +/* Dump vpmu info on console, called in the context of keyhandler 'q'. */
> +static void core2_vpmu_dump(struct vcpu *v)
> +{
> +    struct vpmu_struct *vpmu = vcpu_vpmu(v);
> +    int i, num;
> +    struct core2_vpmu_context *core2_vpmu_cxt = NULL;
> +    u64 val, mask;
> +
> +    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;
> +    }
> +
> +    printk("    vPMU running\n");
> +    core2_vpmu_cxt = vpmu->context;
> +    num = core2_get_pmc_count();
> +    /* Print the contents of the counter and its configuration msr. */
> +    for ( i = 0; i < num; i++ )
> +    {
> +        struct arch_msr_pair* msr_pair = core2_vpmu_cxt->arch_msr_pair;
> +        if ( core2_vpmu_cxt->pmu_enable->arch_pmc_enable[i] )
> +            printk("      general_%d: 0x%016lx ctrl: 0x%016lx\n",
> +                             i, msr_pair[i].counter, msr_pair[i].control);
> +    }
> +    /*
> +     * The configuration of the fixed counter is 4 bits each in the
> +     * MSR_CORE_PERF_FIXED_CTR_CTRL.
> +     */
> +    val = core2_vpmu_cxt->ctrls[MSR_CORE_PERF_FIXED_CTR_CTRL_IDX];
> +    mask = (1 << FIXED_CTRL_CTRL_CONF_WIDTH) - 1;
> +    for ( i = 0; i < core2_fix_counters.num; i++ )
> +    {
> +        if ( core2_vpmu_cxt->pmu_enable->fixed_ctr_enable[i] )
> +            printk("      fixed_%d:   0x%016lx ctrl: 0x%lx\n",
> +                             i, core2_vpmu_cxt->fix_counters[i], val & mask);
> +	val >>= FIXED_CTRL_CTRL_CONF_WIDTH;
> +    }
> +}
> +
>  static int core2_vpmu_do_interrupt(struct cpu_user_regs *regs)
>  {
>      struct vcpu *v = current;
> @@ -751,7 +805,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
>  };
>  
>  static void core2_no_vpmu_do_cpuid(unsigned int input,
> Index: xen-unstable.hg/xen/arch/x86/hvm/vpmu.c
> ===================================================================
> --- xen-unstable.hg.orig/xen/arch/x86/hvm/vpmu.c
> +++ xen-unstable.hg/xen/arch/x86/hvm/vpmu.c
> @@ -154,3 +154,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);
> +}
> +
> Index: xen-unstable.hg/xen/include/asm-x86/hvm/vpmu.h
> ===================================================================
> --- xen-unstable.hg.orig/xen/include/asm-x86/hvm/vpmu.h
> +++ xen-unstable.hg/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);

> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

      reply	other threads:[~2013-03-27 15:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-26 11:16 [PATCH-v2] vpmu intel: Add cpuid handling when vpmu disabled Dietmar Hahn
2013-03-26 11:45 ` Keir Fraser
2013-03-27 14:13   ` [PATCH 1/3] vpmu intel: Better names and replacing numerals with defines Dietmar Hahn
2013-04-04 12:10     ` Dietmar Hahn
2013-04-05 13:34       ` Konrad Rzeszutek Wilk
2013-03-27 14:13   ` [PATCH 3/3] vpmu intel: Dump vpmu infos in 'q' keyhandler Dietmar Hahn
2013-03-27 15:16     ` Konrad Rzeszutek Wilk [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130327151631.GA5759@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=dietmar.hahn@ts.fujitsu.com \
    --cc=eddie.dong@intel.com \
    --cc=jun.nakajima@intel.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.