[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

VMCS perf, Was: [PATCH v2] x86/mem_sharing: support forks with active vPMU state


  • To: Tamas K Lengyel <tamas@xxxxxxxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Fri, 22 Jul 2022 10:54:04 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=u+w0/tVtW6tFrWYY1ZR9/pMCOsgMzQV5sFVeVE8gFyw=; b=n4L/7oQGjqgG4v8O7vK/KwImjoUK7Yhgv5AtO4v8pDE7ztTsY8Io2F+beYV+KGobiSmJmKXMVUgHXNahOKPgbsNoi65Yk2Xnx+OBhkHvF3xGBsVSvh5j1rkMbuEHkxJ5co5MniqPS1zUc7MfOeLfnG/W/478QLV4wo3J1Dj5nErxKzjyzr0zhmb60qm1+DfClMtq7aZHtexmrp8xyWMs8niZrCdqUwH2hgxmL3BHDGuITOJI1TTStAjojLgwoO/fqxRelS0urqlexYeMSIFGPx1IoCgiSECPfmTsXSJYhI2cVQtrHGDf8Guzn0Aj0NcftIi9G+0tYyBe4pqngpjCng==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lr/Rfk3uVMzC/VUIHF2pWsMS8BK0FnzBXiH2zSftLw0QGEoLkt/znIi8cyzNunP5bRfMNmc1cUyOYp0mhICStA5xENfxAsVMnEaGeLbCMVgF5rFlvS3JK+sxLMhej/nRP4xnBeFTVcZbxdMtVpW0tBZHmhylthNBTp/4To256l+qMSX8MRgyJfEhAq2amthb78gUFpAJlj9XVTZ9WpFnMv+V78rK/88a7Gu6/RqTe89FU/SWdX2pIjSPfJNFG7lcwVSYfv75usbkJU0wpU76veM9WID3qmGNeTiGEFBrHU704AfnT6CSbU3cswkcePRf+1ycUtF3M+EQoPcUWpbSug==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Tamas K Lengyel <tamas.lengyel@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxx>
  • Delivery-date: Fri, 22 Jul 2022 10:54:38 +0000
  • Ironport-data: A9a23:FaZuYaMfDwEoOcHvrR1YlsFynXyQoLVcMsEvi/4bfWQNrUohhjMDx zEaCmuEP/2ON2Sjc4hzaty3/EsP75/TytBkGgto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdleF+lH3dOCJQUBUjcmgXqD7BPPPJhd/TAplTDZJoR94kqsyj5UAbeKRWmthg vuv5ZyEULOZ82QsaDhMtPjZ8EoHUMna41v0gHRvPZing3eG/5UlJMp3Db28KXL+Xr5VEoaSL woU5Ojklo9x105F5uKNyt4XQGVTKlLhFVHmZk5tc7qjmnB/Shkaic7XAha+hXB/0F1ll/gpo DlEWAfZpQ0BZsUgk8xFO/VU/r0X0QSrN9YrLFDm2fF/wXEqfFPw2NR2A2YZDLc/xeR0G0pj+ MMkEys0O0Xra+KemNpXS8FKr+F6dYzHGd1avXttizbEEfwhXJbPBb3Q4sNV1ysxgcYIGuvCY 80eanxkaxGojx9nYw9LTs5h2rr3wCCgLFW0q3rMzUYzy0HVwBZ8z/7GN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ehTMYd228LAu23FQgMyOeJP7dSueVVspj8ys5/0CH8yzYY fHBK5r
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYnGkyeHzLfYftlkqMXoeeKAYG062IuvCAgAAJBwCAAXXsgA==
  • Thread-topic: VMCS perf, Was: [PATCH v2] x86/mem_sharing: support forks with active vPMU state

On 21/07/2022 13:35, Tamas K Lengyel wrote:
> On Thu, Jul 21, 2022 at 8:03 AM Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx> 
> wrote:
>> On 20/07/2022 19:47, Tamas K Lengyel wrote:
>>> +#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.
> It does get saved and swapped on vmexit but we don't want to do this
> vmx_read/vmx_write in the mem_sharing codebase. It's much cleaner if
> this is saved into the vpmu context structure and reloaded from there,
> so we can just do a memcpy in mem_sharing without having to know the
> details.

This is specifically why I introduced the {pv,hvm}_{get,set}_reg()
interfaces.

Lots of callers want to operate on a specific register, without wanting
to know if it's live in an MSR, or in the VMCB, VMCS, MSR load/save
list, or in a random structure in memory.

This is a perfect example that wants converting.  One patch to move
MSR_CORE_PERF_GLOBAL_CTRL into the get/set reg infrastructure (no
practical change), and then a second patch to make the VT-x
implementation conditional between the MSR load/save lists and the VMCS
host/guest controls depending on hardware support.

~Andrew

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.