[Devel] [PATCH vz10 23/32] mm/memory: build the page fault latency accounting for x86 only
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Aug 21 19:37:09 MSK 2026
From: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
mm/memory.c accounts the latency of major page faults into the VZ
statistics, converting TSC cycles to nanoseconds with CLKS2NSEC(), which
is built on tsc_khz from asm/tsc.h. Both the header and the variable are
x86-only, so generic mm/memory.c does not compile elsewhere - User Mode
Linux, which we now want for KUnit, has no asm/tsc.h at all:
mm/memory.c:90:10: fatal error: asm/tsc.h: No such file or directory
Include the header on x86 only and let CLKS2NSEC() evaluate to 0 on other
architectures, so the accounting keeps working where there is a cycle
counter to read and reports no latency where there is not.
Feature: ve: extra statistics (mm, latency)
https://virtuozzo.atlassian.net/browse/VSTOR-134732
Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
mm/memory.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/mm/memory.c b/mm/memory.c
index 837194e87664..5e414c68f3a9 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -87,7 +87,9 @@
#include <linux/uaccess.h>
#include <asm/tlb.h>
#include <asm/tlbflush.h>
+#ifdef CONFIG_X86
#include <asm/tsc.h>
+#endif
#include "pgalloc-track.h"
#include "internal.h"
@@ -4455,7 +4457,12 @@ 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)
+#else
+/* No cycle counter to convert from outside x86 */
+#define CLKS2NSEC(c) (0)
+#endif
/*
* We enter with non-exclusive mmap_lock (to exclude vma changes,
--
2.47.1
More information about the Devel
mailing list