All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH 05/10] x86/msr: Compile out unused logic/objects
Date: Thu, 27 Feb 2020 10:37:37 +0000	[thread overview]
Message-ID: <8730f07d-decd-7ed1-b07b-ce3af000c0ca@citrix.com> (raw)
In-Reply-To: <88c175bc-ebeb-c40b-fc4e-5e175706c3af@suse.com>

On 27/02/2020 08:07, Jan Beulich wrote:
> On 26.02.2020 21:22, Andrew Cooper wrote:
>> @@ -76,16 +77,27 @@ void __init init_guest_msr_policy(void)
>>  {
>>      calculate_raw_policy();
>>      calculate_host_policy();
>> -    calculate_hvm_max_policy();
>> -    calculate_pv_max_policy();
>> +
>> +    if ( IS_ENABLED(CONFIG_PV) )
>> +        calculate_pv_max_policy();
>> +
>> +    if ( hvm_enabled )
>
> Any chance of talking you into doing things more symmetrically,
> by either also using IS_ENABLED(CONFIG_HVM) here or ...
>
>> +        calculate_hvm_max_policy();
>>  }
>>  
>>  int init_domain_msr_policy(struct domain *d)
>>  {
>> -    struct msr_policy *mp =
>> -        xmemdup(is_pv_domain(d) ?  &pv_max_msr_policy
>> -                                : &hvm_max_msr_policy);
>> +    struct msr_policy *mp = is_pv_domain(d)
>> +        ? (IS_ENABLED(CONFIG_PV)  ?  &pv_max_msr_policy : NULL)
>> +        : (IS_ENABLED(CONFIG_HVM) ? &hvm_max_msr_policy : NULL);
> ... (imo preferably) hvm_enabled here? Either way
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

The asymmetry is deliberate.

In the former hunk, hvm_enabled is short-circuited to false for
!CONFIG_HVM, and if I don't use hvm_enabled, here, then I've got to
retain the logic at the top of calculate_hvm_max_policy().  That seems
silly.

In this later hunk, we are looking for the most efficient way to allow
the compiler to discard the reference to hvm_max_msr_policy.  Using
hvm_enabled would be logically equivalent, but compile to more code in
CONFIG_HVM case, as it is a real boolean needing checking.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2020-02-27 10:37 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 20:22 [Xen-devel] [PATCH 00/10] x86: Default vs Max policies Andrew Cooper
2020-02-26 20:22 ` [Xen-devel] [PATCH 01/10] x86/sysctl: Don't return cpu policy data for compiled-out support (2) Andrew Cooper
2020-02-27  7:38   ` Jan Beulich
2020-02-27  9:33     ` Andrew Cooper
2020-02-27  9:40       ` Jan Beulich
2020-02-27 16:24         ` Andrew Cooper
2020-02-26 20:22 ` [Xen-devel] [PATCH 02/10] tools/libxc: Simplify xc_get_static_cpu_featuremask() Andrew Cooper
2020-02-27  7:47   ` Jan Beulich
2020-02-27  9:55     ` Andrew Cooper
2020-02-27 16:27       ` Andrew Cooper
2020-02-26 20:22 ` [Xen-devel] [PATCH 03/10] x86/gen-cpuid: Rework internal logic to ease future changes Andrew Cooper
2020-02-27  7:57   ` Jan Beulich
2020-02-27 10:08     ` Andrew Cooper
2020-02-26 20:22 ` [Xen-devel] [PATCH 04/10] x86/gen-cpuid: Create max and default variations of INIT_*_FEATURES Andrew Cooper
2020-02-27  8:02   ` Jan Beulich
2020-02-27 10:29     ` Andrew Cooper
2020-02-27 10:34       ` Jan Beulich
2020-02-26 20:22 ` [Xen-devel] [PATCH 05/10] x86/msr: Compile out unused logic/objects Andrew Cooper
2020-02-27  8:07   ` Jan Beulich
2020-02-27 10:37     ` Andrew Cooper [this message]
2020-02-27 11:24       ` Jan Beulich
2020-02-26 20:22 ` [Xen-devel] [PATCH 06/10] x86/msr: Introduce and use default MSR policies Andrew Cooper
2020-02-27  8:11   ` Jan Beulich
2020-02-26 20:22 ` [Xen-devel] [PATCH 07/10] x86/cpuid: Compile out unused logic/objects Andrew Cooper
2020-02-27  8:12   ` Jan Beulich
2020-02-26 20:22 ` [Xen-devel] [PATCH 08/10] x86/cpuid: Introduce and use default CPUID policies Andrew Cooper
2020-02-27  8:19   ` Jan Beulich
2020-02-27 10:55     ` Andrew Cooper
2020-02-27 11:29       ` Jan Beulich
2020-02-26 20:22 ` [Xen-devel] [PATCH 09/10] x86/gen-cpuid: Distinguish default vs max in feature annotations Andrew Cooper
2020-02-27  8:21   ` Jan Beulich
2020-02-26 20:22 ` [Xen-devel] [PATCH 10/10] x86/hvm: Do not enable MPX by default Andrew Cooper
2020-02-27  8:23   ` Jan Beulich

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=8730f07d-decd-7ed1-b07b-ce3af000c0ca@citrix.com \
    --to=andrew.cooper3@citrix.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.