]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
x86/mm: consolidate setting of TLB flush time stamps
authorJan Beulich <jbeulich@suse.com>
Thu, 22 Jun 2017 07:57:15 +0000 (09:57 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 22 Jun 2017 07:57:15 +0000 (09:57 +0200)
Move code and comment into a helper function instead of repeating it in
multiple places.

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

index 14b9125ef5b559b16d114965f56373a8db7d8db3..5cdfce04b3937bc36359b2ab9b39579bf1dcfdc8 100644 (file)
@@ -602,6 +602,20 @@ static inline void guest_get_eff_kern_l1e(struct vcpu *v, unsigned long addr,
     TOGGLE_MODE();
 }
 
+static inline void page_set_tlbflush_timestamp(struct page_info *page)
+{
+    /*
+     * Record TLB information for flush later. We do not stamp page tables
+     * when running in shadow mode:
+     *  1. Pointless, since it's the shadow pt's which must be tracked.
+     *  2. Shadow mode reuses this field for shadowed page tables to store
+     *     flags info -- we don't want to conflict with that.
+     */
+    if ( !(page->count_info & PGC_page_table) ||
+         !shadow_mode_enabled(page_get_owner(page)) )
+        page->tlbflush_timestamp = tlbflush_current_time();
+}
+
 const char __section(".bss.page_aligned.const") __aligned(PAGE_SIZE)
     zero_page[PAGE_SIZE];
 
@@ -2405,16 +2419,7 @@ static int __put_final_page_type(
     /* No need for atomic update of type_info here: noone else updates it. */
     if ( rc == 0 )
     {
-        /*
-         * Record TLB information for flush later. We do not stamp page tables
-         * when running in shadow mode:
-         *  1. Pointless, since it's the shadow pt's which must be tracked.
-         *  2. Shadow mode reuses this field for shadowed page tables to
-         *     store flags info -- we don't want to conflict with that.
-         */
-        if ( !(shadow_mode_enabled(page_get_owner(page)) &&
-               (page->count_info & PGC_page_table)) )
-            page->tlbflush_timestamp = tlbflush_current_time();
+        page_set_tlbflush_timestamp(page);
         wmb();
         page->u.inuse.type_info--;
     }
@@ -2422,9 +2427,7 @@ static int __put_final_page_type(
     {
         ASSERT((page->u.inuse.type_info &
                 (PGT_count_mask|PGT_validated|PGT_partial)) == 1);
-        if ( !(shadow_mode_enabled(page_get_owner(page)) &&
-               (page->count_info & PGC_page_table)) )
-            page->tlbflush_timestamp = tlbflush_current_time();
+        page_set_tlbflush_timestamp(page);
         wmb();
         page->u.inuse.type_info |= PGT_validated;
     }
@@ -2474,16 +2477,7 @@ static int __put_page_type(struct page_info *page,
                 break;
             }
 
-            /*
-             * Record TLB information for flush later. We do not stamp page
-             * tables when running in shadow mode:
-             *  1. Pointless, since it's the shadow pt's which must be tracked.
-             *  2. Shadow mode reuses this field for shadowed page tables to
-             *     store flags info -- we don't want to conflict with that.
-             */
-            if ( !(shadow_mode_enabled(page_get_owner(page)) &&
-                   (page->count_info & PGC_page_table)) )
-                page->tlbflush_timestamp = tlbflush_current_time();
+            page_set_tlbflush_timestamp(page);
         }
 
         if ( likely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) == x) )