]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
xen/common: Split tlb-clock.h out of mm.h
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 12 Mar 2025 14:12:47 +0000 (14:12 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 12 Mar 2025 18:45:45 +0000 (18:45 +0000)
xen/mm.h includes asm/tlbflush.h almost at the end, which creates a horrible
tangle.  This is in order to provide two common files with an abstraction over
the x86-specific TLB clock logic.

First, introduce CONFIG_HAS_TLB_CLOCK, selected by x86 only.  Next, introduce
xen/tlb-clock.h, providing empty stubs, and include this into memory.c and
page_alloc.c

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>
There is still a mess here with the common vs x86 split, but it's better
contained than before.

xen/arch/x86/Kconfig
xen/common/Kconfig
xen/common/memory.c
xen/common/page_alloc.c
xen/include/xen/mm.h
xen/include/xen/tlb-clock.h [new file with mode: 0644]

index 6e41bc0fb435e4fccaf3d4a76d69b6007ce6e2fa..e9a166ee3dd010f737efb1e6ab90290ba157cbc8 100644 (file)
@@ -28,6 +28,7 @@ config X86
        select HAS_PCI_MSI
        select HAS_PIRQ
        select HAS_SCHED_GRANULARITY
+       select HAS_TLB_CLOCK
        select HAS_UBSAN
        select HAS_VMAP
        select HAS_VPCI if HVM
index 6166327f4d149915936760491e5fc37930133a9c..dcf7d9d00d0a5debb0c7db85f582cb798b521908 100644 (file)
@@ -83,6 +83,9 @@ config HAS_PMAP
 config HAS_SCHED_GRANULARITY
        bool
 
+config HAS_TLB_CLOCK
+       bool
+
 config HAS_UBSAN
        bool
 
index 61a94b23abae2becf8c0626fb00cdeecff6460c5..9138fd09669668de5a9489e3be0d300a110e4e65 100644 (file)
@@ -24,6 +24,7 @@
 #include <xen/perfc.h>
 #include <xen/sched.h>
 #include <xen/sections.h>
+#include <xen/tlb-clock.h>
 #include <xen/trace.h>
 
 #include <asm/current.h>
index bc029ea797a2e783e9250076bcb057f2c94d8284..b90c3d7988b4df13de5fdcb73017c61ebc9f2fa9 100644 (file)
 #include <xen/sections.h>
 #include <xen/softirq.h>
 #include <xen/spinlock.h>
+#include <xen/tlb-clock.h>
 #include <xen/vm_event.h>
 #include <xen/xvmalloc.h>
 
index 45000cc3f64b3eec4122f44cae7f79899ad6f024..fff36ff903d69e854ac8146369425d7793ad491b 100644 (file)
@@ -588,33 +588,6 @@ unsigned long get_upper_mfn_bound(void);
 
 #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;
-
-    cpumask_copy(&mask, &cpu_online_map);
-    tlbflush_filter(&mask, tlbflush_timestamp);
-    if ( !cpumask_empty(&mask) )
-    {
-        perfc_incr(need_flush_tlb_flush);
-        arch_flush_tlb_mask(&mask);
-    }
-}
-
 enum XENSHARE_flags {
     SHARE_rw,
     SHARE_ro,
diff --git a/xen/include/xen/tlb-clock.h b/xen/include/xen/tlb-clock.h
new file mode 100644 (file)
index 0000000..796c0be
--- /dev/null
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef XEN_TLB_CLOCK_H
+#define XEN_TLB_CLOCK_H
+
+#include <xen/types.h>
+
+#ifdef CONFIG_HAS_TLB_CLOCK
+
+#include <xen/mm.h>
+
+#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;
+
+    cpumask_copy(&mask, &cpu_online_map);
+    tlbflush_filter(&mask, tlbflush_timestamp);
+    if ( !cpumask_empty(&mask) )
+    {
+        perfc_incr(need_flush_tlb_flush);
+        arch_flush_tlb_mask(&mask);
+    }
+}
+
+#else /* !CONFIG_HAS_TLB_CLOCK */
+
+struct page_info;
+static inline void accumulate_tlbflush(
+    bool *need_tlbflush, const struct page_info *page,
+    uint32_t *tlbflush_timestamp) {}
+static inline void filtered_flush_tlb_mask(uint32_t tlbflush_timestamp) {}
+
+#endif /* !CONFIG_HAS_TLB_CLOCK*/
+#endif /* XEN_TLB_CLOCK_H */