[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: Wed, 23 Feb 2022 17:11:50 +0100
  • 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=yanYrsGJL/uOVrabryc0fZ4FDX9w63P6n48/TQkTPlk=; b=ZAcOr0GevjZgNef2NCivQ09UYgSjf1wWXzS7m/WBN5vd7fR9L30gFcc3l/vC4hi1Z2W21aLUSaEopf6o+5Mh+Dx8sp6cM/kPfflBYYqjyG7fnmnIra7Tij5CqiTO8kNSlhp3IlIzeXGQusmTlWmnaD1/5lZgOPiIMw5EW7k+B4dTPKoWFtinLxfCZARIu0QGn6r9LBFHLH4wQlTZyE02JrkHO1YGhXFp4vOKns1h0an53HVJmAkiiun6Y1WRhFtYlAC5M9SLh7gF7efKqwi3pxmEKhvNLgaCSs1lzc4MpXBcKSG8WXZtBhx62PBm6Qqi1JUr2otDo8vKrwu6BdS4HA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dm0VmABYKOvW7td/RVFj6m7TkdsOvsAKcPbhs3mpXLhJPX9znC0lyMaWVQ8/swBPtAB/5GRuIPA1iCI1XCMMYtUiGaZqMSZPxOreFolr0yQnzxyOIjGSkNR12wUa68T+CGGvxc3I9SzGV0hskE8m3gQizcN2bZ5OfmrXZ5ebY52kmw64GEN2P0gzkCECLwgXbmyzqHfJRTnWVzABLZX2F5nOiKnIwbJ7jcM2LwaDWTmNODsKB1ZEQA318Wu5IApEF4gDIDMREC+wejIATK4hd0FE6yx1GOjac85UsTrMNTPPNBvEiYQvOMYx7enBAcq+kdo9Pc1wOAbakg5yvsyToA==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 23 Feb 2022 16:12:08 +0000
  • Ironport-data: A9a23:mBGom6yFoI1sKJGK5UR6t+c/xirEfRIJ4+MujC+fZmUNrF6WrkVVy WJLWWDXaf3bY2rxctAjOoS3o0lVvMCDy4ViS1ForCAxQypGp/SeCIXCJC8cHc8zwu4v7q5Dx 59DAjUVBJlsFhcwnj/0bv656yMUOZigHtIQMsadUsxKbVIiGHdJZS5LwbZj2NYy24PhWWthh PupyyHhEA79s9JLGjp8B5Kr8HuDa9yr5Vv0FnRnDRx6lAe2e0s9VfrzFonoR5fMeaFGH/bSe gr25OrRElU1XfsaIojNfr7TKiXmS1NJVOSEoiI+t6OK2nCuqsGuu0qS2TV1hUp/0l20c95NJ Npl9qyoEQUzNJL1tc8NUQtJUApAYYZl0eqSSZS/mZT7I0zudnLtx7NlDV0sPJ1e8eFyaY1M3 aVGcnZXNEnF3r/ohuLgIgVvrp1LwM3DJoQQt2sm1TjEJf0nXYrCU+PB4towMDIY2JwUQ6iHO ppxhTxHMj6aYQ9NOnUuM58Tt+Op1yf0cQEJkQfAzUYwyzeKl1EguFT3C/LFd9rPSchLk0Kwo mPd43+/EhwcLMaYyzeO7jSrnOCntT/7WZlUFab+/6Zum1qV7mMWARwSE1C8pJGEZlWWAowFb RZOo2x38PZ0pBfDosTBswOQ406c5hwGUeVpPsYq6hOciYHqvy26Lz1RJtJeU+AOuMgzTD0s8 1aGmdL1GDBi2IGopWKhGqS89m3rZ3VMRYMWTWpdFFZevYG/yG0mpk+XFr5e/LiJYsoZ8N0a6 xSDt2AAiroalqbnPI3rrAmc01pASnUkJzPZBzk7vEr4tmuVh6b/PuREDGQ3C94acO51qXHb4 RA5dzC2trxmMH10vHXlrB8xNL+o/e2ZFzbXnERiGZIsnxz0pSL+IN0OuGEkeBg5WirhRdMPS BWP0e+2zMUOVEZGkIctO97hYyjU5fKI+SvZugD8MYMVP8kZmP6v9yByf0+At10BY2B3+ZzTz ayzKJ72ZV5DUPwP5GPvG481jO96rghjlDi7bc2qkHyaPU+2OSf9pUEtawDVMIjULcqs/W3oz jqoH5HUk04GCLWmOEE6M+c7dDg3EJTyPrivw+R/fe+fOAt2XmYnDv7a27Q6fIJ52a9Sk4/1E ruVACe0FHKXaaX7FDi3
  • Ironport-hdrordr: A9a23:FGqhw6HXRh1aaZ+GpLqFBJHXdLJyesId70hD6qkvc3Nom52j+/ xGws536faVslcssHFJo6HmBEClewKnyXcV2/hrAV7GZmfbUQSTXeNfBOfZsljd8mjFh5NgPM RbAtZD4b/LfCFHZK/BiWHSebZQo+VvsprY/ds2p00dMj2CAJsQiTuRZDzrdnGfE2J9dOYE/d enl4N6jgvlXU5SQtWwB3EDUeSGj9rXlKj+aRpDIxI88gGBgR6h9ba/SnGjr1wjegIK5Y1n3X nOkgT/6Knmm/anyiXE32uWy5hNgtPuxvZKGcTJoMkILTfHjBquee1aKvW/lQFwhNvqxEchkd HKrRtlF8Nv60nJdmXwmhfp0xmI6kdb11bSjXujxVfzq83wQzw3T+Bbg5hCTxff4008+Plhza NixQuixtZqJCKFuB64y8nDVhlsmEbxi2Eli/Qvg3tWVpZbQKNNrLYY4FheHP47bW/HAbgcYa dT5fznlbdrmQvwVQGYgoAv+q3nYp0LJGbIfqBY0fblkAS/nxhCvj4lLYIk7zU9HakGOul5Dt T/Q9VVfY51P7wrhIJGdZA8qJiMexrwqSylChPhHb2gLtBDB07w
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Feb 23, 2022 at 09:38:56AM -0600, Alex Olson wrote:
> I appreciate your interest, apologies for not replying right away. I've been
> digging deeper to have a more meaningful resposne.
> 
> I had attempted to instrument the MSR reads, but only saw a small number reads
> being blocked by the code change. They appear to be the list below and the
> others seem fairly harmless:
> 
> 0x00000034    MSR_SMI_COUNT
> 0x0000019a    IA32_CLOCK_MODULATION/MSR_IA32_THERM_CONTROL MSR
> 0x000003f8    MSR_PKG_C3_RESIDENCY
> 0x000003f9    MSR_PKG_C6_RESIDENCY
> 0x000003fa    MSR_PKG_C7_RESIDENCY
> 0x00000606    MSR_RAPL_POWER_UNIT
> 0x0000060d    MSR_PKG_C2_RESIDENCY
> 0x00000611    MSR_PKG_ENERGY_STATUS
> 0x00000619    MSR_DRAM_ENERGY_STATUS
> 0x00000630    MSR_PKG_C8_RESIDENCY
> 0x00000631    MSR_PKG_C9_RESIDENCY
> 0x00000632    MSR_PKG_C10_RESIDENCY
> 0x00000639    MSR_PP0_ENERGY_STATUS
> 0x00000641    MSR_PP1_ENERGY_STATUS
> 
> As for my test program, it is just a crude loop compiled with "gcc -O3",
> normally takes about 10 seconds to execute:
> int main()
> {
>     for (volatile int i=1; i!=0; ++i){}
>     return 0;
> }
> 
> The relative changes in execution time of the test program and also that  HVM
> guest startup time (associated with the "qemu" process being busy) completely
> agreed.  I also observed the same changes under a PVH guest for the test
> program.
> 
> Thus, it seemed like the CPU was somehow operating a different frequency than
> expected, rather than faults consuming execution time.
> 
> -- (after a lot more investigation) --
> 
> Further instrumentation showed that the
> IA32_CLOCK_MODULATION/MSR_IA32_THERM_CONTROL MSR initially had value
> "0x10"  which appears to be invalid both in the Intel Software Developer's
> manual and what I think I'm seeing in the ACPI tables.
> 
> In dom0 Linux 5.2.38,  this value seems to have caused the
> acpi_processor_get_throttling_ptc() function to see an invalid result from
> acpi_get_throttling_state() and thus execute __acpi_processor_set_throttling()
> which wrote the MSR with a value of zero and had the side effect of disabling
> throttling (restoring normal performance).  (This all happened as the CPUs 
> were
> detected).
> 
> When the unknown MSR reads are blocked, the call to
> __acpi_processor_set_throttling() did not occur since the MSR read did not
> result in the invalid value -- thus the CPU remained in a throttling state.
> 
> So far, this seems to explain the dom0 performance issues I saw.
> 
> The domU observation was related... In some of my testing, dom0 was limited 
> (via
> Xen command-line) to a small number of cores so that the others could be
> dedicated to other domains.  When a domU VM was launched on the others (not 
> used
> by dom0), its MSR remained at the original value resulting in low performance
> since dom0 hadn't a chance to rewrite it...   Thus, I saw different domU
> behavior based on the number of cores allocated to dom0.
> 
> 
> -- summary --
> 
> In desparation, I ended up resetting BIOS settings to defaults and 
> mysteriously
> this issue doesn't occur anymore.  Not sure what could have gone wrong before 
> as
> the original settings were not far from defaults.  It seems my issues stemmed
> from the server's BIOS setting the throttling MSR to an invalid value but it 
> had
> illuminated some unusual behaviors under Xen...
> 
> It seems to me there are a few findings useful to the Xen developers from
> venturing down this rabbithole:
> 
> 1) For conditions in which MSR registers are writeable from PV guests (such as
> dom0),  they should probably be readable well, looks like 
> MSR_IA32_THERM_CONTROL
> is currently one of a small number of "unreadable" but writeable
> MSRs.  Otherwise seemingly valid read-(check/modify)-write operations will
> behave incorrectly under Xen.

So it's one of those MSRs that's only writable when dom0 has it's
vCPUs pinned. We could allow dom0 to read from it in that case (that's
an oversight of the MSR handling rework), but it would seem better to
just remove access to it altogether: it's bogus to allow dom0 to play
with the MSR in the first place IMO, and it won't really solve issues
like the one reported here unless dom0 vCPUs == pCPUs and all are
pinned, so that dom0 can fix the MSR in all CPUs.

Thanks, Roger.



 


Rackspace

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