All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <Andrew.Cooper3@citrix.com>
To: Tamas K Lengyel <tamas.lengyel@intel.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Jan Beulich <jbeulich@suse.com>,
	Roger Pau Monne <roger.pau@citrix.com>, Wei Liu <wl@xen.org>,
	Jun Nakajima <jun.nakajima@intel.com>,
	Kevin Tian <kevin.tian@intel.com>,
	Tamas K Lengyel <tamas@tklengyel.com>,
	George Dunlap <George.Dunlap@citrix.com>
Subject: Re: [PATCH v2] x86/mem_sharing: support forks with active vPMU state
Date: Thu, 21 Jul 2022 12:03:26 +0000	[thread overview]
Message-ID: <cb26974c-2eb1-d27b-9de2-cbd3b501cb62@citrix.com> (raw)
In-Reply-To: <a8a66208064c209e65c08380c59bc6aeff5f57f8.1658340502.git.tamas.lengyel@intel.com>

On 20/07/2022 19:47, Tamas K Lengyel wrote:
> diff --git a/xen/arch/x86/cpu/vpmu_amd.c b/xen/arch/x86/cpu/vpmu_amd.c
> index 9bacc02ec1..4c76e24551 100644
> --- a/xen/arch/x86/cpu/vpmu_amd.c
> +++ b/xen/arch/x86/cpu/vpmu_amd.c
> @@ -518,6 +518,14 @@ static int cf_check svm_vpmu_initialise(struct vcpu *v)
>      return 0;
>  }
>  
> +#ifdef CONFIG_MEM_SHARING
> +static int cf_check amd_allocate_context(struct vcpu *v)
> +{
> +    ASSERT_UNREACHABLE();

What makes this unreachable?

I know none of this is tested on AMD, but it is in principle reachable I
think.

I'd just leave this as return 0.  It will be slightly less rude to
whomever adds forking support on AMD.

> +    return 0;
> +}
> +#endif
> +
>  static const struct arch_vpmu_ops __initconst_cf_clobber amd_vpmu_ops = {
>      .initialise = svm_vpmu_initialise,
>      .do_wrmsr = amd_vpmu_do_wrmsr,
> @@ -527,6 +535,10 @@ static const struct arch_vpmu_ops __initconst_cf_clobber amd_vpmu_ops = {
>      .arch_vpmu_save = amd_vpmu_save,
>      .arch_vpmu_load = amd_vpmu_load,
>      .arch_vpmu_dump = amd_vpmu_dump,
> +
> +#ifdef CONFIG_MEM_SHARING
> +    .allocate_context = amd_allocate_context

Trailing comma please, and in the Intel structure.

> +#endif
>  };
>  
>  static const struct arch_vpmu_ops *__init common_init(void)
> diff --git a/xen/arch/x86/cpu/vpmu_intel.c b/xen/arch/x86/cpu/vpmu_intel.c
> index 8612f46973..01d4296485 100644
> --- a/xen/arch/x86/cpu/vpmu_intel.c
> +++ b/xen/arch/x86/cpu/vpmu_intel.c
> @@ -282,10 +282,17 @@ static inline void __core2_vpmu_save(struct vcpu *v)
>      for ( i = 0; i < fixed_pmc_cnt; i++ )
>          rdmsrl(MSR_CORE_PERF_FIXED_CTR0 + i, fixed_counters[i]);
>      for ( i = 0; i < arch_pmc_cnt; i++ )
> +    {
>          rdmsrl(MSR_IA32_PERFCTR0 + i, xen_pmu_cntr_pair[i].counter);
> +        rdmsrl(MSR_P6_EVNTSEL(i), xen_pmu_cntr_pair[i].control);
> +    }
>  
>      if ( !is_hvm_vcpu(v) )
>          rdmsrl(MSR_CORE_PERF_GLOBAL_STATUS, core2_vpmu_cxt->global_status);
> +    /* Save MSR to private context to make it fork-friendly */
> +    else if ( mem_sharing_enabled(v->domain) )
> +        vmx_read_guest_msr(v, MSR_CORE_PERF_GLOBAL_CTRL,
> +                           &core2_vpmu_cxt->global_ctrl);

/sigh.  So we're also not using the VMCS perf controls either.

That wants fixing too, but isn't a task for now.

Everything else LGTM.

~Andrew

  parent reply	other threads:[~2022-07-21 12:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-20 18:47 [PATCH v2] x86/mem_sharing: support forks with active vPMU state Tamas K Lengyel
2022-07-21 10:19 ` Jan Beulich
2022-07-21 12:31   ` Tamas K Lengyel
2022-07-21 12:03 ` Andrew Cooper [this message]
2022-07-21 12:35   ` Tamas K Lengyel
2022-07-22 10:54     ` VMCS perf, Was: " Andrew Cooper

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=cb26974c-2eb1-d27b-9de2-cbd3b501cb62@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=George.Dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=roger.pau@citrix.com \
    --cc=tamas.lengyel@intel.com \
    --cc=tamas@tklengyel.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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.