@@ -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
@@ -83,6 +83,9 @@ config HAS_PMAP
config HAS_SCHED_GRANULARITY
bool
+config HAS_TLB_CLOCK
+ bool
+
config HAS_UBSAN
bool
@@ -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>
@@ -137,6 +137,7 @@
#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>
@@ -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,
new file mode 100644
@@ -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 */
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 | 1 + xen/common/Kconfig | 3 +++ xen/common/memory.c | 1 + xen/common/page_alloc.c | 1 + xen/include/xen/mm.h | 27 -------------------- xen/include/xen/tlb-clock.h | 49 +++++++++++++++++++++++++++++++++++++ 6 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 xen/include/xen/tlb-clock.h