All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>,
	"George Dunlap" <george.dunlap@citrix.com>
Subject: [PATCH v2 2/2] x86/p2m: aid the compiler in folding p2m_is_...()
Date: Thu, 23 Jun 2022 13:54:40 +0200	[thread overview]
Message-ID: <7cce89f4-962e-bfbe-7d30-18fea7515bed@suse.com> (raw)
In-Reply-To: <5d6c927e-7d7c-5754-e7eb-65d1e70f6222@suse.com>

By using | instead of || or (in the negated form) && chances increase
for the compiler to recognize that both predicates can actually be
folded into an expression requiring just a single branch (via OR-ing
together the respective P2M_*_TYPES constants).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
RFC: The 3-way checks look to be a general problem for gcc, but even in
     some 2-way cases it doesn't manage to fold the expressions. Hence
     it's worth considering to go farther with this transformation, as
     long as the idea isn't disliked in general.
---
v2: Re-base over change to earlier patch.

--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -379,7 +379,7 @@ struct page_info *p2m_get_page_from_gfn(
             return page;
 
         /* Error path: not a suitable GFN at all */
-        if ( !p2m_is_ram(*t) && !p2m_is_paging(*t) && !p2m_is_pod(*t) &&
+        if ( !(p2m_is_ram(*t) | p2m_is_paging(*t) | p2m_is_pod(*t)) &&
              !mem_sharing_is_fork(p2m->domain) )
             return NULL;
     }
@@ -568,7 +568,7 @@ p2m_remove_entry(struct p2m_domain *p2m,
     for ( i = 0; i < (1UL << page_order); ++i )
     {
         p2m->get_entry(p2m, gfn_add(gfn, i), &t, &a, 0, NULL, NULL);
-        if ( !p2m_is_hole(t) && !p2m_is_special(t) && !p2m_is_shared(t) )
+        if ( !(p2m_is_hole(t) | p2m_is_special(t) | p2m_is_shared(t)) )
         {
             set_gpfn_from_mfn(mfn_x(mfn) + i, gfn_x(gfn) + i);
             paging_mark_pfn_dirty(p2m->domain, _pfn(gfn_x(gfn) + i));



  parent reply	other threads:[~2022-06-23 11:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23 11:52 [PATCH v2 0/2] x86/p2m: type checking adjustments Jan Beulich
2022-06-23 11:53 ` [PATCH v2 1/2] x86/p2m: make p2m_get_page_from_gfn() handle grant case correctly Jan Beulich
2024-02-08  6:32   ` George Dunlap
2024-02-08  8:02     ` Jan Beulich
2024-02-08  8:09       ` George Dunlap
2022-06-23 11:54 ` Jan Beulich [this message]
2024-02-01 13:32   ` [PATCH v2 2/2] x86/p2m: aid the compiler in folding p2m_is_...() George Dunlap
2024-02-01 14:14     ` Jan Beulich
2024-02-07  3:07       ` George Dunlap
2024-02-07  8:50         ` Jan Beulich
2024-02-12 14:22         ` 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=7cce89f4-962e-bfbe-7d30-18fea7515bed@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.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.