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

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


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 23 Feb 2022 16:15:26 +0100
  • 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=juNOMnTTaHYlj1GzEVqLULFZt9qHfroO97X6sGnQeak=; b=mxWQJaWfT87S89A/JU4FoATAQB2xWAqR2MWw0Hnf/n7XkdZq/pYMazFmxsvP6JVtb1Jyc2v2/Ye6O3mLqN9Mh2ADug4wnhb4Y5t9wdhOj074Xdj24mvd9bqZvMPDAk2cxn6RCF7twhFlvrzQHUSUpiahDaTAgU0tGQR/VMOUkE38Qd+ZABJf8dSd6d+avG5mdT7n1VHjWedp9CpnVYJNmBKSfi74BT5nVMEjOmUFVOP3KNrEfu6B/Az8SMk92IzpTfB6bBOPvTGiECPNaN9k9pjIw7qrg+xhhMIdefff7W+PlVkvblhM4RCcsxDRE4KMaDZAlP5T1JGoMhy5ag9Ydg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NIVaUBF7YAcQAIFyN3rLPE2mXM3gkyPE+WI3IlTzB+l04gNhbd5gU01PsYa6h8E3vX3KejMfjJYXVpRGJV+53AnSY7kb30O519xNGaOrZ74lNcVfwzd0LM2/eYi+tS4YFkjECk97U8zdbqP5KrgxFBzSeQf1IXdpWMPBnrmp0Jh2D7Jp9YBSAE8Jm8JiO4O/2WZm0393XMsNwWnFyQI+1SktvXYWPAUHOsHBqF3c+W78EvoKTjkp6+yboCK5xkKICquGcxI4/eUOufHvjjuWPOmcGno9DDONdSI6CeeUQT3YVHKjXDGZVZfWOiCOX0n2Cibm06u1/PBtkAe3Dfbv2g==
  • 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: Wed, 23 Feb 2022 15:15:33 +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.

--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -606,7 +606,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)) &&
              (!p2m_is_shared(*t) || !(q & P2M_UNSHARE)) &&
              !mem_sharing_is_fork(p2m->domain) )
             return NULL;
@@ -840,7 +840,7 @@ p2m_remove_page(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®.