]> xenbits.xensource.com Git - xen.git/commitdiff
replace tlbflush check and operation with inline functions
authorDongli Zhang <dongli.zhang@oracle.com>
Tue, 20 Sep 2016 14:13:51 +0000 (16:13 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Sep 2016 14:13:51 +0000 (16:13 +0200)
This patch cleaned up the code by replacing complicated tlbflush check and
operation with inline functions. We should use those inline functions to
avoid the complicated tlbflush check and tlbflush operations when
implementing TODOs left in commit a902c12ee45fc9389eb8fe54eeddaf267a555c58
(More efficient TLB-flush filtering in alloc_heap_pages()).

"#include <asm/flushtlb.h>" is removed from xen/arch/x86/acpi/suspend.c to
avoid the compiling error after we include "<asm/flushtlb.h>" to
xen/include/xen/mm.h.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
xen/arch/x86/acpi/suspend.c
xen/common/page_alloc.c
xen/include/xen/mm.h

index 1d8344cb35d1910e6c591fd546e51db406e6a46c..d5c67ee1f33b05e94dc79e6c31963abdb8fdd681 100644 (file)
@@ -10,7 +10,6 @@
 #include <asm/processor.h>
 #include <asm/msr.h>
 #include <asm/debugreg.h>
-#include <asm/flushtlb.h>
 #include <asm/hvm/hvm.h>
 #include <asm/hvm/support.h>
 #include <asm/i387.h>
index 18ff6cfb4075479771d3e53168eb2e7204d02016..d7ca3a0a8f02d13490bebc664d88e646827b6a79 100644 (file)
@@ -827,14 +827,7 @@ static struct page_info *alloc_heap_pages(
         BUG_ON(pg[i].count_info != PGC_state_free);
         pg[i].count_info = PGC_state_inuse;
 
-        if ( pg[i].u.free.need_tlbflush &&
-             (pg[i].tlbflush_timestamp <= tlbflush_current_time()) &&
-             (!need_tlbflush ||
-              (pg[i].tlbflush_timestamp > tlbflush_timestamp)) )
-        {
-            need_tlbflush = 1;
-            tlbflush_timestamp = pg[i].tlbflush_timestamp;
-        }
+        accumulate_tlbflush(&need_tlbflush, &pg[i], &tlbflush_timestamp);
 
         /* Initialise fields which have other uses for free pages. */
         pg[i].u.inuse.type_info = 0;
@@ -849,15 +842,7 @@ static struct page_info *alloc_heap_pages(
     spin_unlock(&heap_lock);
 
     if ( need_tlbflush )
-    {
-        cpumask_t mask = cpu_online_map;
-        tlbflush_filter(mask, tlbflush_timestamp);
-        if ( !cpumask_empty(&mask) )
-        {
-            perfc_incr(need_flush_tlb_flush);
-            flush_tlb_mask(&mask);
-        }
-    }
+        filtered_flush_tlb_mask(tlbflush_timestamp);
 
     return pg;
 }
index f470e495f3698c4e99feaf643c61505b745ef81f..50db01de804c509f609e3f553759f6eb3a759e0f 100644 (file)
@@ -51,6 +51,7 @@
 #include <xen/spinlock.h>
 #include <xen/typesafe.h>
 #include <xen/kernel.h>
+#include <xen/perfc.h>
 #include <public/memory.h>
 
 TYPE_SAFE(unsigned long, mfn);
@@ -567,4 +568,32 @@ int prepare_ring_for_helper(struct domain *d, unsigned long gmfn,
                             struct page_info **_page, void **_va);
 void destroy_ring_for_helper(void **_va, struct page_info *page);
 
+#include <asm/flushtlb.h>
+
+static inline void accumulate_tlbflush(bool *need_tlbflush,
+                                       const struct page_info *page,
+                                       uint32_t *tlbflush_timestamp)
+{
+    if ( page->u.free.need_tlbflush &&
+         page->tlbflush_timestamp <= tlbflush_current_time() &&
+         (!*need_tlbflush ||
+          page->tlbflush_timestamp > *tlbflush_timestamp) )
+    {
+        *need_tlbflush = true;
+        *tlbflush_timestamp = page->tlbflush_timestamp;
+    }
+}
+
+static inline void filtered_flush_tlb_mask(uint32_t tlbflush_timestamp)
+{
+    cpumask_t mask = cpu_online_map;
+
+    tlbflush_filter(mask, tlbflush_timestamp);
+    if ( !cpumask_empty(&mask) )
+    {
+        perfc_incr(need_flush_tlb_flush);
+        flush_tlb_mask(&mask);
+    }
+}
+
 #endif /* __XEN_MM_H__ */