[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for-4.17 v4 2/2] amd: remove VIRT_SC_MSR_HVM synthetic feature
- To: Roger Pau Monne <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
- Date: Tue, 15 Nov 2022 16:21:07 +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=MplvytQ/0P+vTrUB/Js1KPcOExHp+Rr+0ASILNrxPiI=; b=W/bfhsToHAPp1wPdavxEHqMOG5k1Jzp81IiW12M15N+UXq+7GT0a0xgi1E8XwzRL3T095oGJgW4BCMJgxUKSCfjpzOMA92cw17BqK4eaO4JEK/clh59f/JhbkoKZd+22fggoGpJDSHlmZDSptprlqOtboc8Gf8ze/n+wO7cj2eDXqmQ5oZ/aZPiFuYVqkJi3wTic8G1InyEEQSRfgrTWu3lpmF9x2yRiPLM1kqAhE2A+0rdX2O1reGIJuist7zEGeXx+BeupnY71cZh/O1yzW8NnXQzasWeqK+SE5IL5V4NY86/9/5Sj4tuedKul/KQBZWdPvGnKMUUd5O8DQp6wVg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OOzUZuimBL5jn0Qe50rpZV+EPwGQIS+M37d4mhbKiGIlRuyCSusOUQ92Bnpu+1sVov2WLtq01vWN3RiytZmKx9R50cxicLniTdTMugk87jhf/Vh8VSRJokug+mi4cvdamSJX9nuVu26qHbKJNxyLtOrIRaKFZ/mXQJZDiPgArSY5Y22Ipm7NAoR0jav6KeonJX4DWCl8Klg8wUcqF82jKezgIEPPiVgn1QDG+BbecBFP+MR16JrcoRzctx6x7Xh+d2QkmTqeLXcJI9hAGsIMVXjsVmt2fdNhvtybkSJCx49rkNp55T6Pn2Hi6RWw9Gkmi69kirjTicxlK7UcnNQmAw==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: "Henry.Wang@xxxxxxx" <Henry.Wang@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Tue, 15 Nov 2022 16:21:46 +0000
- Ironport-data: A9a23:5dTmB6sp5cfIxESxovUe76DwoOfnVGhfMUV32f8akzHdYApBsoF/q tZmKWnUOf6Damumf9x2boy28B5SvZCAzdJiGVA6/nozFCkS+JbJXdiXEBz9bniYRiHhoOCLz O1FM4Wdc5pkJpP4jk3wWlQ0hSAkjclkfpKlVKiffHg0HVU/IMsYoUoLs/YjhYJ1isSODQqIu Nfjy+XSI1bg0DNvWo4uw/vrRChH4bKj5lv0gnRkPaoR5QaHyiFPZH4iDfrZw0XQE9E88tGSH 44v/JnhlkvF8hEkDM+Sk7qTWiXmlZaLYGBiIlIPM0STqkAqSh4ai87XB9JFAatjsB2bnsgZ9 Tl4ncfYpTHFnEH7sL91vxFwS0mSNEDdkVPNCSDXXce7lyUqf5ZwqhnH4Y5f0YAwo45K7W9yG fMwCHMVVgGCue2P+b+edvJwnsgSEMixM9ZK0p1g5Wmx4fcOZ7nmGvyPzvgBmTA6i4ZJAOrUY NcfZXx3dhPcbhZTO1ARTpUjgOOvgXq5eDpdwL6XjfNvvy6Pk0osjv60b4O9lt+iHK25mm6xo G7c8nu/KRYdLNGFkhKO8262h/+JliT+MG4XPO3nqqY10QTProAVIBoJbRimmtygsRGvUvtNF 2we3A08grdnoSRHSfG4BXVUukWsrhM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Tr1qumuGjexxe701lU
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHY+PYG7JqnYiwdr0usZ0w09l5ina5AKpoA
- Thread-topic: [PATCH for-4.17 v4 2/2] amd: remove VIRT_SC_MSR_HVM synthetic feature
On 15/11/2022 13:26, Roger Pau Monne wrote:
> Since the VIRT_SPEC_CTRL.SSBD selection is no longer context switched
> on vm{entry,exit} there's no need to use a synthetic feature bit for
> it anymore.
>
> Remove the bit and instead use a global variable.
>
> No functional change intended.
>
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
> Release-acked-by: Henry Wang <Henry.Wang@xxxxxxx>
This is definitely not appropriate for 4.17, but it's a performance
regression in general, hence my firm and repeated objection to this
style of patch.
General synthetic bits have existed for several decades longer than
alternatives. It has never ever been a rule, or even a recommendation,
to aggressively purge the non-alternative bits, because it's a provably
bad thing to do.
You are attempting a micro-optimisation, that won't produce any
improvement at all in centuries, while...
> diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
> index a332087604..9e3b9094d3 100644
> --- a/xen/arch/x86/cpu/amd.c
> +++ b/xen/arch/x86/cpu/amd.c
> @@ -49,6 +49,7 @@ boolean_param("allow_unsafe", opt_allow_unsafe);
> /* Signal whether the ACPI C1E quirk is required. */
> bool __read_mostly amd_acpi_c1e_quirk;
> bool __ro_after_init amd_legacy_ssbd;
> +bool __ro_after_init amd_virt_spec_ctrl;
... actually expending .rodata with something 8 times less efficiently
packed, and ...
>
> static inline int rdmsr_amd_safe(unsigned int msr, unsigned int *lo,
> unsigned int *hi)
> diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
> index 822f9ace10..acc2f606ce 100644
> --- a/xen/arch/x86/cpuid.c
> +++ b/xen/arch/x86/cpuid.c
> @@ -3,6 +3,7 @@
> #include <xen/param.h>
> #include <xen/sched.h>
> #include <xen/nospec.h>
> +#include <asm/amd.h>
... (Specific to this instance) making life harder for the people trying
to make CONFIG_AMD work, and ...
> diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
> index 4e53056624..0b94af6b86 100644
> --- a/xen/arch/x86/spec_ctrl.c
> +++ b/xen/arch/x86/spec_ctrl.c
> @@ -514,12 +514,12 @@ static void __init print_details(enum ind_thunk thunk,
> uint64_t caps)
> (boot_cpu_has(X86_FEATURE_SC_MSR_HVM) ||
> boot_cpu_has(X86_FEATURE_SC_RSB_HVM) ||
> boot_cpu_has(X86_FEATURE_IBPB_ENTRY_HVM) ||
> - boot_cpu_has(X86_FEATURE_VIRT_SC_MSR_HVM) ||
> + amd_virt_spec_ctrl ||
... breaking apart a single TEST instruction, which not only adds an
extra conditional merge, but now hits an cold-ish cache line everywhere
it's used.
Count how many synthetic feature bits it will actually take to change
the per-cpu data size, and realise that, when it will take more than 200
years at the current rate of accumulation, any believe that this is an
improvement to be had disappears.
Yes, it is only a micro regression, but you need a far better
justification than "there is a gain of 64 bytes per CPU which will be
non-theoretical in more than 200 years" when traded off vs the actual
512 bytes, plus extra code bloat bloat, plus reduced locality of data
that this "improvement" genuinely costs today.
~Andrew
|