All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <Andrew.Cooper3@citrix.com>
To: Roger Pau Monne <roger.pau@citrix.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Henry.Wang@arm.com" <Henry.Wang@arm.com>,
	Jan Beulich <jbeulich@suse.com>, Wei Liu <wl@xen.org>
Subject: Re: [PATCH for-4.17 v4 2/2] amd: remove VIRT_SC_MSR_HVM synthetic feature
Date: Tue, 15 Nov 2022 16:21:07 +0000	[thread overview]
Message-ID: <c698b1e2-c047-1197-9c26-2239ea56c30a@citrix.com> (raw)
In-Reply-To: <20221115132657.97864-3-roger.pau@citrix.com>

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@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> Release-acked-by: Henry Wang <Henry.Wang@arm.com>

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

  reply	other threads:[~2022-11-15 16:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15 13:26 [PATCH for-4.17 v4 0/2] amd/virt_ssbd: refactoring and fixes Roger Pau Monne
2022-11-15 13:26 ` [PATCH for-4.17 v4 1/2] amd/virt_ssbd: set SSBD at vCPU context switch Roger Pau Monne
2022-11-15 13:26 ` [PATCH for-4.17 v4 2/2] amd: remove VIRT_SC_MSR_HVM synthetic feature Roger Pau Monne
2022-11-15 16:21   ` Andrew Cooper [this message]
2022-11-15 16:44     ` Jan Beulich
2022-11-15 23:54       ` Andrew Cooper
2022-11-16  7:41         ` Jan Beulich
2022-11-16 10:11           ` Roger Pau Monné
2022-11-15 16:50     ` Roger Pau Monné
2022-11-16  0:27 ` [PATCH for-4.17 v4 0/2] amd/virt_ssbd: refactoring and fixes Andrew Cooper
2022-11-16  9:53   ` Roger Pau Monné

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=c698b1e2-c047-1197-9c26-2239ea56c30a@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Henry.Wang@arm.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.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.