[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 2/2] x86/p2m: aid the compiler in folding p2m_is_...()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 23 Jun 2022 13:54:40 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=EeosBR+ZdmfwY/nfD62Mb7pRTRQW2IaAj5iLTpTX/vA=; b=l8npNh/iDGQw/zmKncpJPm0p4JkNvzqBrDMinlpK1n3zlWrDS8Hk5D5kmmNxoJRSUaoZglD4A532uDjbC0/Ab2bsKwmiaAoAQ6Pj9gxIQsy0O4cPRvsFEJs1w7yzAvroDUPYVE8Pqv2YkF3ZQaYbJvEjl7S6DG6fMwo1pzVLwA56IeEmJblhtAwOLijzGpfIKAqxsuCz6nv925sYva9qestPebxfAtxeGbdScpKctjNW/xQpZNwOTyzbea3jWVnvVeAnsu170ron2u2m8NMTh7tGBLvWOTvbcgbYUAz8sVrtxnbvTiPfwC+k425m6NzjIe+4AvpfDWtyrD3cByKpBQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IP/gR4hYFxFpZHle6lqQhWL7J1F+sYNenPVcA6BxqVHDERLEVXjPcXV8lrYxD8UcQ8iKV8da/25UlSjI0D+dujpXcGGBbMfaMQ1ekUq0IRANDCr/6fgZGBFFCBnCsdM2x+IEuZ3i6Ug6xentHTFrwzbl/DfFS9A4cnotzF4HqpG355R073WqbYgtFrujCruKVX599XVHSleSeRHpgSKMSJxMRDwSqvOEN1owY6KeBE0g7jdvvd8yanNFeX4KCxk2KqpEUZV+ruZ/zG2sDimk1XXXC05tIokaeFk9JitVShU6QsmGb1VopEEBEVkoe07nM4udg+bfp+Mje8svjLNqGA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>
  • Delivery-date: Thu, 23 Jun 2022 11:54:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxx>
---
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));




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.