All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <Andrew.Cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Wei Liu <wl@xen.org>, Roger Pau Monne <roger.pau@citrix.com>,
	"Tim (Xen.org)" <tim@xen.org>,
	George Dunlap <George.Dunlap@citrix.com>
Subject: Re: [PATCH 07/11] x86/shadow: L2H shadow type is PV32-only
Date: Fri, 6 Jan 2023 01:31:44 +0000	[thread overview]
Message-ID: <a3b7631c-07e7-455b-3531-c33ce435521b@citrix.com> (raw)
In-Reply-To: <2743393d-852d-b385-9eba-e22806b1c4af@suse.com>

On 05/01/2023 4:05 pm, Jan Beulich wrote:
> Like for the various HVM-only types, save a little bit of code by suitably
> "masking" this type out when !PV32.

add/remove: 0/1 grow/shrink: 2/4 up/down: 544/-922 (-378)
Function                                     old     new   delta
sh_map_and_validate_gl2e__guest_4            136     666    +530
sh_destroy_shadow                            289     303     +14
sh_clear_shadow_entry__guest_4               178     176      -2
sh_validate_guest_entry                      521     472     -49
sh_map_and_validate_gl2he__guest_4           136       2    -134
sh_remove_shadows                           4757    4545    -212
validate_gl2e                                525       -    -525
Total: Before=3914702, After=3914324, chg -0.01%

Marginal...

>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> I wasn't really sure whether it would be worthwhile to also update the
> "#else" part of shadow_size(). Doing so would be a little tricky, as the
> type to return 0 for has no name right now; I'd need to move down the
> #undef to allow for that. Thoughts?

This refers to the straight deletion from sh_type_to_size[] ?

I was confused by that at first.  The shadow does have a size of 1.  Might

/*   [SH_type_l2h_64_shadow]  = 1,  PV32 only */

work better?  That leaves it clearly in there as a 1, but not needing
any further ifdefary.

> --- a/xen/arch/x86/mm/shadow/multi.c
> +++ b/xen/arch/x86/mm/shadow/multi.c
> @@ -859,13 +866,12 @@ do {
>      int _i;                                                                 \
>      int _xen = !shadow_mode_external(_dom);                                 \
>      shadow_l2e_t *_sp = map_domain_page((_sl2mfn));                         \
> -    ASSERT(mfn_to_page(_sl2mfn)->u.sh.type == SH_type_l2_64_shadow ||\
> -           mfn_to_page(_sl2mfn)->u.sh.type == SH_type_l2h_64_shadow);\
> +    ASSERT_VALID_L2(mfn_to_page(_sl2mfn)->u.sh.type);                       \
>      for ( _i = 0; _i < SHADOW_L2_PAGETABLE_ENTRIES; _i++ )                  \
>      {                                                                       \
>          if ( (!(_xen))                                                      \
>               || !is_pv_32bit_domain(_dom)                                   \
> -             || mfn_to_page(_sl2mfn)->u.sh.type != SH_type_l2h_64_shadow    \
> +             || mfn_to_page(_sl2mfn)->u.sh.type == SH_type_l2_64_shadow     \

Isn't this redundant with the ASSERT_VALID_L2() now?

Per your other question, yes this desperately wants rearranging, but I
would agree with it being another patch.

I did previously play at trying to simplify the PV pagetable loops in a
similar way.  Code-gen wise, I think the L2 loops what to calculate an
upper bound which is either 512, or compat_first_slot, while the L4
loops what an "if(i == 256) i += 7; continue;" rather than having
LFENCE-ing predicates on each iteration.

~Andrew

  reply	other threads:[~2023-01-06  1:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05 15:57 [PATCH 00/11] x86/shadow: misc tidying Jan Beulich
2023-01-05 15:59 ` [PATCH 01/11] x86/shadow: replace sh_reset_l3_up_pointers() Jan Beulich
2023-01-06  0:55   ` Andrew Cooper
2023-01-09  8:35     ` Jan Beulich
2023-01-05 15:59 ` [PATCH 02/11] x86/shadow: convert sh_audit_flags()'es 1st parameter to domain Jan Beulich
2023-01-05 15:59 ` [PATCH 03/11] x86/shadow: drop hash_vcpu_foreach() Jan Beulich
2023-01-05 16:00 ` [PATCH 04/11] x86/shadow: rename hash_domain_foreach() Jan Beulich
2023-01-05 16:04 ` [PATCH 05/11] x86/shadow: move bogus HVM checks in sh_pagetable_dying() Jan Beulich
2023-01-06  1:00   ` Andrew Cooper
2023-01-09  8:39     ` Jan Beulich
2023-01-05 16:04 ` [PATCH 06/11] x86/shadow: drop a few uses of mfn_valid() Jan Beulich
2023-01-06  1:02   ` Andrew Cooper
2023-01-09  8:42     ` Jan Beulich
2023-01-05 16:05 ` [PATCH 07/11] x86/shadow: L2H shadow type is PV32-only Jan Beulich
2023-01-06  1:31   ` Andrew Cooper [this message]
2023-01-09  9:12     ` Jan Beulich
2023-01-05 16:05 ` [PATCH 08/11] x86/shadow: reduce effort of hash calculation Jan Beulich
2023-01-06  2:03   ` Andrew Cooper
2023-01-09  9:48     ` Jan Beulich
2023-01-05 16:06 ` [PATCH 09/11] x86/shadow: simplify conditionals in sh_{get,put}_ref() Jan Beulich
2023-01-05 16:07 ` [PATCH 10/11] x86/shadow: correct shadow type bounds checks Jan Beulich
2023-01-05 16:07 ` [PATCH 11/11] x86/shadow: sh_remove_all_mappings() is HVM-only Jan Beulich
2023-01-06  2:03 ` [PATCH 00/11] x86/shadow: misc tidying Andrew Cooper

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=a3b7631c-07e7-455b-3531-c33ce435521b@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=George.Dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=tim@xen.org \
    --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.