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

Re: [RFC] Avoid dom0/HVM performance penalty from MSR access tightening


  • To: Alex Olson <this.is.a0lson@xxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 11 Feb 2022 09:28:13 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=b3xRSDw9VHcQZ0WCaVPEyvGTc+1tW1q+fKCin7xhoH0=; b=Hx2Q6GPoyIkFnMbEZeHLQVubDaC4pJm3Du/E7B/3QxPdO8wbl7uhYLNlJI/tfeGf6pbgnH6fnyvd0hrsPhfJhLnBA5GkLsh2nearYjSNuPs6r2J84wY5nz34BRSVvxRmJEDcgRJENeza6fpHjAagB2GaJi1Mr7sML289tWNb+cN+aEkq/iQgHQG1KhSLgj48LcMh3JzTaCPz7M1ubMyAt3gjhtFMnZpt1WVQrGFgcdt6ey5kFBZro0H8Jmk21kVZK7cp5TvlJzb9qKLmC8NmytTKkRoCCKen8MHqZBd2Mi17SIp0wE5ohJcpHsam2mTPFORH7lwAxlptH6N2exVLtA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q+ak/mGk77ZtzO66o8bW2plIlyxQLPHuxL+zwFFb7BjPCbzwtq3m7/ZcAeOXchrP1jhWx3qlbOa5BFO2Mro3GDj6JQpcWBplBu05tB4UqtxW8MroRlzS3CR/cas8r8pj0OVMeVg3DR1HTSbW+Qv3zn72DkuZ+f1H7j6B9abVgVIL1/wiyoVPD8UukBOU4DKwO4zWyQWwYvFw1Y/6Lkk9C9H2ABICh8drivDdZ/j/ASEZBY9fYezGkvRV1FyfNX8cOdyy9ZoM4Mz2xN9KzibsLx5FI9oGbveXiP0e+IEFdvsJlBP4knedIP7XvxTTQ2S+FvBRgGbxTEVVJ4wO4dxV6w==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 11 Feb 2022 08:28:51 +0000
  • Ironport-data: A9a23:4nem9KmLjOu16kLMUCMJTALo5gxWIURdPkR7XQ2eYbSJt1+Wr1Gzt xJODW/QaPaCMGT1eN13PY/n904H7cKEz9BiSgc9rXg2QSMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BClVlxJVF/fngqoDUUYYoAQgsA180IMsdoUg7wbRh2Ncx2YHR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 Nxtt4PralopB4vNvsAACkZ5EwtAEqITrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBNPsM44F/Glp0BnSDOo8QICFSKLPjTNd9Glr15EfR6+ED yYfQR5lVT/lZT1EA3A0KZgE3+DxqyX6VxQN/Tp5ooJoujOOnWSdyoPFINfTP9CHW8hRtkKZv X7duXT0BAkAM96SwibD9Wij7sfTnSLgHoMJUrTg8uVthnWcw2USDFsdUl7TnBWiohfgAZQFc RVSo3dw6/hpnKC2cjXjdxSYomHfnUMcYvxRNcknsV6syoDqzAnMUwDoUQV9QNAhscY3Qxkj2 VmIg87lCFRTjVGFdZ6O3uzK9G3vYED5OUdHPHZZFlVdv7EPtalu1kqnczp1LEKiYjQZ8xnUy ivCkiUxjq57YSUjh/TipgCvb95BS/H0ou8J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fV8pRtgdPkjv9OHtaFhMQ5IijlziyoeINicbufuy1dmpDl1H8a1P 335zswNcV67H3cOkmzvBvWwgHllA0j7nfzoGXo9kfLkIjcfnYXGsBBjYVWfl/y8Ew7puxx16 pNwiawq4dXJQmoplWz2/H4EzVR0makq3srluAey1ZFV5EFVbNXpYsDuGtIDZY7Gj7g4oxPKp gjMCjl3ocWTbqmVQGYgoE2q+bcHUjbXy32D3Tqg/blnQS/xxtCvgklLM92pAZ1yHtycegA2w 3+CNUZqFh5dL5iUUtMPpZxfSKJMB2/ffvtChPlHb21LtBPB5ryw6SHkondotvaPKA18A==
  • Ironport-sdr: 6xMvbttvqKLb9I+rpKZo2zJqYdzfS4jZ5kU9gCyO6/9OW2Rd0lXuyaa2DfyAuX9A5GcfUloY61 WFzZvQftHv/BXY0UapCGxGMsTo9GOfdCBLxmyoYqKaZBK+ETOHZvbEtbCEIPcHUOuQJLVpgGgn JIDYL7BHaAQYZ8kX1iuYOv/kM3MNm+V7VN9IC0WEH10yU+sAP8ZplXKHXSMB5Han5VP6OlAt7o 45Wwb+diRky4o5tE4YPb8uLB9Ipxkaya58yeve/6VQpRUaBOZObYhuAfJJRQe8wTC40c475/yR qD92Dxko7luNMxUvC32XEUNc
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Feb 10, 2022 at 11:27:15AM -0600, Alex Olson wrote:
> I'm seeing strange performance issues under Xen on a Supermicro server with a 
> Xeon D-1541 CPU caused by an MSR-related commit.
> 
> Commit 322ec7c89f6640ee2a99d1040b6f786cf04872cf 'x86/pv: disallow access to 
> unknown MSRs'
> surprisingly introduces a severe performance penality where dom0 has about 
> 1/8th
> the normal CPU performance. Even even when 'xenpm' is used to select the
> performance governor and operate the CPU at maximum frequency, actual CPU
> performance is still 1/2 of normal (as well as using 
> "cpufreq=xen,performance").
> 
> The patch below fixes it but I don't fully understand why.
> 
> Basically, when *reads* of MSR_IA32_THERM_CONTROL are blocked, dom0 and
> guests (pinned to other CPUs) see the performance issues.

You only mention MSR_IA32_THERM_CONTROL here...

> For benchmarking purposes, I built a small C program that runs a "for
> loop" 
> 4Billion iterations and timed its execution. In dom0, the
> performance issues
> also cause HVM guest startup time to go from 9-10
> seconds to almost 80 seconds.
> 
> I assumed Xen was managing CPU frequency and thus blocking related MSR
> access by dom0 (or any other domain). However,  clearly something else
> is happening and I don't understand why.
> 
> I initially attempted to copy the same logic as the write MSR case. This
> was effective at fixing the dom0 performance issue, but still left other
> domains running at 1/2 speed. Hence, the change below has no access control.
> 
> 
> If anyone has any insight as to what is really happening, I would be all ears
> as I am unsure if the change below is a proper solution.
> 
> Thanks
> 
> -Alex
> 
> ---
> ---
>  xen/arch/x86/pv/emul-priv-op.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c
> index 7f4279a051..f254479bda 100644
> --- a/xen/arch/x86/pv/emul-priv-op.c
> +++ b/xen/arch/x86/pv/emul-priv-op.c
> @@ -970,6 +970,18 @@ static int read_msr(unsigned int reg, uint64_t *val,
>          *val = 0;
>          return X86EMUL_OKAY;
>  
> +    /* being unable to read MSR_IA32_THERM_CONTROL seems to significantly 
> affect
> +     * dom0 and thus HVM guest startup performance, as well as PVH VMs.
> +     */
> +    case MSR_IA32_THERM_CONTROL:
> +    case MSR_IA32_ENERGY_PERF_BIAS:

...yet in the patch you also allow access to
MSR_IA32_ENERGY_PERF_BIAS, which makes me wonder whether
MSR_IA32_THERM_CONTROL is the only required one.

It could help to post full logs Xen + Linux dmesgs.

Is this reproducible with different Linux versions?

Thanks, Roger.



 


Rackspace

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