[Devel] [PATCH vz10 13/14] mm: memory: guard asm/tsc.h include for UML builds

Eva Kurchatova eva.kurchatova at virtuozzo.com
Fri Jun 26 01:08:15 MSK 2026


mm/memory.c includes asm/tsc.h for the CLKS2NSEC() macro used in VZ
latency statistics collection.  Under UML, asm/tsc.h either does not
exist or conflicts with the UML timex definitions, breaking the
build.

Guard the include with #ifdef CONFIG_X86 and provide a no-op
fallback that defines CLKS2NSEC(c) as 0.  Also guard the real
CLKS2NSEC definition (which references tsc_khz) with the same
condition.

Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>

https://virtuozzo.atlassian.net/browse/VSTOR-134732
Feature: fix kunit
---
 mm/memory.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mm/memory.c b/mm/memory.c
index 837194e87664..77d16507f8ec 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -87,7 +87,11 @@
 #include <linux/uaccess.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
+#ifdef CONFIG_X86
 #include <asm/tsc.h>
+#else
+#define CLKS2NSEC(c)	(0)
+#endif
 
 #include "pgalloc-track.h"
 #include "internal.h"
@@ -4455,7 +4459,9 @@ static struct folio *alloc_swap_folio(struct vm_fault *vmf)
 
 static DECLARE_WAIT_QUEUE_HEAD(swapcache_wq);
 
+#ifdef CONFIG_X86
 #define CLKS2NSEC(c)	((c) * 1000000 / tsc_khz)
+#endif
 
 /*
  * We enter with non-exclusive mmap_lock (to exclude vma changes,
-- 
2.54.0



More information about the Devel mailing list