gnttab: drop struct active_grant_entry's gfn field for release builds
authorJan Beulich <jbeulich@suse.com>
Thu, 17 Aug 2017 12:44:02 +0000 (14:44 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 17 Aug 2017 12:44:02 +0000 (14:44 +0200)
This shrinks the size from 48 to 40 bytes bytes on 64-bit builds.
Switch to gfn_t at once.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/grant_table.c

index b522e626aa2497ddfdda6f6fbf612e3f0cf55e28..fdd8e4ed5aa4f460e9d825d9422b0d9b0d1f4c46 100644 (file)
@@ -185,7 +185,9 @@ struct active_grant_entry {
     grant_ref_t   trans_gref;
     struct domain *trans_domain;
     unsigned long frame;  /* Frame being granted.                     */
-    unsigned long gfn;    /* Guest's idea of the frame being granted. */
+#ifndef NDEBUG
+    gfn_t         gfn;    /* Guest's idea of the frame being granted. */
+#endif
     spinlock_t    lock;      /* lock to protect access of this entry.
                                 see docs/misc/grant-tables.txt for
                                 locking protocol                      */
@@ -195,6 +197,13 @@ struct active_grant_entry {
 #define _active_entry(t, e) \
     ((t)->active[(e)/ACGNT_PER_PAGE][(e)%ACGNT_PER_PAGE])
 
+static inline void act_set_gfn(struct active_grant_entry *act, gfn_t gfn)
+{
+#ifndef NDEBUG
+    act->gfn = gfn;
+#endif
+}
+
 DEFINE_PERCPU_RWLOCK_GLOBAL(grant_rwlock);
 
 static inline void gnttab_flush_tlb(const struct domain *d)
@@ -891,7 +900,7 @@ map_grant_ref(
                                  op->flags & GNTMAP_readonly, rd);
             if ( rc != GNTST_okay )
                 goto unlock_out_clear;
-            act->gfn = gfn;
+            act_set_gfn(act, _gfn(gfn));
             act->domid = ld->domain_id;
             act->frame = frame;
             act->start = 0;
@@ -2278,7 +2287,7 @@ acquire_grant_for_copy(
             act->trans_domain = td;
             act->trans_gref = trans_gref;
             act->frame = grant_frame;
-            act->gfn = gfn_x(INVALID_GFN);
+            act_set_gfn(act, INVALID_GFN);
             /*
              * The actual remote remote grant may or may not be a sub-page,
              * but we always treat it as one because that blocks mappings of
@@ -2304,7 +2313,7 @@ acquire_grant_for_copy(
             rc = get_paged_frame(gfn, &grant_frame, page, readonly, rd);
             if ( rc != GNTST_okay )
                 goto unlock_out_clear;
-            act->gfn = gfn;
+            act_set_gfn(act, _gfn(gfn));
             is_sub_page = false;
             trans_page_off = 0;
             trans_length = PAGE_SIZE;
@@ -2315,7 +2324,7 @@ acquire_grant_for_copy(
                                  readonly, rd);
             if ( rc != GNTST_okay )
                 goto unlock_out_clear;
-            act->gfn = sha2->full_page.frame;
+            act_set_gfn(act, _gfn(sha2->full_page.frame));
             is_sub_page = false;
             trans_page_off = 0;
             trans_length = PAGE_SIZE;
@@ -2326,7 +2335,7 @@ acquire_grant_for_copy(
                                  readonly, rd);
             if ( rc != GNTST_okay )
                 goto unlock_out_clear;
-            act->gfn = sha2->sub_page.frame;
+            act_set_gfn(act, _gfn(sha2->sub_page.frame));
             is_sub_page = true;
             trans_page_off = sha2->sub_page.page_off;
             trans_length = sha2->sub_page.length;
@@ -3491,8 +3500,16 @@ void grant_table_warn_active_grants(struct domain *d)
 
         nr_active++;
         if ( nr_active <= WARN_GRANT_MAX )
-            printk(XENLOG_G_DEBUG "Dom%d has an active grant: GFN: %lx (MFN: %lx)\n",
-                   d->domain_id, act->gfn, act->frame);
+            printk(XENLOG_G_DEBUG "Dom%d has active grant %x ("
+#ifndef NDEBUG
+                   "GFN %lx, "
+#endif
+                   "MFN: %lx)\n",
+                   d->domain_id, ref,
+#ifndef NDEBUG
+                   gfn_x(act->gfn),
+#endif
+                   act->frame);
         active_entry_release(act);
     }