diff mbox

x86/mm: consolidate setting of TLB flush time stamps

Message ID 594A6283020000780016517F@prv-mh.provo.novell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Beulich June 21, 2017, 10:11 a.m. UTC
Move code and comment into a helper function instead of repeating it in
multiple places.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
x86/mm: consolidate setting of TLB flush time stamps

Move code and comment into a helper function instead of repeating it in
multiple places.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -602,6 +602,20 @@ static inline void guest_get_eff_kern_l1
     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];
 
@@ -2417,16 +2431,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--;
     }
@@ -2434,9 +2439,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;
     }
@@ -2486,16 +2489,7 @@ static int __put_page_type(struct page_i
                 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) )

Comments

Andrew Cooper June 21, 2017, 10:29 a.m. UTC | #1
On 21/06/17 11:11, Jan Beulich wrote:
> Move code and comment into a helper function instead of repeating it in
> multiple places.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reivewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox

Patch

--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -602,6 +602,20 @@  static inline void guest_get_eff_kern_l1
     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];
 
@@ -2417,16 +2431,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--;
     }
@@ -2434,9 +2439,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;
     }
@@ -2486,16 +2489,7 @@  static int __put_page_type(struct page_i
                 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) )